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)
CDspace
  • 2,639
  • 18
  • 30
  • 36
Chetan
  • 141
  • 1
  • 1
  • 4
  • 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 `scapy` – Mike Pennington Jul 11 '11 at 01:30

1 Answers1

20

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)
Cukic0d
  • 5,111
  • 2
  • 19
  • 48
phoenix
  • 7,988
  • 6
  • 39
  • 45
  • 3
    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 ? – b0fh Apr 02 '13 at 14:06
  • 3
    @b0fh 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. – phoenix Jul 17 '16 at 01:29