Make socket connection using SOCKS4/5, telnet HTTP or HTTPS tunnel.
Based on connect.c from Shun-ichi GOTO gotoh@taiyo.co.jp Added HTTPS proxy support Made code gcc-9 and valgrind clean
On Linux/UNIX environment:
$ gcc connect.c -o connect -lssl -lcrypto
usage:
/connect [-dnhstx45] [-p local-port][-R resolve] [-w timeout]
[-S [user@]socks-server[:port]]
[-H [user@]proxy-server[:port]]
[-T proxy-server[:port] [-c telnet-proxy-command]
[-X [user@]proxy-server[:port]]
[--help]
[--socks-server [user@]socks-server[:port]]
[--http-proxy [user@]proxy-server[:port]]
[--telnet-proxy proxy-server[:port]
[--https-proxy [user@]proxy-server[:port]]
[--https-proxy-ca PEM format file of CA's]
[--https-proxy-ca-path PEM format directory of CA's]
[--https-proxy-certname name]
[--https-user-cert certfile.pem]
[--https-user-key keyfile.pem]
[--no-check-certificate]
host port
"host" and "port" is for the target hostname and port-number to connect to.
You can omit the "port" argument when program name is special format containing port number itself. For example,
$ ln -s connect connect-25
means this connect-25 command is spcifying port number 25 already so you need not 2nd argument (and ignored if specified). * To use proxy, this example is for SOCKS5 connection to connect to 'host' at port 25 via SOCKS5 server on 'firewall' host.
$ connect -S firewall host 25
or
$ SOCKS5_SERVER=firewall; export SOCKS5_SERVER
$ connect -s host 25
$ connect -H proxy-server:8080 host 25
or
$ HTTP_PROXY=proxy-server:8080; export HTTP_PROXY
$ connect -h host 25
For a HTTPS-PROXY connection:
$ connect -H proxy-server:443 host 25 or
$ HTTPS_PROXY=proxy-server:443; export HTTPS_PROXY $ connect -x host 25
ProxyCommand connect -n %h %p
The following environment variables can be used to specify the above parameters: HTTPS proxy server: $HTTPS_PROXY proxy user: $HTTPS_PROXY_USER proxy password: $HTTPS_PROXY_PASSWORD server certificate name: $HTTPS_PROXY_CERTNAME CA certificate name: $HTTPS_PROXY_CA_FILE CA certificate path: $HTTPS_PROXY_CA_PATH client certificate file: $HTTPS_PROXY_USERCERT client privatekey file: $HTTPS_PROXY_USERKEY
The User name for authentication is specifed by an environment variable or system login name. And password is specified from environment variable or external program (specified in $SSH_ASKPASS) or tty. The following environment variable is used for specifying user name. - SOCKS: $SOCKS5_USER, $LOGNAME, $USER - HTTP Proxy: $HTTP_PROXY_USER, $LOGNAME, $USER - HTTPS Proxy: $HTTPS_PROXY_USER, $LOGNAME, $USER
You can use ssh-askpass (came from OpenSSH or else) to specify password on graphical environment (X-Window or MS Windows). To use this, set program name to environment variable SSH_ASKPASS. On UNIX, X-Window must be required, so $DISPLAY environment variable is also needed. On Win32 environment, $DISPLAY is not mentioned.