Refactor SSID extraction in analyze_pcap to handle tags and improve error handling
This commit is contained in:
parent
33e6fb35c9
commit
78a6b225fc
1 changed files with 13 additions and 6 deletions
19
enrich.py
19
enrich.py
|
@ -334,13 +334,20 @@ def analyze_pcap(pcapng_path, start_ts, end_ts, ap_bssid, ap_channel):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
mgt = packet.get_multiple_layers('wlan.mgt')[0]
|
mgt = packet.get_multiple_layers('wlan.mgt')[0]
|
||||||
print(mgt._all_fields)
|
ssid = None
|
||||||
ssid = mgt.get_field('ssid')
|
|
||||||
if ssid is None:
|
for tag in mgt.get_field('tag'):
|
||||||
print("[DEBUG] SSID is None (explicitly)")
|
if tag.get('wlan.tag.number') == '0' and 'wlan.ssid' in tag:
|
||||||
|
raw_ssid = tag['wlan.ssid']
|
||||||
|
ssid_bytes = bytes.fromhex(raw_ssid.replace(':', ''))
|
||||||
|
ssid = ssid_bytes.decode('utf-8', errors='replace')
|
||||||
|
break
|
||||||
|
|
||||||
|
if not ssid:
|
||||||
|
print("[DEBUG] No SSID found in tags.")
|
||||||
continue
|
continue
|
||||||
except (IndexError, AttributeError):
|
except Exception as e:
|
||||||
print("Debug: No SSID found in packet, or I am terrible at parsing")
|
print(f"[DEBUG] Error parsing SSID: {e}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
bssid = getattr(wlan, 'bssid', '').lower()
|
bssid = getattr(wlan, 'bssid', '').lower()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue