How to make Timestamp in TCP header

46 views
Skip to first unread message

alexsav...@gmail.com

unread,
Dec 7, 2013, 9:14:23 PM12/7/13
to libcr...@googlegroups.com
Hello

I would like to make timestamp in tcp header using libcrafter.
But I cannot find the related API function.

SetSrcPort, SetDstPort, SetSeqNumber, SetAckNumber, SetDataOffset, SetReserved, SetFlags, SetWindowsSize, SetCheckSum, SetUrgPointer

May I add the function like SetOptions. If so, how should I do?

Wireshark analyse them as options in tcp header.

Thanks.
Alex

Esteban Pellegrino

unread,
Dec 8, 2013, 12:56:48 AM12/8/13
to libcr...@googlegroups.com

Hello, TCP options in libcrafter are set like any other layer on the top of TCP. Be aware that you need to pad the bytes after the options.

Take a look at this example : https://github.com/pellegre/libcrafter-examples/blob/master/TCPOptions/main.cpp

--
You received this message because you are subscribed to the Google Groups "libcrafter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to libcrafter+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

alexsav...@gmail.com

unread,
Dec 8, 2013, 4:39:28 AM12/8/13
to libcr...@googlegroups.com
Hi Esteban,

Thanks

One question.

The following scenario is possible by using libcrafter?
I have a TCP Server-Client socket program. (It's sample.)
At first, client should log in to server. After success to log in, server send data to client.
At that time I'm going to block traffic from server to client(or change server not to reply) and build raw packet instead of server reply.
I guess many fields(ip, port, seq num, ack num, identification, etc) should be same to real packet that server made.
Client doesn't recognize this.
Is it possible? And then normal socket server works well? How can I consider any exceptions like TCP Retransmission?
Is there a such sample?

Regards,
Alex

Esteban Pellegrino

unread,
Dec 11, 2013, 6:45:38 AM12/11/13
to libcr...@googlegroups.com
Yes is possible, what you need is to code a TCP stack in "user-mode". Normal socket won't work because you can't manipulate TCP packets with sockets... What you want is TCP hijacking, I have a few example of it with libcrafter : https://github.com/pellegre/netjacker

You can also look at the TCPConnection.cpp / h class on libcrafter (inside the Utils folder), which can help you to achieve what you want.

What you need to do is to tell the kernel to stay away from a TCP connection (using iptables) and then you handle all the TCP packets from user mode :-)


--
Reply all
Reply to author
Forward
0 new messages