From a81321436a351b81f203de9755bef7f4548756f8 Mon Sep 17 00:00:00 2001 From: Yaro Kasear Date: Thu, 1 May 2025 11:03:29 -0500 Subject: [PATCH] Refactor handle_packet to detect APs using only beacon frames and improve unicast client counting logic. --- listener.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/listener.py b/listener.py index dd9183f..6bf72cd 100755 --- a/listener.py +++ b/listener.py @@ -77,9 +77,9 @@ def handle_packet(pkt): a1 = dot11.addr1.lower() if dot11.addr1 else None a2 = dot11.addr2.lower() if dot11.addr2 else None - # === Detect APs via beacons/probe responses === - if dot11.type == 0 and dot11.subtype in (5, 8): # Probe Response or Beacon - if a2: + # === Detect APs via beacon frames only === + if dot11.type == 0 and dot11.subtype == 8: # Beacon + if a2 and is_unicast(a2): aps.add(a2) ssid = parse_ssid(pkt) if ssid: @@ -92,7 +92,6 @@ def handle_packet(pkt): for mac in (sa, da): if is_unicast(mac) and mac != target_ap_bssid: - print(f"[D] Counting client: {mac} (frame type: {dot11.type}, subtype: {dot11.subtype})") clients[mac] += 1 # Track clients talking to the same AP we're connected to