I have a assignment where I have to pseudonymisate the last 3 bytes of every mac adress I'm getting back as probe requests. By that I mean to format a printed mac adress like this ce:63:be:f5:04:00
to ce:63:be:aa:aa:a1
everytime I'm sniffing. How can I do this in my python script?
from scapy.all import *
def PacketHandler(pkt) :
if pkt.haslayer(Dot11) :
if pkt.type == 0 and pkt.subtype == 4 :
print("Client with Mac: %s probing for SSID: %s" % (pkt.addr2, pkt.info))
sniff(iface="wlan1mon", prn = PacketHandler)
You could use Scapy's RandMAC()
>>> a = "aa:bb:cc:00:11:22"
>>> a[:9] + str(RandMAC())[:8]
'aa:bb:cc:c5:ab:23'
Or simply craft the randomization yourself. If you don't know string slicing in Python, look it up: https://docs.python.org/3/tutorial/introduction.html#strings