Refactor handle_packet to detect APs using only beacon frames and improve unicast client counting logic.

This commit is contained in:
Yaro Kasear 2025-05-01 11:03:29 -05:00
parent 7be1b48831
commit a81321436a

View file

@ -77,9 +77,9 @@ def handle_packet(pkt):
a1 = dot11.addr1.lower() if dot11.addr1 else None a1 = dot11.addr1.lower() if dot11.addr1 else None
a2 = dot11.addr2.lower() if dot11.addr2 else None a2 = dot11.addr2.lower() if dot11.addr2 else None
# === Detect APs via beacons/probe responses === # === Detect APs via beacon frames only ===
if dot11.type == 0 and dot11.subtype in (5, 8): # Probe Response or Beacon if dot11.type == 0 and dot11.subtype == 8: # Beacon
if a2: if a2 and is_unicast(a2):
aps.add(a2) aps.add(a2)
ssid = parse_ssid(pkt) ssid = parse_ssid(pkt)
if ssid: if ssid:
@ -92,7 +92,6 @@ def handle_packet(pkt):
for mac in (sa, da): for mac in (sa, da):
if is_unicast(mac) and mac != target_ap_bssid: 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 clients[mac] += 1
# Track clients talking to the same AP we're connected to # Track clients talking to the same AP we're connected to