Send TCP SYN packet with payload

zzy

Is it possible to send a SYN packet with self-defined payload when initiating TCP connections? My gut feeling is that it is doable theoretically. I'm looking for a easy way to achieve this goal in Linux (with C or perhaps Go language) but because it is not a standard behavior, I didn't find helpful information yet. (This post is quite similar while it is not very helpful.)

Please help me, thanks!

EDIT: Sorry for the ambiguity. Not only the possibility for such task, I'm also looking for a way, or even sample codes to achieve it.

Gil Hamilton

Obviously if you write your own software on both sides, it is possible to make it work however you want. But if you are relying on standard software on either end (such as, for example, a standard linux or Windows kernel), then no, it isn't possible, because according to TCP, you cannot send data until the session is established, and the session isn't established until you get an acknowledgment to your SYN from the other peer.

So, for example, if you send a SYN packet that also includes additional payload to a linux kernel (caveat: this is speculation to some extent since I haven't actually tried it), it will simply ignore the payload and proceed to acknowledge (SYN/ACK) or reject (with RST) the SYN depending on whether there's a listener.

In any case, you could try this, but since you're going "off the reservation" so to speak, you would need to craft your own raw packets; you won't be able to convince your local OS to create them for you.

The python scapy package could construct it:

#!/usr/bin/env python2
from scapy.all import *
sport = 3377
dport = 2222
src = "192.168.40.2"
dst = "192.168.40.135"
ether = Ether(type=0x800, dst="00:0c:29:60:57:04", src="00:0c:29:78:b0:ff")
ip = IP(src=src, dst=dst)
SYN = TCP(sport=sport, dport=dport, flags='S', seq=1000)
xsyn = ether / ip / SYN / "Some Data"
packet = xsyn.build()
print(repr(packet))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

why my TCP server code send a SYN/ACK on only first packet or only on the first connection?

From Dev

Attempting to send TCP SYN packet with data and RST with data, but raw data field disappears in transit. Why?

From Dev

Send TCP packet in PHP

From Dev

Filter tcp packet payload length in tcpdump

From Dev

Client not responding TCP SYN-ACK packet ethernet driver

From Dev

Java / JSP Send TCP packet and wait for response

From Dev

Is there a way to send a TCP packet as another application?

From Dev

Java / JSP Send TCP packet and wait for response

From Dev

How to get packet.tcp.payload and packet.http.data as string?

From Dev

TCP starting without SYN?

From Dev

TCP starting without SYN?

From Dev

Disabling of TCP SYN retransmission

From Dev

How to send stdout in a tcp packet ? (only using bash commands)

From Dev

Send packet from server to a specific client using TCP c#

From Dev

TCP checksum is incorrect when trying to send packet in C

From Dev

Does TCP ensure packet is received by sequence that server send it

From Dev

Sending a raw tcp packet with syn flag set just goes through the lo interface, not eth0 as I want

From Dev

Get ICMP packet payload

From Dev

Capture the data and payload in a packet

From Dev

TCP-Syn is not being answered

From Dev

UDP payload length and packet transmission

From Dev

Decompressing a gzipped payload of a packet with Python

From Dev

Sending PublicKey within packet payload

From Dev

Is UDP packet payload size fixed?

From Dev

Extracting RTP payload from packet

From Dev

Jnetpcap Payload modify in UDP packet

From Dev

hping send SYN: how not to send RST after receiving SYN/ACK?

From Dev

Creating TCP packet with POX

From Dev

Parsing a TCP Packet data

Related Related

  1. 1

    why my TCP server code send a SYN/ACK on only first packet or only on the first connection?

  2. 2

    Attempting to send TCP SYN packet with data and RST with data, but raw data field disappears in transit. Why?

  3. 3

    Send TCP packet in PHP

  4. 4

    Filter tcp packet payload length in tcpdump

  5. 5

    Client not responding TCP SYN-ACK packet ethernet driver

  6. 6

    Java / JSP Send TCP packet and wait for response

  7. 7

    Is there a way to send a TCP packet as another application?

  8. 8

    Java / JSP Send TCP packet and wait for response

  9. 9

    How to get packet.tcp.payload and packet.http.data as string?

  10. 10

    TCP starting without SYN?

  11. 11

    TCP starting without SYN?

  12. 12

    Disabling of TCP SYN retransmission

  13. 13

    How to send stdout in a tcp packet ? (only using bash commands)

  14. 14

    Send packet from server to a specific client using TCP c#

  15. 15

    TCP checksum is incorrect when trying to send packet in C

  16. 16

    Does TCP ensure packet is received by sequence that server send it

  17. 17

    Sending a raw tcp packet with syn flag set just goes through the lo interface, not eth0 as I want

  18. 18

    Get ICMP packet payload

  19. 19

    Capture the data and payload in a packet

  20. 20

    TCP-Syn is not being answered

  21. 21

    UDP payload length and packet transmission

  22. 22

    Decompressing a gzipped payload of a packet with Python

  23. 23

    Sending PublicKey within packet payload

  24. 24

    Is UDP packet payload size fixed?

  25. 25

    Extracting RTP payload from packet

  26. 26

    Jnetpcap Payload modify in UDP packet

  27. 27

    hping send SYN: how not to send RST after receiving SYN/ACK?

  28. 28

    Creating TCP packet with POX

  29. 29

    Parsing a TCP Packet data

HotTag

Archive