Python Scapy: How to stop sniff() function manually

How to stop scapy sniff() function to stop, simply use stop_filter parameter to pass a function

Here’s an example

Announce an Event in python:

e = Event()

Then write a function to stop sniff()

def stop_sniff():

Now finish the function to start sniff() and pass the Event e to the stop_filter

def start_sniff():
    sniff(iface='ASUS PCE-AC88 802.11ac Network Adapter',
          filter="dst host or src host", 
          stop_filter=lambda x: e.is_set())

Now sniff() will stop each time you call the stop_sniff() function and restart when you call start_sniff().

Leave a Comment

Your email address will not be published.