Adding payload in packet
Asked Answered
K

1

12

Can I insert image or document (in MBs) as a data in packet using scapy?

This is what I did to send data.

data = "University of texas at San Antonio"
a = IP(dst="129.132.2.21")/TCP()/data
send(a)
Kal answered 7/7, 2011 at 2:13 Comment(1)
What are you really trying to do with this? Build your own file streamer in python? If so, there are much easier ways to do that than scapyPunctual
S
19

Yes, you can send raw data like this. In this example, data will be ASCII encoded.

>>> data = 'University of Texas at San Antonio'
>>> a = IP(dst='129.132.2.21') / TCP() / Raw(load=data)
>>> send(a)
Subtorrid answered 17/5, 2012 at 16:25 Comment(2)
That works, but does it do what is intended ? don't you need to send at least two packets for the TCP handshake to work ? wouldn't this payload be simply discarded by the recipient ?Biofeedback
@Biofeedback You are correct, sending a single TCP packet with data is not the same as establishing a TCP connection via the three-way hand shake and then transmitting data that would be accepted by a real TCP stack. This answer was simply about adding data after a TCP header.Subtorrid

© 2022 - 2024 — McMap. All rights reserved.