Using Python code to generate a random MAC address, use the Python network programming or available, and use the Scapy module to generate the Mac directly using the Randmac () function.
Python
Copy Code code as follows:
Import Random
Maclist = []
For I in Range (1,7):
Randstr = "". Join (Random.sample ("0123456789abcdef", 2)
Maclist.append (RANDSTR)
Randmac = ":". Join (Maclist)
Print Randmac
--------------------------------Run Results-----------------------------------
E4:13:0e:1a:73:f5
The following FAKE_HW are MAC addresses packaged in binary format with struct
Copy Code code as follows:
Import Random
Import struct
Mac_bin_list = []
Mac_hex_list = []
For I in Range (1,7):
i = Random.randint (0x00,0xff)
Mac_bin_list.append (i)
FAKE_HW = Struct.pack ("bbbbbb", mac_bin_list[0), mac_bin_list[1], mac_bin_list[2], mac_bin_list[3], mac_bin_list[4], MAC_BIN_LIST[5])
For J in Mac_bin_list:
Mac_hex_list.append (Hex (j))
Hardware = ":". Join (Mac_hex_list). Replace ("0x", "")
Print hardware
--------------------Results-----------------------------
24:c7:6f:92:2c:42
The above is the entire content of this article, I hope you can enjoy.