Pivot, Tunneling and Port Forwarding
SSH
Local port forwarding
Mysql port 3306 on victim localhost: netstat -tulpn
ssh -L 1234:localhost:3306 ubuntu@10.129.202.64The -L command tells the SSH client to request the SSH server to forward all the data we send via the port 1234 to localhost:3306 on the Ubuntu server.
$ nmap -v -sV -p1234 localhost
PORT STATE SERVICE VERSION
1234/tcp open mysql MySQL 8.0.28-0ubuntu0.20.04.3Web server listening on localhost
user@box:~$ netstat -tulpn
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:33060 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:33209 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:37285 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:3000 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:43765 0.0.0.0:* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 :::21 :::* LISTEN -
udp 0 0 127.0.0.53:53 0.0.0.0:* -
udp 0 0 0.0.0.0:68 0.0.0.0:* - 
Forwarding multiple ports
Dynamic Port Forwarding with SSH
- sT
Remote / reverse port forward
Attacker host
Create user
Configue SSH Server
Add
Restart SSH Server
or inside a Docker
2 - On victim - Connect to our host

Attacker host:
WinSSH
Metasploit
MSF's SOCKS Proxy
proxychains:
Autoroute
or
Listing autoroute
test
MSF local port forward
The above command requests the Meterpreter session to start a listener on our attack host's local port (-l) 3300 and forward all the packets to the remote (-r) Windows server 172.16.5.19 on 3389 port (-p) via our Meterpreter session.
Meterpreter Reverse Port Forwarding
We can now create a reverse shell payload that will send a connection back to our Ubuntu server on 172.16.5.129:1234 when executed on our Windows host. Once our Ubuntu server receives this connection, it will forward that to attack host's ip:8081 that we configured.
Resources
Proxychains
proxychains -q <cmd> : quiet mode
Nmap over proxychains: proxychains -q nmap -sT IP PORT
tun2socks
Chisel
Socks4
proxychains not working - try without proxychains
Socks5
or choose an other port
Socat
Socat Reverse shell
On pivot host
Socat will listen on localhost on port 8080 and forward all the traffic to port 80 on our attack host (10.10.14.18).
Socat Bind shell
socat bind shell listener, which listens on port 8080 and forwards packets to Windows server 8443.
On pivot machine:
Plink
If the host is older and PuTTY is present (or we can find a copy on a file share), Plink can be our path to victory. We can use it to create our pivot and potentially avoid detection a little longer.
Proxifier can be used to start a SOCKS tunnel via the SSH session we created.
Portable version :

SSHuttle
removes the need to configure proxychains. However, this tool only works for pivoting over SSH and does not provide other options for pivoting
Rpivot
run client from pivot machine:
HTTP proxy and NTLM auth
configure proxychains to pivot over our local server on 127.0.0.1:9050
Netsh

DNScat2
DNS Tunneling
Doesn't work on Exegol => Ubuntu
Will provide us the secret key

Import dnscat to windows victim

ICMP Tunneling
-r: attacker host
Port forward:
SocksOverRDP
Copy the SocksOverRDPx64.zip on the target
Load dll
Connect to 172.16.5.19 over RDP using mstsc.exe, and we should receive a prompt that the SocksOverRDP plugin is enabled, and it will listen on 127.0.0.1:1080

We will need to transfer SocksOverRDPx64.zip or just the SocksOverRDP-Server.exe to 172.16.5.19. We can then start SocksOverRDP-Server.exe with Admin privileges.

After starting our listener, we can transfer Proxifier portable to the Windows 10 target (on the 10.129.x.x network), and configure it to forward all our packets to 127.0.0.1:1080. Proxifier will route traffic through the given host and port

Profile > Proxyserver Add 127.0.0.1 port 1080 Socks version5
With Proxifier configured and running, we can start mstsc.exe, and it will use Proxifier to pivot all our traffic via 127.0.0.1:1080, which will tunnel it over RDP to 172.16.5.19, which will then route it to 172.16.6.155 using SocksOverRDP-server.exe.

Ligolo-ng - The best tool
References
Moving pivot from different hosts
Double Pivot (and more)
1st Pivot

2nd Pivot
Create a new interface

3rd Pivot - the same thing (create new interface, tunnel via the new interface), if the subnet is the same, don't forget to delete old routes
Reverse shell - File Transfer
Tunnel to localhost
Bore
Ngrock
Last updated
