changing GET request in tcp packet
newfeeling opened this issue · comments
I'm trying to change simple GET request with pydivert (WinDivert for python)
What i seem to encounter is problem with packet lenght.
when i rewrite url so it has same amount or less of letters it works:
ie. GET /?a=asdf => GET /?a=z
But when i add more letters to the request, browser loops and ends up without showing anything
Below is example code i use
filter_ = "true and tcp.PayloadLength > 0"
with Handle(filter=filter_) as handle:
while True:
packet = handle.receive()
if packet.payload[0:3]=="GET":
packet.payload=packet.payload.replace("GET /?a=asdf","GET /?a=gfdsazzz")
handle.send(packet)
and
Is there somewhere a MAX packet size setted. If yes then how to increase it?
If that would be a hint for you then if i will print all packets in console then i clearly see that request was responded by server because see packet.payload with gfdsazzz
if any PayloadLength changed , the packet send will faild or no respond .
how can I fix it?
Since you're changing the payload, the whole packet length is changing too, so you should adjust the total packet length property of ip header accordingly. You should also recalculate checksums. Anyway, for this kind of changes I recommend you to redirect the traffic to your own proxy server (just a piece of software written by yourself listening on a socket) and then operate all the changes you want there, otherwise you would worry about sequence numbers, ack, and of course fragmentation due to MTU (which is the MAX packet size you were referring, and it's something that depends on the underlying network layer).