Enhance AP detection by counting beacon frames before adding to the list of seen APs
This commit is contained in:
parent
47b7f4f818
commit
c3df0d124f
1 changed files with 9 additions and 6 deletions
15
listener.py
15
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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue