Search code examples
pythonpython-3.xscapypacket-sniffers

Scapy Sniff() - Device Is A NoneType


So I'm trying to get scapy to work on my windows computer. After a lot of work I finally was able to load the library without any errors. However when I call the function sniff(count=1) I get an error. It seems that a variable called "device" is getting the value None. Here is the error :

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python34\lib\site-packages\scapy\arch\windows\__init__.py", line 445, 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 223, 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'

Thanks In Advance For Any Help :)


Solution

  • After downloading the new development version and tinkering around with the timeouts of some of the powershell commands I fixed it! Guess it was just a bug with the old version. Scapy doesn't have the best Windows support.