-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
39 lines (29 loc) · 942 Bytes
/
main.py
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
from scapy.all import rdpcap
from scapy.layers.dot11 import Dot11Beacon, Dot11Elt, Dot11
s = set()
def parse_beacon_packet(beacon):
"""
解析beacon帧中的字段
:param beacon:
:return:
"""
ssid = beacon[Dot11Elt].info.decode() if beacon[Dot11Elt].ID == 0 else None
bssid = beacon[Dot11].addr2
cap = beacon.sprintf("{Dot11Beacon:%Dot11Beacon.cap%}")
timestamp = beacon[Dot11Beacon].timestamp
beacon_interval = beacon[Dot11Beacon].beacon_interval
s.add(ssid)
print(f"SSID: {ssid}")
print(f"BSSID: {bssid}")
print(f"Capabilities: {cap}")
print(f"Timestamp: {timestamp}")
print(f"Beacon Interval: {beacon_interval}")
print("=" * 50)
# Load the .cap file
packets = rdpcap('./airportSniffsYHvPs.cap')
# Iterate through packets and print summary
for packet in packets:
if not packet.haslayer(Dot11Beacon):
continue
parse_beacon_packet(packet)
print(s)