From c3df0d124fc9d68b8b07dfe8a74b47474b9e903e Mon Sep 17 00:00:00 2001 From: Yaro Kasear Date: Thu, 1 May 2025 11:21:40 -0500 Subject: [PATCH] Enhance AP detection by counting beacon frames before adding to the list of seen APs --- listener.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/listener.py b/listener.py index 81f0108..fb7e616 100755 --- a/listener.py +++ b/listener.py @@ -22,6 +22,7 @@ ssid_map = {} # BSSID -> SSID ssid_signals = defaultdict(list) # SSID -> list of dBm ap_clients = defaultdict(lambda: defaultdict(int)) target_ap_bssid = None +beacon_counts = defaultdict(int) # === Signal handling === def stop_sniff(signum, frame): @@ -78,13 +79,15 @@ def handle_packet(pkt): a2 = dot11.addr2.lower() if dot11.addr2 else None # === Detect APs via beacon frames only === - if dot11.type == 0 and dot11.subtype == 8: # Beacon + if dot11.type == 0 and dot11.subtype == 8: if a2 and is_unicast(a2): - aps.add(a2) - ssid = parse_ssid(pkt) - if ssid: - ssid_map[a2] = ssid - print(f"[D] Beacon from AP {a2} (SSID: {ssid})") + beacon_counts[a2] += 1 + if beacon_counts[a2] > 1: + aps.add(a2) + ssid = parse_ssid(pkt) + if ssid: + ssid_map[a2] = ssid + print(f"[D] Beacon from AP {a2} (SSID: {ssid}) [count={beacon_counts[a2]}]") # === Track all seen clients === if dot11.type == 2: