Enhance get_aps_on_channel function to include BSSID parameter and improve packet handling with debug output
This commit is contained in:
parent
9b19c07b7a
commit
d69890fc3c
1 changed files with 12 additions and 4 deletions
16
enrich.py
16
enrich.py
|
|
@ -148,7 +148,7 @@ def get_clients_on_channel(capture, ap_channel, ap_bssid):
|
||||||
|
|
||||||
return len(clients)
|
return len(clients)
|
||||||
|
|
||||||
def get_aps_on_channel(capture, ap_channel):
|
def get_aps_on_channel(capture, ap_channel, ap_bssid):
|
||||||
try:
|
try:
|
||||||
ap_channel = int(ap_channel)
|
ap_channel = int(ap_channel)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|
@ -162,37 +162,45 @@ def get_aps_on_channel(capture, ap_channel):
|
||||||
if not hasattr(packet, 'radiotap') or not hasattr(packet, 'wlan'):
|
if not hasattr(packet, 'radiotap') or not hasattr(packet, 'wlan'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Pull the radiotap channel frequency
|
|
||||||
packet_freq = getattr(packet.radiotap.channel, 'freq', None)
|
packet_freq = getattr(packet.radiotap.channel, 'freq', None)
|
||||||
if packet_freq is None:
|
if packet_freq is None:
|
||||||
|
print("[DEBUG] No channel frequency found.")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
packet_freq = int(packet_freq)
|
packet_freq = int(packet_freq)
|
||||||
packet_channel = get_channel_from_freq(packet_freq)
|
packet_channel = get_channel_from_freq(packet_freq)
|
||||||
|
|
||||||
if packet_channel != ap_channel:
|
if packet_channel != ap_channel:
|
||||||
|
print(f"[DEBUG] Skipped packet on channel {packet_channel}, looking for {ap_channel}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Manually decode frame control field
|
|
||||||
fc_raw = getattr(packet.wlan, 'fc', None)
|
fc_raw = getattr(packet.wlan, 'fc', None)
|
||||||
if not fc_raw:
|
if not fc_raw:
|
||||||
|
print("[DEBUG] No FC field found.")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
fc_int = int(fc_raw, 16)
|
fc_int = int(fc_raw, 16)
|
||||||
frame_type = (fc_int >> 2) & 0b11
|
frame_type = (fc_int >> 2) & 0b11
|
||||||
subtype = (fc_int >> 4) & 0b1111
|
subtype = (fc_int >> 4) & 0b1111
|
||||||
|
|
||||||
# Beacon (8) or Probe Response (5) frames only
|
print(f"[DEBUG] FC: {fc_raw}, frame_type: {frame_type}, subtype: {subtype}")
|
||||||
|
|
||||||
if frame_type != 0 or subtype not in (5, 8):
|
if frame_type != 0 or subtype not in (5, 8):
|
||||||
|
print("[DEBUG] Not a Beacon or Probe Response.")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
bssid = getattr(packet.wlan, 'bssid', '').lower()
|
bssid = getattr(packet.wlan, 'bssid', '').lower()
|
||||||
if bssid:
|
if bssid:
|
||||||
|
print(f"[DEBUG] Adding BSSID: {bssid}")
|
||||||
aps.add(bssid)
|
aps.add(bssid)
|
||||||
|
else:
|
||||||
|
print("[DEBUG] No BSSID found.")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"[DEBUG] Failed packet: {e}")
|
print(f"[DEBUG] Failed packet: {e}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
print(f"[DEBUG] Final AP count: {len(aps)} | APs: {sorted(aps)}")
|
||||||
return len(aps)
|
return len(aps)
|
||||||
|
|
||||||
def analyze_pcap(pcapng_path, start_ts, end_ts, ap_bssid, ap_channel):
|
def analyze_pcap(pcapng_path, start_ts, end_ts, ap_bssid, ap_channel):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue