6

I tried this piece of code for sending packet using scapy in python

data= "University of texas at San Antonio"
a=IP(dst="129.132.2.21")/TCP()/Raw(load=data)
sendp(a)

But I'm getting error in third line "sendp(a)" saying

Traceback (most recent call last):
   File "<pyshell#7>", line 1, in <module>
     sendp(a)
   File "C:\Python25\lib\site-packages\scapy\sendrecv.py", line 259, in sendp
     __gen_send(conf.L2socket(iface=iface, *args, **kargs), x, inter=inter, loop=loop, 
   count=count, verbose=verbose, realtime=realtime)
   File "C:\Python25\lib\site-packages\scapy\arch\pcapdnet.py", line 313, in __init__
     self.outs = dnet.eth(iface)
   File "dnet.pyx", line 112, in dnet.eth.__init__
   OSError: No such file or directory

Please let me know where am I wrong.

7
  • What error are you getting? Please include complete code & complete error traceback. Commented Dec 13, 2013 at 15:38
  • Edit your question and add the error/traceback please. Commented Dec 13, 2013 at 15:38
  • 2
    scapy is not correctly installed: it looks for dnet.pyx and can't find it. I think you'll need to install dnet. Commented Dec 13, 2013 at 15:41
  • This should answer your question about how to use dnet Can only use Scapy in interactive mode? Commented Dec 13, 2013 at 15:43
  • @Evert I have downloaded the dnet-1.12.win32-py2.5 and installed selecting "run as administrator". Still getting the same error. I am working on python 2.5.1 Commented Dec 13, 2013 at 15:55

1 Answer 1

6

You are using sendp() directly with IP packets, which is wrong.

Use either sendp(Ether()/IP()/...) or send(IP()/...).

By the way, you don't need to add Raw(load=...), as Scapy treats str as Raw.

So try this:

data = "University of texas at San Antonio"
a = IP(dst="129.132.2.21")/TCP()/data
send(a)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.