diff --git a/enrich.py b/enrich.py index 413a085..006a234 100755 --- a/enrich.py +++ b/enrich.py @@ -148,7 +148,7 @@ def get_clients_on_channel(capture, ap_channel, ap_bssid): return len(clients) -def get_aps_on_channel(capture, ap_channel): +def get_aps_on_channel(capture, ap_channel, ap_bssid): try: ap_channel = int(ap_channel) except ValueError: @@ -162,37 +162,45 @@ def get_aps_on_channel(capture, ap_channel): if not hasattr(packet, 'radiotap') or not hasattr(packet, 'wlan'): continue - # Pull the radiotap channel frequency packet_freq = getattr(packet.radiotap.channel, 'freq', None) if packet_freq is None: + print("[DEBUG] No channel frequency found.") continue packet_freq = int(packet_freq) packet_channel = get_channel_from_freq(packet_freq) + if packet_channel != ap_channel: + print(f"[DEBUG] Skipped packet on channel {packet_channel}, looking for {ap_channel}") continue - # Manually decode frame control field fc_raw = getattr(packet.wlan, 'fc', None) if not fc_raw: + print("[DEBUG] No FC field found.") continue fc_int = int(fc_raw, 16) frame_type = (fc_int >> 2) & 0b11 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): + print("[DEBUG] Not a Beacon or Probe Response.") continue bssid = getattr(packet.wlan, 'bssid', '').lower() if bssid: + print(f"[DEBUG] Adding BSSID: {bssid}") aps.add(bssid) + else: + print("[DEBUG] No BSSID found.") except Exception as e: print(f"[DEBUG] Failed packet: {e}") continue + print(f"[DEBUG] Final AP count: {len(aps)} | APs: {sorted(aps)}") return len(aps) def analyze_pcap(pcapng_path, start_ts, end_ts, ap_bssid, ap_channel):