1

I've tried to run this code:

import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)

print "hhhh"
from scapy.all import send
from scapy.layers.inet import IP, UDP

send(IP()/UDP())
print "BBBB"

and I got this output error:

hhhh
Traceback (most recent call last):
  File "C:/Users/Tamir/PycharmProjects/SIP/main.py", line 12, in <module>
    send(IP()/UDP())
  File "C:\Python27\lib\site-packages\scapy\sendrecv.py", line 251, in send
    __gen_send(conf.L3socket(*args, **kargs), x, inter=inter, loop=loop, count=count,verbose=verbose, realtime=realtime)
  File "C:\Python27\lib\site-packages\scapy\sendrecv.py", line 234, in __gen_send
    s.send(p)
  File "C:\Python27\lib\site-packages\scapy\arch\pcapdnet.py", line 252, in send
    ifs = dnet.ip()
  File "dnet.pyx", line 250, in dnet.ip.__init__ (./dnet.c:2317)
OSError: No such file or directory

But, other functions, such as sniff(), work fine.

Does anyone know how to fix this? I'm using windows 7 and python 2.7

tamird14
  • 481
  • 1
  • 6
  • 19

1 Answers1

0

Scapy requires dnet library. It is required for sending packets. Sniffing and dissecting might work well without it.

You can either remove importing dnet or install dnet library.

This is a similar question with a possible solution: Running Scapy on Windows with Python 2.7

Community
  • 1
  • 1
Eriks Dobelis
  • 913
  • 7
  • 16
  • It looks like it is not working though. Either you have a version of scapy, which requires dnet in a different form or it is in a different place than expected. Cannot comment without more details - how you installed scapy and dnet? This is generic instruction for installing scapy on Windows: http://www.secdev.org/projects/scapy/doc/installation.html#windows – Eriks Dobelis Jul 01 '15 at 10:32
  • I installed scapy using "python setup.py install" from the scapy folder (scapy-2.3.1), i've downloaded the file "dnet-1.12.win32-py2.7" and installed the dnet library. I also have all the other library needed – tamird14 Jul 01 '15 at 10:38
  • Create a python test script with just one line `import dnet` and run it. Does it succeed? – Eriks Dobelis Jul 01 '15 at 10:51
  • And if you add a line `r = dnet.ip()` ? – Eriks Dobelis Jul 01 '15 at 11:27
  • the same error: "File "dnet.pyx", line 250, in dnet.ip.__init__ (./dnet.c:2317) OSError: No such file or directory" – tamird14 Jul 01 '15 at 11:31
  • Which means it is not correctly installed or it is not a working dnet version. Use python 2.6 as recommended in scapy documentation provided above (with links to dnet), or find a working dnet library. E.g. see this post: http://stackoverflow.com/questions/7817926/compile-libdnet-for-python-2-7/23279252#23279252 – Eriks Dobelis Jul 01 '15 at 11:36