scapy can't send packet

Viewed 833

I just installed scapy and when I try to send a packet:

./scapy
send(IP(dst="1.2.3.4"))

It gives this error:

 WARNING: No route found (no default route?)
Exception ignored in: <function SuperSocket.__del__ at 0x000002D5C55AC620>
Traceback (most recent call last):
  File "c:\users\saeed\appdata\local\programs\python\python37\lib\site-packages\scapy\supersocket.py", line 206, in __del__
    self.close()
  File "c:\users\saeed\appdata\local\programs\python\python37\lib\site-packages\scapy\arch\windows\native.py", line 193, in close
    self.ins.ioctl(socket.SIO_RCVALL, socket.RCVALL_OFF)
OSError: [WinError 10022] An invalid argument was supplied
c:\users\saeed\appdata\local\programs\python\python37\lib\code.py:140: ResourceWarning: unclosed <socket.socket fd=588, family=AddressFamily.AF_INET, type=SocketKind.SOCK_RAW, proto=0>
  sys.last_traceback = last_tb
ResourceWarning: Enable tracemalloc to get the object allocation traceback
c:\users\saeed\appdata\local\programs\python\python37\lib\code.py:140: ResourceWarning: unclosed <socket.socket fd=796, family=AddressFamily.AF_INET, type=SocketKind.SOCK_RAW, proto=255>
  sys.last_traceback = last_tb
ResourceWarning: Enable tracemalloc to get the object allocation traceback
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "c:\users\saeed\appdata\local\programs\python\python37\lib\site-packages\scapy\sendrecv.py", line 345, in send
    socket = socket or conf.L3socket(*args, **kargs)
  File "c:\users\saeed\appdata\local\programs\python\python37\lib\site-packages\scapy\arch\windows\native.py", line 119, in __init__
    host = iface.ip if iface.ip else socket.gethostname()
AttributeError: 'str' object has no attribute 'ip'
1 Answers

This error happens when Scapy does not detect any valid network interfaces.

Print the output of get_if_list() and it will probably be empty. Make sure that npcap is installed, reinstall npcap, or try winpcap instead.

See: https://github.com/secdev/scapy/issues/1239

Related