Scapy sniff() 不接受 iface 字符串

Scapy sniff() doesn't accept the iface strings

新安装 Python2.7.14 和 scapy(版本 git-archive.dev254ab6d5a)后,我无法将我的 LAN 卡定义为接口。只要 iface=None 嗅探功能就可以正常工作。如果我将 iface 分配给一个字符串,我会收到以下错误。对于这个错误,我没有在 google:/.

上找到任何帖子

代码:

#Import all necessary scapy functionality from ethernet Api
from Lib.IHR_EthApi import *
from Lib.IHR_GeneralApi import GeneralApi as SYS
from scapy.all import *

FullTrafficList = []
#show_interfaces()
scapy.all.sniff(lfilter=None, iface="Realtek PCIe GBE Family Controller", store=True, prn = lambda x: FullTrafficList.append(x), count=10, timeout= None)
SYS.IHR_print(str(FullTrafficList))

错误描述:

> Traceback (most recent call last):   File
> "c:\Users\Evgenij\Desktop\Desktop\Eth_Test_Dev\Code\Test.py", line 8,
> in <module>
>     scapy.all.sniff(lfilter=None, iface="Realtek PCIe GBE Family Controller", store=True, prn = lambda x: FullTrafficList.append(x),
> count=10, timeout= None)   File
> "C:\Python27\Lib\site-packages\scapy\sendrecv.py", line 708, in sniff
>     *arg, **karg)] = iface   File "C:\Python27\Lib\site-packages\scapy\arch\pcapdnet.py", line 198, in
> __init__
>     self.ins = open_pcap(iface, 1600, self.promisc, 100, monitor=monitor)   File
> "C:\Python27\Lib\site-packages\scapy\arch\windows\__init__.py", line
> 856, in open_pcap
>     if iface.ismonitor(): AttributeError: 'str' object has no attribute 'ismonitor'

我的问题是通过降级Wireshark版本解决的。但我想真正的问题是 npcap(v0.98) 和 Python(v2.7.14) 之间的兼容性。 不幸的是,我不明白 "ismonitor=True" 参数的用法,但如果它应该是兼容性问题,我们将很快阅读更多相关信息:)

我几个小时都遇到同样的问题。这是我为解决它所做的。

确保你有最新版本的scapy和最新版本的npcap。安装 npcap 时,单击选项以打开监控模式。我还在 scapy 文档站点上找到了这个

Winpcap/Npcap conflicts

As Winpcap is becoming old, it’s recommended to use Npcap instead. Npcap is part of the Nmap project.

If you get the message ‘Winpcap is installed over Npcap.’ it means that you >have installed both winpcap and npcap versions, which isn’t recommended. You may uninstall winpcap from your Program Files, then you will need to remove:

C:/Windows/System32/wpcap.dll
C:/Windows/System32/Packet.dll

And if you are on a x64 machine:

    C:/Windows/SysWOW64/wpcap.dll
    C:/Windows/SysWOW64/Packet.dll

To use npcap instead. Those files are not removed by the Winpcap un-installer.

在我这样做之后,我使用

列出了接口
    show_interfaces()
    iface = raw_input("Enter the interface to sniff on: ")

将界面复制并粘贴到输入