Refactor analyze_pcap to improve layer checks and SSID extraction handling
This commit is contained in:
parent
7fbdcb310a
commit
57c9532b88
1 changed files with 7 additions and 3 deletions
10
enrich.py
10
enrich.py
|
@ -317,8 +317,7 @@ def analyze_pcap(pcapng_path, start_ts, end_ts, ap_bssid, ap_channel):
|
|||
try:
|
||||
print(f"[DEBUG] Layers: {[layer.layer_name for layer in packet.layers]}")
|
||||
|
||||
if 'radiotap' not in packet or 'wlan' not in packet or not 'wlan.mgt' in packet.get_multiple_layers('wlan.mgt'):
|
||||
print(f"[DEBUG] Skipping packet due to missing layers: {packet}")
|
||||
if 'radiotap' not in packet or 'wlan' not in packet:
|
||||
continue
|
||||
|
||||
radio = packet.radiotap
|
||||
|
@ -334,7 +333,12 @@ def analyze_pcap(pcapng_path, start_ts, end_ts, ap_bssid, ap_channel):
|
|||
if subtype not in (5, 8): # Probe Response or Beacon
|
||||
continue
|
||||
|
||||
ssid = getattr(packet.wlan.mgt, 'ssid', None)
|
||||
try:
|
||||
mgt = packet.get_multiple_layers('wlan.mgt')[0]
|
||||
ssid = mgt.get_field('ssid')
|
||||
except (IndexError, AttributeError):
|
||||
continue
|
||||
|
||||
bssid = getattr(wlan, 'bssid', '').lower()
|
||||
|
||||
# For debugging purposes, print the SSID and BSSID
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue