Proxytunnel

Construit un tunnel TCP à travers des proxies HTTP(S) standards via la méthode CONNECT, utilisé pour faire pivoter du trafic SSH ou autre à travers un proxy d'entreprise restrictif. Builds a TCP tunnel through standard HTTP(S) proxies via the CONNECT method, used to pivot SSH or other traffic out through a restrictive corporate proxy.

↗ https://github.com/proxytunnel/proxytunnel

Overview

Proxytunnel connects to a standard HTTP or HTTPS proxy and issues a CONNECT request to tunnel an arbitrary TCP connection through it — most commonly used to get SSH (or other traffic) out of a network whose only permitted outbound path is via a corporate HTTP proxy. It’s a lightweight alternative to full SOCKS-based pivoting when the only egress available is an HTTP CONNECT-capable proxy.

Common Usage

Tunnel a raw TCP connection to a remote SSH server through an HTTP proxy

proxytunnel -p proxy.corp.local:8080 -d ssh-server.example.com:22 -a 2222

Then SSH through the local tunnel endpoint

ssh -p 2222 user@localhost

Tunnel through an HTTPS (TLS) proxy instead of plain HTTP

proxytunnel -p proxy.corp.local:443 -e -d ssh-server.example.com:22 -a 2222

Authenticate to the proxy with Basic auth credentials

proxytunnel -p proxy.corp.local:8080 -P user:pass -d ssh-server.example.com:22 -a 2222

SSH ProxyCommand Integration

# ~/.ssh/config
Host pivot
    HostName ssh-server.example.com
    Port 22
    ProxyCommand proxytunnel -p proxy.corp.local:8080 -d %h:%p

Then simply:

ssh pivot

Options

-p HOST:PORT      proxy server address and port
-d HOST:PORT       destination host:port to tunnel to
-a PORT             local port to bind the tunnel to (standalone mode)
-P USER:PASS         proxy Basic authentication credentials
-e                    use TLS/SSL when connecting to the proxy
-X                    use NTLM authentication against the proxy
-v                    verbose output
-q                    quiet mode

Tips

  • Proxytunnel is often the difference-maker on engagements where egress is locked down to an authenticated corporate proxy that only permits HTTPS-looking traffic (443) — SSH over the tunnel looks like ordinary HTTPS CONNECT traffic to network monitoring.
  • Combine with -e when the corporate proxy itself requires TLS on the client-facing side.
  • Works well as an SSH ProxyCommand, letting normal ssh/scp/sftp usage transparently ride through the tunnel.
Help / Man page
Usage: proxytunnel [options]

  -p, --proxy=host:port     proxy server to connect to
  -d, --dest=host:port       destination host to tunnel to
  -a, --standalone=port       run standalone, bind to local port
  -P, --proxy-auth=user:pass  proxy authentication credentials
  -X, --ntlm                    use NTLM proxy authentication
  -e, --encrypt-proxy           use SSL/TLS to the proxy
  -E, --encrypt-dest             use SSL/TLS to the destination
  -z, --quiet                    suppress non-error output
  -v, --verbose                  verbose output
  -h, --help                     display this help and exit

Vue d’ensemble

Proxytunnel se connecte à un proxy HTTP ou HTTPS standard et émet une requête CONNECT pour tunneliser une connexion TCP arbitraire à travers celui-ci : le plus souvent utilisé pour faire sortir du SSH (ou un autre trafic) d’un réseau dont le seul chemin sortant autorisé passe par un proxy HTTP d’entreprise. C’est une alternative légère au pivoting complet basé sur SOCKS lorsque la seule sortie disponible est un proxy compatible HTTP CONNECT.

Utilisation courante

# Tunneliser une connexion TCP brute vers un serveur SSH distant à travers un proxy HTTP
proxytunnel -p proxy.corp.local:8080 -d ssh-server.example.com:22 -a 2222

# Puis se connecter en SSH via le point d'entrée local du tunnel
ssh -p 2222 user@localhost

# Tunneliser via un proxy HTTPS (TLS) plutôt qu'en HTTP simple
proxytunnel -p proxy.corp.local:443 -e -d ssh-server.example.com:22 -a 2222

# S'authentifier auprès du proxy avec des identifiants Basic Auth
proxytunnel -p proxy.corp.local:8080 -P user:pass -d ssh-server.example.com:22 -a 2222

Intégration avec ProxyCommand SSH

# ~/.ssh/config
Host pivot
    HostName ssh-server.example.com
    Port 22
    ProxyCommand proxytunnel -p proxy.corp.local:8080 -d %h:%p

Ensuite, simplement :

ssh pivot

Options

-p HOST:PORT      proxy server address and port
-d HOST:PORT       destination host:port to tunnel to
-a PORT             local port to bind the tunnel to (standalone mode)
-P USER:PASS         proxy Basic authentication credentials
-e                    use TLS/SSL when connecting to the proxy
-X                    use NTLM authentication against the proxy
-v                    verbose output
-q                    quiet mode

Conseils

  • Proxytunnel fait souvent la différence sur les missions où la sortie réseau est verrouillée derrière un proxy d’entreprise authentifié qui n’autorise que du trafic ressemblant à du HTTPS (443) : le SSH via le tunnel ressemble, pour la surveillance réseau, à du trafic HTTPS CONNECT ordinaire.
  • Combinez avec -e lorsque le proxy d’entreprise lui-même exige du TLS côté client.
  • Fonctionne bien comme ProxyCommand SSH, permettant à ssh/scp/sftp de transiter de manière transparente à travers le tunnel.
Aide / Page de manuel
Usage: proxytunnel [options]

  -p, --proxy=host:port     proxy server to connect to
  -d, --dest=host:port       destination host to tunnel to
  -a, --standalone=port       run standalone, bind to local port
  -P, --proxy-auth=user:pass  proxy authentication credentials
  -X, --ntlm                    use NTLM proxy authentication
  -e, --encrypt-proxy           use SSL/TLS to the proxy
  -E, --encrypt-dest             use SSL/TLS to the destination
  -z, --quiet                    suppress non-error output
  -v, --verbose                  verbose output
  -h, --help                     display this help and exit