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:
|
||||
mgt = packet.get_multiple_layers('wlan.mgt')[0]
|
||||
print(mgt._all_fields)
|
||||
ssid = mgt.get_field('ssid')
|
||||
if ssid is None:
|
||||
print("[DEBUG] SSID is None (explicitly)")
|
||||
ssid = None
|
||||
|
||||
for tag in mgt.get_field('tag'):
|
||||
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
|
||||
except (IndexError, AttributeError):
|
||||
print("Debug: No SSID found in packet, or I am terrible at parsing")
|
||||
except Exception as e:
|
||||
print(f"[DEBUG] Error parsing SSID: {e}")
|
||||
continue
|
||||
|
||||
bssid = getattr(wlan, 'bssid', '').lower()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue