0

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

<?php
  echo $_GET['a'];
?>

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

4

1 回答 1

2

直接的问题是您没有更新 TCP/IP 标头以反映新的数据包长度。

但是,还有其他更严重的问题:

  1. 如您所述,新数据包可能超过最大数据包大小(MTU)
  2. TCP Seq/Ack 编号需要更改,连接两端将不再同步。
  3. 编辑:另一个问题是 URL 可能会在多个数据包之间拆分,尤其是对于长 URL。

第二个和第三个问题不容易解决。

如果您希望使用 WinDivert 修改 TCP 流,更好的解决方案是使用 WinDivert 将流量重定向到本地代理服务器,并让代理服务器编辑流。有关使用此想法的示例程序,请参阅TorWall

于 2014-06-11T13:12:57.413 回答