项目作者: nick3499

项目描述 :
Python3: Spoof MAC Address: datetime.date(), subprocess.run()
高级语言: Python
项目地址: git://github.com/nick3499/spoof_mac_nick3499.git
创建时间: 2020-02-01T18:00:16Z
项目社区:https://github.com/nick3499/spoof_mac_nick3499

开源协议:MIT License

下载


spoof_mac_nick3499

Python3: Spoof MAC Address: datetime.date(), subprocess.run()

Caution

spoof_mac.py can break a network connection, so users should avoid negative outcomes.

Bang Line

#! /snap/bin/pypy3 starts with a shebang (#!), which functions as a magic number):

Unix or Linux scripts may start with a shebang) (#!, 23 21) followed by the path to an interpreter, if the interpreter is likely to be different from the one from which the script was invoked.1

PyPy3 Snap

In Ubuntu, /snap/bin/pypy3 can be installed in the CLI: $ snap install pypy3. python3 can be used otherwise.

Index Daily MAC Address

datetime.date.today().weekday() returns an integer used to index the MAC
address of the day from mac_list.

  1. mac_list = [
  2. "9A:E9:30:BF:99:3E",
  3. "AA:F4:25:C5:0E:2E",
  4. "9E:FF:D2:A5:B4:6C",
  5. "9E:FF:D2:A5:B4:6D",
  6. "CA:F2:6D:CF:15:67",
  7. "02:4D:64:22:FE:70",
  8. "7E:AE:18:B4:32:19"
  9. ]

On Saturday, value returned by datetime.date.today().weekday() is 5, which indexes mac_list[5] which returns '02:4D:64:22:FE:70', the MAC address for Saturday MAC address.

Run the Script

$ python3 ~/Applications/py/spoof_mac/spoof_mac.py

Alternative: Shell Script

  1. #! /bin/sh
  2. # spoof MAC address
  3. $HOME/scripts/spoof_mac/./spoof_mac.py
  4. # check network device name with spoofed MAC address
  5. sudo lshw -class network | egrep 'serial|logical name'

gen_mac

gen_mac.py generates a pseudo-random MAC address. The first part of the spoofed MAC address comes from a list of organizationally unique identifiers.

  1. Magicnumber(programming): In_files#In_files)

ko-fi