简体   繁体   中英

Python Scapy not sniffing

When I run the script, scapy does not listen on the interface, it just print out this error:

Traceback (most recent call last): File "keylogger.py", line 91, in sniff_packets(scapy_expression, target_site) File "keylogger.py", line 15, in sniff_packets sniff(filter=scapy_expression, prn=sniffer_callback(target_site), store=0, iface="eth0") TypeError: sniffer_callback() takes exactly 2 arguments (1 given)

The code where the error occurs is the following (the expression that sniff)

def sniff_packets(scapy_expression, target_site):
    sniff(filter=scapy_expression, prn=sniffer_callback(target_site), store=0, iface="eth0")

This is the callback function:

    def sniffer_callback(packet, target_site):

            print "[*] Got a packet"

I am not sure why scapy doesn't listen to the wire. Any help is appreciated.

The problem is: prn=sniffer_callback(target_site) . You call sniffer_callback with one argument, which is wrong.

It should probably be: prn=sniffer_callback . Because it is a callback function, sniffer_callback should be called from somewhere inside function sniff . Therefor you give the function itself as an argument, not a value that it has computed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM