phaethon / kamene

Network packet and pcap file crafting/sniffing/manipulation/visualization security tool. Originally forked from scapy in 2015 and providing python3 compatibility since then.
GNU General Public License v2.0
868 stars 191 forks source link

AttributeError: 'NoneType' object has no attribute 'encode' when running on Windows 10 #86

Open wsw70 opened 8 years ago

wsw70 commented 8 years ago

System: Windows 10 Python: 3.4 scapy-python3: 0.18

When starting sniff I get the following traceback:

Traceback (most recent call last):
  File "C:/Users/yop/dev/sentinel/honeysyn/honeysyn.py", line 82, in <module>
    scapy.sniff(iface=h.config['interface'], prn=h.filtre)
  File "C:\Python34\lib\site-packages\scapy\arch\windows\__init__.py", line 444, in sniff
    s = L2socket(type=ETH_P_ALL, *arg, **karg)
  File "C:\Python34\lib\site-packages\scapy\arch\pcapdnet.py", line 266, in __init__
    self.ins = open_pcap(iface, 1600, self.promisc, 100)
  File "C:\Python34\lib\site-packages\scapy\arch\windows\__init__.py", line 222, in <lambda>
    pcapdnet.open_pcap = lambda iface,*args,**kargs: _orig_open_pcap(pcap_name(iface),*args,**kargs)
  File "C:\Python34\lib\site-packages\scapy\arch\pcapdnet.py", line 251, in <lambda>
    open_pcap = lambda *args,**kargs: _PcapWrapper_pypcap(*args,**kargs)
  File "C:\Python34\lib\site-packages\scapy\arch\pcapdnet.py", line 215, in __init__
    self.iface = create_string_buffer(device.encode('ascii'))
AttributeError: 'NoneType' object has no attribute 'encode'

The interface which is used via the iface parametr is {FEC67D86-A8E0-4362-8D9E-CD8EA834EB0C}. I retrieved it via Get-NetAdapter | select Name, InterfaceIndex, InterfaceDescription, InterfaceGuid, MacAddress | fl (or netifaces) and it is the Ethernet card.

The same code ran on Linux works fine (with the relevant interface, of course)

bortkiewicz commented 7 years ago

Yessss.

image

I was introduced to Scapy here, but running the program (I added the print functions) gave that error.

How is this inactive for over half an year now?

kclock commented 7 years ago

It is good to look at "get_windows_if_list ()" in "init.py".

talbaror commented 7 years ago

hi, have the same error under windows 10 tried to "get_windows_iflist ()" and used the desired interface below, but have same error Thanks `['\Device\NPF{7DF7BB36-6059-416A-BC52-6D3EF76C021D}', '\Device\NPF{14CCCC0A-5CF9-4B5A-AF5B-9A7388A04B56}', '\Device\NPF{C87D4372-8EE6-45F6-906A-895A6F52F8AB}', '\Device\NPF{1697B6E2-AF58-4255-922E-1E4F20BA9B78}', '\Device\NPF{07240D87-18FE-45B5-BB69-CB62E403C02E}', '\Device\NPF_{27102B72-028E-4B3F-B6BF-D9D84DF1CEF6}']`

ghost commented 7 years ago

iface has to be set on powershells InterfaceDescription value. I obtain iface-names using:

ifaces = scapy.NetworkInterfaceDict()
ifaces.load_from_powershell()

Note: i import scapy with import scapy.all as scapy

What might be helpfull would be some debug output. Actually the ValueError raised in scapy/arch/windows/init.py line 169 in def pcap_name of class NetworkInterfaceDict is a result of a KeyError when the devices name is not found as a key in the dict. This Error contains an Error-Message stating "Unknown network interface %r" % devname but this Error then is caught by line 206 in same init.py, pcap_name is set to None and this results in the 'NoneType' object has no attribut 'enode' Error. The Errormessage itself got lost in the process.

gpotter2 commented 6 years ago

Hi !

This issue has been resolved on the original scapy fork, which now supports Python 3 ! This fork (scapy3k) is missing many updates, bug fixes and tweaks. You can have a look at https://github.com/secdev/scapy to get more support !

Have a good day