WinDivert: redirect to proxy listening on loopback interface only
Asked Answered
D

1

8

trying to implement transparent proxy same way as in this post, but I have a "proxy" listening only on loopback interface. Once I set DstAddr to loopback, 2nd packet of TCP handshake never received

...
iphdr->DstAddr = htonl(INADDR_LOOPBACK);
tcphdr->DstPort = ProxyPort;
addr->Direction = WINDIVERT_DIRECTION_INBOUND;
...

but it works if DstAddr = address_of_network_interface_packet_captured_from.

Also tried to alter addr:

    addr->IfIdx = 1;
    addr->SubIfIdx = 0;

without any effect.

Is there a way to implement such a configuration?

Dwaindwaine answered 1/3, 2017 at 9:47 Comment(0)
V
0

As with the original linked post, there does not appear to be any code here handling the reverse path (i.e. connection->proxy is handled, but proxy->connection is not). This would explain why the SYNACK is never received.

For diverting to a local proxy see the streamdump sample program.

Veach answered 25/3, 2017 at 13:2 Comment(4)
Thanks for the reply,Dwaindwaine
but the point is I need to restrict proxy to loopback interface only (127.0.0.1). My filter is (tcp.DstPort == 80 or tcp.DstPort == 443 or tcp.SrcPort == <proxy_port>) so I think it should handle 'proxy->connection' path?Dwaindwaine
if I modify streamdump so it runs proxy on INADDR_LOOPBACK and do appropriate changes in main loop, it stops working. Maybe any trick to inject/redirect to loopback interface?Dwaindwaine
For reference, this issue is discussed further here: github.com/basil00/Divert/issues/82Veach

© 2022 - 2024 — McMap. All rights reserved.