From 021ea90d9a92b87e28db5e4ace60053629088c1d Mon Sep 17 00:00:00 2001 From: Yaro Kasear Date: Thu, 1 May 2025 10:45:26 -0500 Subject: [PATCH] Refactor client tracking in handle_packet to simplify logic and ensure unicast clients are counted correctly, excluding the target AP BSSID. --- listener.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/listener.py b/listener.py index b525054..551691b 100755 --- a/listener.py +++ b/listener.py @@ -86,15 +86,18 @@ def handle_packet(pkt): ssid_map[a2] = ssid # === Track all seen clients === - if is_unicast(a1) and a1 not in aps: - clients[a1] += 1 - if is_unicast(a2) and a2 not in aps: - clients[a2] += 1 + sa = dot11.addr2.lower() if dot11.addr2 else None + da = dot11.addr1.lower() if dot11.addr1 else None + + for mac in (sa, da): + if is_unicast(mac) and mac != target_ap_bssid: + clients[mac] += 1 + # Track clients talking to the same AP we're connected to if target_ap_bssid: if a1 and a2: - if target_ap_bssid in (a1.lower(), a2.lower()): + if target_ap_bssid in (a1, a2): peer = a2 if a1 == target_ap_bssid else a1 if is_unicast(peer) and peer not in aps: ap_clients[target_ap_bssid][peer] += 1