问题
After a new installation of Python2.7.14 and scapy(Version git-archive.dev254ab6d5a) i cant define my LAN-card as interface. As long iface=None the sniff function works fine. If i assign iface to a string, i get the following Error. For this Error i didn't found any posts on google:/.
Code:
#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))
Error describtion:
> 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'
回答1:
I had this same issue for hours. Here's what I did to solve it.
Be sure you have the latest version of scapy and the latest version of npcap. When you install npcap click the option to turn monitor mode on. I also found this on the scapy documentation site
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.
after I did that I listed the interfaces using
show_interfaces()
iface = raw_input("Enter the interface to sniff on: ")
copy and paste the interface into the input
回答2:
My problem is solved by downgrading the Wireshark version. But i guess the real problem is the compatibility between npcap(v0.98) and Python(v2.7.14). Unfortunately i dont understand the usage of the "ismonitor=True" parameter, but if it should be a compatibility problem, we will read soon more about it:)
来源:https://stackoverflow.com/questions/49065489/scapy-sniff-doesnt-accept-the-iface-strings