# htb — lab lifecycle from the Mac The entry cheat for the whole rig: a **Kali Docker container** (`htb-kali`) you drive from macOS, because Docker Desktop can't hand a host VPN tunnel to a container — so the VPN, the tools, and the raw sockets all live *inside* the box. Set a target, bring the container up, connect the VPN, work. Next stops: `cheat recon`, `cheat web`, `cheat nxc`, `cheat ad`. ## Aim — who you're hitting `t` seeds `$TARGET`/`$RHOST`; nearly every scanner and enum wrapper defaults to it, so set it once. - **`t `** — set `$TARGET` **and** `$RHOST` · **`t`** — print the current target - **`myip`** — your attack IP into `$LHOST`: container **tun0** first (the VPN one you actually want), then host `utun0`/`tun0`, then LAN `en0`. Run it right after the VPN connects. ## Boot the lab `htb-up` is the everyday verb — create / start / re-attach in one command, then it drops you into a shell in the container. Prefers `docker compose`, falls back to raw `docker run`. - **`htb-up`** — bring up `htb-kali` and attach an interactive shell - **`htb-exec [cmd]`** — run `cmd` in the already-running container; **bare = a `/bin/bash` shell**. This is how you get a *second* prompt inside the box without leaving your current one. - **`htb-down`** — `docker stop` (state kept, restart is instant) · **`htb-rm`** — `docker rm -f` (destroys the container; `~/htb` + external drive are volumes, so your data survives) ## Connect the VPN (inside the container) Drop your HTB `.ovpn` into **`~/htb/vpn/`** (mounted at `/root/vpn`); a bare call grabs the first one it finds. - **`htb-up-vpn [file.ovpn]`** — fresh container that **auto-connects** the VPN on boot (sets `HTB_VPN`, recreates if needed) - **`htb-vpn [file.ovpn]`** — connect openvpn as a daemon in an *already-running* container, wait for `tun0`, export `$LHOST` - **`htb-vpn-status`** — is it up, and what's the `tun0` IP · **`htb-vpn-stop`** — `pkill openvpn` in the container - Still connecting? Read the log: **`htb-exec cat /tmp/openvpn.log`** ## Reach the lab from macOS (proxy) Burp / a Mac browser / `curl` can't route to HTB directly — the container can. `htb-proxy` opens a SOCKS5 hole through it. - **`htb-proxy`** — SOCKS5 via `ncat` on **`127.0.0.1:1080`** · **`htb-proxy stop`** — tear it down - Point Burp / Firefox at `SOCKS5 127.0.0.1:1080`, or `curl --socks5 127.0.0.1:1080 http://` ## GUI when you need a screen (Bloodhound, browsers) XFCE4 + VNC container (`kali-htb-gui`), separate from the headless one. Build once with `htb-build-gui`. - **`htb-up-gui`** — start it (VNC **:5901**, noVNC **:6080**), then auto-opens the browser client - **`htb-gui-connect`** — reprint the URLs / open `http://localhost:6080/vnc.html` - **`htb-exec-gui`** — `/bin/zsh` straight into the GUI box (skip VNC) · **`htb-down-gui`** — stop **and remove** it ## Organise the engagement Per-target scaffolding under `~/htb`, plus `/etc/hosts` and Pro-Lab scope helpers. ``` htb-box mk boxes//{scans,loot,exploits,notes,www} + cd box [name] cd to a box (bare: list boxes) htb-lab mk pro-labs//{scans,loot,pivoting,exploits,notes,hosts} + cd lab [name] cd to a lab (bare: list labs) ``` - **`hosts-box `** — add current `$TARGET` as `name.htb` + `name` to `/etc/hosts` (the one you want 90% of the time) - **`hosts-add `** — manual add (sudo) · **`hosts-show`** — active entries · **`hosts-rm `** — delete matching lines (sudo, backs up to `/etc/hosts.bak`) - **`scope add|rm|check|list|clear `** — track in-scope subnets in `~/htb/.scope` for Pro Labs; **`scope check `** tells you if a host is fair game *before* you scan it (stay in scope). - **`session-report [box]`** — roll `flags.txt` / `creds.txt` / `notes.md` / `scans/` into `boxes/_report_.md` ## tmux for a session - **`tmux-htb [name]`** — full HTB layout (shell / listeners / server / recon / docker windows) via `~/.tmux/htb-layout.sh` - **`tw `** — quick new named window in the current session ## Wordlists Pre-exported paths every wrapper reaches for — seed them once, then use the vars. - **`htb-wordlists`** — clone SecLists + extract rockyou into `$WORDLISTS` (run this on a fresh setup) | Var | Points at | |---|---| | `$COMMON` | Web-Content/common.txt — first dir-bust pass | | `$MEDIUM` / `$BIG` / `$SMALL` | directory-list-2.3-{medium,small} / big.txt | | `$DNS_SUB` | subdomains-top1million-5000.txt — vhost/subdomain fuzzing | | `$USERNAMES` / `$PASSWORDS` | names.txt / top-10000 passwords | | `$ROCKYOU` | rockyou.txt — the default crack list | | `$SECLISTS` / `$WORDLISTS` | the SecLists clone / your wordlist root | ## Build & nuke images - **`htb-build`** — build the `kali-htb` image from `~/htb/docker/` · **`htb-build-gui`** — build `kali-htb-gui` (needs the base image first) - **`htb-delete`** — stop + remove the container **and `rmi` the `kali-htb` image** (destructive — you'll `htb-build` again; `~/htb` and the external drive are untouched) > Daily loop: **`htb-up-vpn`** → **`myip`** → **`t `** → **`hosts-box `** → **`htb-box `** → enumerate (`cheat recon`). Leave it running; `htb-down` between sessions, `htb-rm`/`htb-delete` only when something's wedged.