Trying to shake out Clients on AP.
This commit is contained in:
parent
c1d31ba057
commit
295f17bd91
1 changed files with 13 additions and 10 deletions
|
@ -20,29 +20,32 @@ def convert_timestamp_to_epoch(ts_string):
|
|||
|
||||
def get_clients_on_ap(capture, ap_bssid):
|
||||
clients = set()
|
||||
ap_bssid = ap_bssid.lower() # Normalize for comparison
|
||||
|
||||
for packet in capture:
|
||||
try:
|
||||
if not hasattr(packet, 'wlan'):
|
||||
continue
|
||||
|
||||
sa = packet.wlan.sa
|
||||
da = getattr(packet.wlan, 'da', None)
|
||||
bssid = getattr(packet.wlan, 'bssid', None)
|
||||
sa = getattr(packet.wlan, 'sa', '').lower()
|
||||
da = getattr(packet.wlan, 'da', '').lower()
|
||||
bssid = getattr(packet.wlan, 'bssid', '').lower()
|
||||
|
||||
# Skip if AP is the sender
|
||||
if sa == ap_bssid:
|
||||
continue
|
||||
|
||||
# Count if the AP is the target or part of the BSSID context
|
||||
if da == ap_bssid or bssid == ap_bssid:
|
||||
clients.add(sa)
|
||||
# Count any frame *to or from* a client, if AP is involved
|
||||
if bssid == ap_bssid or sa == ap_bssid or da == ap_bssid:
|
||||
# If it's the AP sending, add the destination (client)
|
||||
if sa == ap_bssid and da and da != ap_bssid:
|
||||
clients.add(da)
|
||||
# If it's the client sending, add the source
|
||||
elif sa and sa != ap_bssid:
|
||||
clients.add(sa)
|
||||
|
||||
except AttributeError:
|
||||
continue
|
||||
|
||||
return len(clients)
|
||||
|
||||
|
||||
def analyze_pcap(pcapng_path, start_ts, end_ts, ap_bssid, ap_channel):
|
||||
|
||||
cap = pyshark.FileCapture(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue