Python Forum

Full Version: Scapy question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys,

I'm trying to use scapy for the first time and I picked up a script that monitors Probe requests,

from scapy.all import *

PROBE_REQUEST_TYPE=0
PROBE_REQUEST_SUBTYPE=4

def PacketHandler(pkt):
    if pkt.haslayer(Dot11):
        if pkt.type==PROBE_REQUEST_TYPE and pkt.subtype == PROBE_REQUEST_SUBTYPE:
            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)
ai
def main():
    from datetime import datetime
    print "[%s] Starting scan"%datetime.now()
    print "Scanning for:"
    print "\n".join(mac for mac in WHITELIST)
    sniff(iface=sys.argv[1],prn=PacketHandler)
    
if __name__=="__main__":
    main()
The challenge I'm facing is with the signal strength, 
signal_strength = -(256-ord(extra[-4:-3]))
The output I get for every probe request is -256.

Has anyone ever face this behaviour?

Thanks
What is "extra", and why is ord(extra[-4:-3]) always 0?