1

I am using Scapy to scan for Wireless Probes form devices a our office environment. I am using an OpenWrt Router for it. I am using the Python script (see below). Now I need help to let Scapy log the Scan that I run while starting the router. While logging the scan results (every Probe) I want to let the script log each probe containing the information including the Timestamp into a CSV as comma separated columns. The CSV may be saved to an attached USB storage onto the Router /mnt/sda1/.

A second option I would like is to report the log directly towards a webservice using a specified URL.

Output line while running script is now: "Probe Request Captured: Target: ff:ff:ff:ff:ff:ff Source: xx:xx:xx:xx:xx:xx SSID: wifi RSSi: -76

The script that works now on the router:

from scapy.all import *

PROBE_REQUEST_TYPE=0
PROBE_REQUEST_SUBTYPE=4

WHITELIST = ['00:00:00:00:00:00',] # Replace this with your phone's MAC address


def PacketHandler(pkt):
if pkt.haslayer(Dot11):
    if pkt.type==PROBE_REQUEST_TYPE and pkt.subtype == PROBE_REQUEST_SUBTYPE and ( pkt.addr2.lower() not in WHITELIST or pkt.addr2.upper() not in WHITELIST):
        PrintPacket(pkt)

def PrintPacket(pkt):
print "Probe Request Captured:"
try:
    extra = pkt.notdecoded
except:
    extra = None
if extra!=None:
    signal_strength = -(256-ord(extra[-4:-3]))
else:
    signal_strength = -100
    print "No signal strength found"    
print "Target: %s Source: %s SSID: %s RSSi: %d"%(pkt.addr3,pkt.addr2,pkt.getlayer(Dot11ProbeReq).info,signal_strength)

def main():
from datetime import datetime
print "[%s] Starting scan"%datetime.now()
print "Scanning for:"
print "\n"
sniff(iface=sys.argv[1],prn=PacketHandler,store=0)

if __name__=="__main__":
    main()
the
  • 21,007
  • 11
  • 68
  • 101
Chrisvr
  • 9
  • 4

0 Answers0