-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathfingerprinter.py
More file actions
73 lines (68 loc) · 2.46 KB
/
Copy pathfingerprinter.py
File metadata and controls
73 lines (68 loc) · 2.46 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python3
from scapy.all import *
import re
def dhcp_fingerprint(pkt):
"""Extract DHCP options (OS, hostname)"""
try:
if DHCP in pkt and pkt[DHCP].options:
for opt in pkt[DHCP].options:
if opt[0] == b'hostname' or opt[0] == 'hostname':
if isinstance(opt[1], bytes):
return opt[1].decode('utf-8', errors='ignore')
else:
return str(opt[1])
if opt[0] == b'vendor_class_id' or opt[0] == 'vendor_class_id':
if isinstance(opt[1], bytes):
return opt[1].decode('utf-8', errors='ignore')
else:
return str(opt[1])
except Exception:
pass
return None
def http_ua_capture(pkt):
"""Capture HTTP GET User-Agent from port 80"""
try:
if TCP in pkt and pkt[TCP].dport == 80 and Raw in pkt:
payload = pkt[Raw].load.decode('utf-8', errors='ignore')
match = re.search(r'User-Agent: (.*?)\r\n', payload, re.I)
if match:
return match.group(1)
except Exception:
pass
return None
def chipset_from_assoc(pkt):
"""Parse vendor-specific tags from association request"""
try:
if pkt.haslayer(Dot11AssoReq):
el = pkt.getlayer(Dot11Elt)
while el:
if el.ID == 221:
data = el.info.decode('utf-8', errors='ignore').lower()
if 'broadcom' in data:
return 'Broadcom'
elif 'intel' in data:
return 'Intel'
elif 'qualcomm' in data:
return 'Qualcomm'
elif 'mediatek' in data:
return 'Mediatek'
elif 'realtek' in data:
return 'Realtek'
el = el.payload.getlayer(Dot11Elt)
except Exception:
pass
return None
def probe_ssid_history(pkt):
"""Extract SSIDs from probe requests"""
try:
if pkt.haslayer(Dot11ProbeReq):
el = pkt.getlayer(Dot11Elt)
while el:
if el.ID == 0:
return el.info.decode('utf-8', errors='ignore')
el = el.payload.getlayer(Dot11Elt)
except Exception:
pass
return None
if __name__ == "__main__":
print("Fingerprinter module loaded. Use from jam_fi.py")