Python Forum
can I set scan interval for scapy?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
can I set scan interval for scapy?
#1
I have found a simple code that sacn my environment
work good

but I want to set my own time it will start the scan
and also to now on which channels it is running\scanning

so it will run 5 full scan (all channels) , wait x min -- run scan again

what do I need to set in the sniif command?
def handle_packet(pkt):
    if not pkt.haslayer(Dot11):
        return
    if pkt.type == 0 and (pkt.subtype == 4 or pkt.subtype == 0 or pkt.subtype == 2): #subtype used to be 8 (APs) but is now 4 
       (Probe Requests)
        #logging.debug('Probe Recorded with MAC ' + curmac)
        curmac = pkt.addr2
        curmac = curmac.upper() #Assign variable to packet mac and make it uppercase
        SEEN_DEVICES.add(curmac) #Add to set of known devices (sets ignore duplicates so it is not a problem)
        for item in SEEN_DEVICES:
            TS = datetime.now().strftime("%d/%m/%Y %H:%M:%S:%f")
            if item in KNOWN_DEVICES:
                pass
                #item = d[item]
                #print(pkt.show())
            if pkt.dBm_AntSignal > -50 :
                print (TS + ': ' + item + ' MAC TimeStamp : ' + str(pkt.mac_timestamp) + ' with SSID: {pkt.info}'.format(pkt=pkt) + ' subtype is : ' + str(pkt.subtype)  + ' Signal : ' + str(pk$
            #else:
                #print (TS + "  "  + item + ' with SSID: {pkt.info}'.format(pkt=pkt))
        print('_________________')


 def main():
    logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p',filename='wifiscanner.log',level=logging.DEBUG) #setup logging to file
    logging.info('\n' + '\033[93m' + 'Wifi Scanner Initialized' + '\033[0m' + '\n') #announce that it has started to log file with yellow color
    print('\n' + '\033[93m' + 'Wifi Scanner Initialized' + '\033[0m' + '\n') #announce that it has started to command line with yellow color        (/n is newline)
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('--interface', '-i', default='mon0', # Change mon0 to your monitor-mode enabled wifi interface
                help='monitor mode enabled interface')
    args = parser.parse_args()
    sniff(iface=args.interface, prn=handle_packet) #start sniffin
    running = 1
    while 1:
        time.sleep(1) # Supposed to make an infinite loop, but for some reason it stops after a while
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Scapy Basics Shivi 0 947 Sep-25-2023, 07:37 AM
Last Post: Shivi
  How to send a HTTP response packet using scapy JeffreyStoner 0 2,667 Apr-18-2022, 05:23 AM
Last Post: JeffreyStoner
  How to get every IP found by a Scapy traceroute? jao 0 2,460 Feb-06-2022, 01:00 AM
Last Post: jao
  scapy wifi scan to get payload \ data korenron 0 2,153 Nov-16-2021, 01:47 PM
Last Post: korenron
  scapy trazom 1 2,634 Aug-30-2020, 04:17 PM
Last Post: micseydel
  network and scapy trazom 0 2,068 Aug-16-2020, 03:54 PM
Last Post: trazom
  Need Help with creating an IP packet with timestamp field using Scapy RTD 0 3,486 Jun-15-2019, 08:21 PM
Last Post: RTD
  Scapy, creating response for GET request. SyRex1013 4 5,123 Dec-11-2018, 07:39 AM
Last Post: SyRex1013
  sniffing real time with pyshark or scapy jeanapala 2 7,463 Nov-16-2017, 09:07 PM
Last Post: jeanapala
  Failed to recieve scapy udp packet SkyAmryBoi 1 3,814 Sep-29-2017, 01:26 PM
Last Post: camp0

Forum Jump:

User Panel Messages

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