Modify Packet that that change the packet size

Home Forums Discussions Support Portal Modify Packet that that change the packet size

This topic contains 2 replies, has 2 voices, and was last updated by  hoadx 11 years, 10 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #4975

    hoadx
    Participant

    I am new here and trying to modify a packet based on the its contents (WEB).

    Following Modify Packet and Modify packet [DELPHI] topics. It is Ok.

    But in the case the modification changes the size of the packet (replace “sex” term with “foo foo foo foo” term or “sex sex sex” with “foo”), I got an incorrect web page.

    Can you share an example (C/C++) for that case, suppose the new size (changed) always less than or equals MAX_ETHER_FRAME.

    Thank you.

    #5889

    Vadim Smirnov
    Moderator

    Can you share an example (C/C++) for that case, suppose the new size (changed) always less than or equals MAX_ETHER_FRAME.

    Sorry, at the moment we don’t have sample which modifies TCP data length in the packet. Implementing this kind of modification is a bit more complex that just changing few bytes in the packet without changing its length. I would recommend reading some good overview of TCP protocol before trying to implement this. In two words you have to track/alter sequence and acknowledgement fields in the packets. An example, you change “sex sex” in the incoming packet with «foo”, after this modification TCP data length of the packet is reduced for 4 bytes, so you should also modify sequence number in the TCP header by reducing it to 4. This SINGLE modification affects the whole TCP connection and you should also do the following:

    1) For all other incoming packets associated with this connection you should also reduce the sequence for these 4 bytes.
    2) For the outgoing packets associated with this connection you have to increment an acknowledgement number for those 4 bytes.

    If you do more modifications then you should recalculate sequence/acknowledgement numbers shift.

    #5890

    hoadx
    Participant

    Thanks a lot for your fast answers.
    It’s valueable instruction.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.