-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscapy-sniff-wifi.py
More file actions
39 lines (29 loc) · 1.02 KB
/
Copy pathscapy-sniff-wifi.py
File metadata and controls
39 lines (29 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3
import scapy.all as scapy
# --------------------------------------------------
# VARIABLES
# --------------------------------------------------
dinfo = ''
# --------------------------------------------------
# FUNCTIONS
# --------------------------------------------------
def display(p):
global dinfo
try:
req = p.info.decode('utf-8') or '???'
except:
return
if( req != dinfo):
dinfo = req
daddr = p.addr2
print(f'[*] WIFI broadcast from {dinfo} ({daddr})')
# --------------------------------------------------
# MAIN
# --------------------------------------------------
if __name__ == '__main__':
scapy.conf.use_pcap=True
scapy.conf.sniff_promisc=False
# filter on packets with DOT11 layer with Beacons (type=0 and subtype=8)
# filter = lambda p: p.haslayer(scapy.Dot11)
filter = lambda p: p.haslayer(scapy.Dot11) and p[scapy.Dot11].type==0 and p[scapy.Dot11].subtype==8
scapy.sniff(count=0,prn=display,lfilter=filter,monitor=True)