I have a specific closed-source (a traffic compression utility) program, that communicate with remote machine via TCP using tunnels. The only acceptable way for me to establish tunnel is to establish it through external http proxy-server.
Unfortunately, this program tries to use "CONNECT" with a port that proxy doesn't allow to use with "CONNECT". I'd like to intercept HTTP requests generated by that program and modify them. I'd like to use (if possible) only utilities included in original distribution (1DVD). I've already written program that (sometimes
) does what I need, but I'd like to know if there is more "sane" way to do this.
I've searched man pages, the only possible solution was iptables, but it (most likely, but I'm not sure) can't modify data, only redirect it to another address/port and this is not a solution since requests are sent through the proxy, not directly to the target IP.
Here are more details:
1) Program generates only one type of HTTP requests: "CONNECT xyz.xyz.net:8081 HTTP/1.1\r\n\r\n". It never sends any other type of requests. Only "CONNECT" requests and never anything else.
2) To make this request work with my proxy-server I need to replace it with "CONNECT xyz.xyz.net:443 HTTP/1.1\r\n\r\n".
3) Upon arrival of positive answer program will immediately establish tunnel on that port and will begin sending|receiving data. That means, that redirection utility must be able to handle tunnels...
4) It looks like squid isn't included in my distribution.
5) There is no way to replace the traffic compression utility with something else. (I just don't know about any similar utilities with same quality)
6) I can post a source code for my own utility that redirects traffic, if this is necessary to make clear what i need/what i'm talking about...
That's all. How can this be done without writing my own programs?
P.S. I apologize for any language errors in this message. English is not my native language.