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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With