Use Python code to generate a random MAC address, use Python network programming or available, if using the Scapy module, you can use the Randmac () function to generate a Mac directly.
Python
Copy the 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
--------------------------------Running Results-----------------------------------
E4:13:0e:1a:73:f5
The following FAKE_HW are MAC addresses packaged in a struct in binary format
Copy the 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 whole content of this article, I hope you can enjoy.