Skip to content

Instantly share code, notes, and snippets.

@xen0bit
Created September 9, 2023 03:24
Show Gist options
  • Save xen0bit/fb38af397b41b4cef5e3903dfe4ee94a to your computer and use it in GitHub Desktop.
Save xen0bit/fb38af397b41b4cef5e3903dfe4ee94a to your computer and use it in GitHub Desktop.
Scapy ESPNOW
#sudo setcap cap_net_raw=eip /bin/python3.10
from scapy.all import *
from struct import *
def dissect(srcMac, load):
categoryCode = unpack('B', load[:1])[0]
organizationIdentifier = load[1:4]
randomValues = load[4:8]
# Vendor Specific
vsElementId = unpack('B', load[8:9])[0]
vsLength = unpack('B', load[9:10])[0]
vsOrganizationIdentifier = load[10:13]
vsType = unpack('B', load[13:14])[0]
vsVersion = unpack('B', load[14:15])[0]
vsBody = load[15:]
print((srcMac,
categoryCode,
organizationIdentifier,
randomValues,
vsElementId,
vsLength,
vsOrganizationIdentifier,
vsType,
vsVersion,
vsBody
))
def espnow(pkt):
if pkt.haslayer(Dot11):
if pkt.type == 0 and pkt.subtype == 13:
if pkt.addr3 == 'ff:ff:ff:ff:ff:ff':
dissect(pkt.addr2, pkt['Raw'].load)
sniff(iface='wlan0mon', prn=espnow)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment