Create a local SSH server (or proxy) for connection tunneling behind a proxy with authentication?

OS is Windows (any flavor, I can adapt). I’m having an issue where I need to connect to imap.google.com (and other services) and it only accepts port 995.

If I try to connect normally, it timeouts. If I manually connect through putty issuing CONNECT plus proxy credentials (username & password) the remote host disconnects me (which I think is a good thing, since I’m doing a simple HTTP/1.1 request).

Now, I need to know what kind of software I can use to create a -local- proxy, either using a specific software or SSH tunneling stuff, so my connections to localhost:600, for example, get redirected to imap.google.com:995 BUT authenticating against the proxy I’m behind.

Any ideas?

Answer

Socat can probably do this. Binaries for windows are available here.

You can then use socat TCP-L:600,reuseaddr,fork,PROXY:yourproxyaddress.example:imap.google.com:995,proxyauth=user:pass,proxyport=8080.