简体   繁体   English

Python Scapy没有嗅探

[英]Python Scapy not sniffing

When I run the script, scapy does not listen on the interface, it just print out this error: 当我运行脚本时, scapy不会在界面上监听,它只会打印出此错误:

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) 追溯(最近一次通话):sniff_packets(scapy_expression,target_site)中的文件“ keylogger.py”,第91行,sniff_packets中的文件“ keylogger.py”,第15行,sniff(filter = scapy_expression,prn = sniffer_callback(target_site), store = 0,iface =“ eth0”)TypeError:sniffer_callback()恰好接受2个参数(给定1个)

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. 我不确定为什么scapy不听话。 Any help is appreciated. 任何帮助表示赞赏。

The problem is: prn=sniffer_callback(target_site) . 问题是: prn=sniffer_callback(target_site) You call sniffer_callback with one argument, which is wrong. 您使用一个参数调用sniffer_callback ,这是错误的。

It should probably be: prn=sniffer_callback . 它可能应该是: prn=sniffer_callback Because it is a callback function, sniffer_callback should be called from somewhere inside function sniff . 由于它是一个回调函数, sniffer_callback应从函数sniff内的某个位置调用sniffer_callback Therefor you give the function itself as an argument, not a value that it has computed. 因此,您将函数本身作为参数,而不是其已计算的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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