Skip to content

Instantly share code, notes, and snippets.

@arall
Created January 10, 2020 09:51
Show Gist options
  • Save arall/9d2978435b30dd275ba87229d20ffa0f to your computer and use it in GitHub Desktop.
Save arall/9d2978435b30dd275ba87229d20ffa0f to your computer and use it in GitHub Desktop.
Python WiFi Probe scanner using tcpdump
#!/usr/bin/env python2.7
# Based on :https://gist.github.com/LoranKloeze/6b713022619c2b32b32c6400a55a8433
import subprocess
import re
import time
monitor_dev = "wlan1mon"
while True:
proc = subprocess.Popen(['tcpdump', '-l', '-I', '-i', monitor_dev, '-e', '-s', '256', 'type', 'mgt', 'subtype', 'probe-req'],stdout=subprocess.PIPE)
patt = '(-\d+)dBm signal antenna 0.+SA:([0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+) .+(Probe Request) \((.+)\)'
while True:
line = proc.stdout.readline()
if line != '':
m = re.search(patt, line)
if m is not None and len(m.groups()) == 4:
signal = m.group(1).rstrip()
mac = m.group(2).rstrip()
ssid = m.group(4).rstrip()
timestamp = int(time.time())
print "SSID: ", ssid, "MAC: ", mac, "Signal: ", signal, "Date: ", timestamp
else:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment