Tunneling and Port Forwarding

SSH

SSH graphical connection (X)

Local Port2Port

Open new Port in SSH Server --> Other port

Port2Port

Local port --> Compromised host (SSH) --> Third_box:Port

ssh -i ssh_key <user>@<ip_compromised> -L <attacker_port>:<ip_victim>:<remote_port> [-p <ssh_port>] [-N -f]  sudo ssh -L 631:<ip_victim>:631 -N -f -l <username> <ip_compromised>

Port2hostnet (proxychains)

Local Port --> Compromised host(SSH) --> Wherever

ssh -f -N -D <attacker_port> <username>@<ip_compromised> 

VPN-Tunnel

You need root in both devices (as you are going to create new interfaces) and the sshd config has to allow root login: PermitRootLogin yes PermitTunnel yes

ssh [email protected] -w any:any ip addr add 1.1.1.2/32 peer 1.1.1.1 dev tun0 ip addr add 1.1.1.1/32 peer 1.1.1.2 dev tun0 

Enable forwarding in Server side

Set new route on client side

SSHUTTLE

You can tunnel via ssh all the traffic to a subnetwork through a host. Example, forwarding all the traffic going to 10.10.10.0/24

Meterpreter

Port2Port

Local port --> Compromised host (active session) --> Third_box:Port

Port2hostnet (proxychains)

Another way:

reGeorg

​https://github.com/sensepost/reGeorgarrow-up-right​

You need to upload a web file tunnel: ashx|aspx|js|jsp|php|php|jsp

Chisel

You can download it from the releases page of https://github.com/jpillora/chiselarrow-up-right You need to use the same version for client and server

socks

Port forwarding

Rpivot

​https://github.com/klsecservices/rpivotarrow-up-right​

Reverse tunnel. The tunnel is started from the victim. A socks4 proxy is created on 127.0.0.1:1080

Pivot through NTLM proxy

Socat

​https://github.com/andrew-d/static-binariesarrow-up-right​

Bind shell

Reverse shell

Port2Port

Port2Port through socks

Meterpreter through SSL Socat

You can bypass a non-authenticated proxy executing this line instead of the last one in the victim's console:

​https://funoverip.net/2011/01/reverse-ssl-backdoor-with-socat-and-metasploit/arrow-up-right​

SSL Socat Tunnel

/bin/sh console

Create certificates in both sides: Client and Server

Remote Port2Port

Connect the local SSH port (22) to the 443 port of the attacker host

It's like a console PuTTY version ( the options are very similar to a ssh client).

As this binary will be executed in the victim and it is a ssh client, we need to open our ssh service and port so we can have a reverse connection. Then, to forward a only locally accessible port to a port in our machine:

NTLM proxy bypass

The previously mentioned tool: Rpivot OpenVPN can also bypass it, setting these options in the configuration file:

Cntlm

​http://cntlm.sourceforge.net/arrow-up-right​

It authenticates against a proxy and binds a port locally that is forwarded to the external service you specify. Then, you can use the tool of your choice through this port. Example that forward port 443

Now, if you set for example in the victim the SSH service to listen in port 443. You can connect to it through the attacker port 2222. You could also use a meterpreter that connects to localhost:443 and the attacker is listening in port 2222.

YARP

A reverse proxy create by Microsoft. You can find it here: https://github.com/microsoft/reverse-proxyarrow-up-right​

DNS Tunneling

Iodine

​https://code.kryo.se/iodine/arrow-up-right​

Root is needed in both systems to create tun adapters and tunnels data between them using DNS queries.

The tunnel will be really slow. You can create a compressed SSH connection through this tunnel by using:

DNSCat2

Establishes a C&C channel through DNS. It doesn't need root privileges.

Port forwarding with dnscat

Change proxychains DNS

Proxychains intercepts gethostbyname libc call and tunnels tcp DNS request through the socks proxy. By default the DNS server that proxychains use is 4.2.2.2 (hardcoded). To change it, edit the file: /usr/lib/proxychains3/proxyresolv and change the IP. If you are in a Windows environment you could set the IP of the domain controller.

Tunnels in Go

​https://github.com/hotnops/gtunnelarrow-up-right​

ICMP Tunneling

Hans

​https://github.com/friedrich/hansarrow-up-right https://github.com/albertzak/hanstunnelarrow-up-right​

Root is needed in both systems to create tun adapters and tunnels data between them using ICMP echo requests.

Last updated

Was this helpful?