dynamic-forward
03 — Dynamic forward -D
Learning objectives
- Stand up a loopback SOCKS
-Dlistener and send one approved tool through it. - Contrast when
-Lis still better; call out DNS local vs via proxy.
Intuition
-D is a general door through B — powerful, easier to over-reach than -L.
Class reminder
-D has no host:port target — only a local SOCKS port. Apps must speak SOCKS (or use a SOCKS-aware wrapper). FAQ: whiteboard FAQ.
Practitioner
Goal: SOCKS proxy on A; B becomes the exit for approved app traffic.
Shape: Listener on A; B dials whatever the SOCKS client asks for (still authorize destinations).
Pattern
ssh -N -o ExitOnForwardFailure=yes \
-D 127.0.0.1:1080 user@B
Then point one tool through SOCKS (browser proxy, or proxychains to a single allowed host:port). Do not treat "scan the subnet" as a tunnel test.
Teach the contrast with -L
-L | -D |
|---|---|
| One fixed destination baked into SSH | Destinations chosen by the client app |
Great when you know host:port | Great when the surface is still being mapped |
| Smaller blast radius | Easy to over-reach if the proxy is misused |
DNS callout (say once)
Ask: does the client resolve names locally or through the proxy? Wrong answer here causes "works in browser, fails in tool" confusion. Confirm in your tool's SOCKS/DNS settings before the next lab.
Hop chain (why dynamic matters)
- App on your laptop →
127.0.0.1:SOCKS_PORT - SOCKS listener on A — binds local loopback (
ssh -N -D 127.0.0.1:port …) - SSH to jumpbox
:22— encrypted control channel (no shell with-N) - Jumpbox dials whatever host:port each SOCKS request named
ssh -N -D 127.0.0.1:1080 user@JUMPBOX
Whole point: one local SOCKS door; no fixed target:port in the flag.
Checkpoint
lsof -nP -iTCP:1080 -sTCP:LISTENon A- One approved host:port via SOCKS succeeds
- Friends can say when they'd still pick
-Linstead
Evidence: artifacts/evidence/03-D-check.md.
Cite: [S-PC-01], [S-OSS-01], Academy pivoting module [S-HTB-ACAD-01].
Deep dive
SOCKS5 vs SOCKS4 and DNS: wrong setting looks like "tunnel broken" when it is name resolution [S-OSS-01 | medium | derived].
Check
One approved host:port via SOCKS; friends state when they'd still use -L.