我使用的是通过数据库导入常见的MAC段,各位使用的时候自定义下 macs 记得直接十六进制的自定义就可以,在上文中我分享过常见的MAC地址段,可以参考下。
import random
def randomMAC():
macs = mysql.getMac()
mac_1 = macs[1]
mac_2 = macs[2]
mac_3 = macs[3]
mac = [
random.randint(0x00, 0x7f),
random.randint(0x00, 0xff),
random.randint(0x00, 0xff) ]
mac = ':'.join(map(lambda x: "%02x" % x, mac))
mac = mac_1+':'+mac_2+':'+mac_3+':'+mac
return mac
1 条评论
文章深入浅出,既有深度思考,又不乏广度覆盖,令人叹为观止。