Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scapy question
#1
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
Reply
#2
What is "extra", and why is ord(extra[-4:-3]) always 0?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  exception scapy kolikol 0 407 Feb-07-2025, 01:57 PM
Last Post: kolikol
  Scapy Basics Shivi 0 1,917 Sep-25-2023, 07:37 AM
Last Post: Shivi
  How to get every IP found by a Scapy traceroute? jao 0 3,170 Feb-06-2022, 01:00 AM
Last Post: jao
  can I set scan interval for scapy? korenron 0 2,884 Dec-31-2020, 01:43 PM
Last Post: korenron
  scapy trazom 1 3,250 Aug-30-2020, 04:17 PM
Last Post: micseydel
  network and scapy trazom 0 2,638 Aug-16-2020, 03:54 PM
Last Post: trazom
  Scapy route6 configuration peterkl 0 4,403 Mar-06-2017, 03:58 PM
Last Post: peterkl
  Scapy Beacon Frames peterkl 1 7,031 Feb-28-2017, 09:00 PM
Last Post: peterkl
  FIN scan with scapy peterkl 0 6,088 Feb-13-2017, 09:10 PM
Last Post: peterkl

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020