0
votes

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.

1
Is this really more complicated than passing a second argument to sniffer_callback(target_site)? I'm weary of any answer that seems so simple, but it looks like changing prn=sniffer_callback(target_site) to prn=sniffer_callback would actually workJason Sperske
Let me try this another way, it looks like you are passing the result of the function sniffer_callback(target_site) (which isn't working because you have defined sniffer_callback() to take 2 arguments instead of one), but the correct way to use this is to pass the functionJason Sperske
yes but the sniffer_callback is automatically passed the packet as an arguement, so when its use prn=sniffer_callback(target_site) its getting passed target site and then the packetCBaker
plus the sniff function would work before it calls the sniffer function. It would error out once a packet was receivedCBaker
if sniffer_callback(target_site) returned a function then I would see how this could work, but as sniffer_callback() is defined it is going to return None (the default of any def where a return isn't present)Jason Sperske

1 Answers

1
votes

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.