Last active
July 15, 2020 08:09
-
-
Save adenkiewicz/a2dcd3bbfe9292482e08fc15ba73410e to your computer and use it in GitHub Desktop.
Scapy-based 802.11 probes tracker.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import argparse | |
from datetime import datetime | |
from scapy.all import sniff, Dot11ProbeReq | |
import asyncio | |
def parse_args(): | |
desc = "802.11 probes tracker by Adrian Denkiewicz" | |
parser = argparse.ArgumentParser(description=desc) | |
parser.add_argument("--interface", "-i") | |
parser.add_argument("--only-new", "-n", action="store_true") | |
return vars(parser.parse_args()) | |
def get_probes(packet): | |
# skip non 802.11 probes frames | |
if not packet.haslayer(Dot11ProbeReq): | |
return | |
if packet.type == 0 and packet.subtype == 4 and packet.info: # FIXME? | |
mac = packet.addr2.upper() | |
entry = (mac, packet.info) | |
status = '' if entry in get_probes.known else 'NEW' | |
get_probes.known.add(entry) | |
if args["only_new"] and not status: | |
return | |
print('{0:5} {1} {2}'.format(status, mac, packet.info.decode("utf-8", "backslashreplace"))) | |
get_probes.known = set() | |
args = [] | |
def main(): | |
global args | |
args = parse_args() | |
sniff(iface=args["interface"], prn=get_probes, store=0) | |
asyncio.get_event_loop().run_forever() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment