How can I prepare TCP Pckets and send them

  • Hi all... Im trying to do such a exercise which in I need to prepare my own TCP packet and send it to target...
    I need some documentation how can I do that, and if there any existence classes in Qt libraries for this purpose.

  • Moderators

    I am not aware of a way to hand-craft TCP packets and send them in Qt. You will need platform APIs for that.

    You can of course get a QTcpSocket and send data through it. But that will create packages as it sees fit for you, splitting up your data as needed and sending out one or more packages with it to the other side. This approach does not allow to mess with the header data of course.

    What are you trying to do? You asked about man in the middle attacks before, now you want to meddle with TCP packets. Are you trying to hack people?

  • What I'm trying to do is perform an automated deep penetration testing, which indeed might look like hacking. What I need here is exactly how to invoke platform API's pertaining to the lower network layer. Does Qt provide an encapsulation or abstraction of these API's or am I wasting my time looking?

  • Moderators

    Any you want to write that yourself? There are several tools out there, doing that. Why don't you use and extend one of them? They have lots of code ready to use and APIs optimized for the penetration tests.

  • I mentioned before my friend, I'm doing some exercises for myself.

  • [quote author="CuteKQ" date="1361007200"]I mentioned before my friend, I'm doing some exercises for myself.[/quote] Then why don't you see it as an exercise to find out things like this yourself via studying the documentation carefully? This skill is much more important for aspiring crackers than fiddling with packet headers, you see.

  • The job is not simply done by "assembling a TCP Packet", you would need to implement a TCP Stack which is somehow compliant to the behavior of a real TCP/IP Stack, you will e.g. need to handle TCP Retransmissions, Acknowledgements (remember, TCP is a "reliable" protocol) etc. etc. etc.
    However, subclassing QAbstractSocket might help, in case you are really crazy enough to try this.

  • The idea of TCP is that it provides a "byte stream" abstraction to the application. Sure, on the Network layer the data has to be encapsulated into IP packets. But the TCP implementation does that automatically for you, e.g. by using Nagle's algorithm! It also takes care of re-sending lost packets, ensuring the right order of packets that arrive out-of-order (sequence numbers) and many other things. There's even a rather complex congestion control mechanism implemented in TCP. The application doesn't "see" any of that. The application will simply write bytes into the TCP connection or read bytes from it. That is no different if you use the TCP implementation of the operating system directly. It's because of how the "service interface" of TCP is defined!

    Consequently, if you want the control over individual network packets, you either have to use a "message oriented" transport protocol, such as UDP, instead of the "connection oriented" TCP or you have to work directly one the Network layer, i.e. work with "raw" IP packets and implement the Transport layer yourself.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.