Module 02 // encrypted operations

pe command center.

pe is the target-first interface for lab state: select one box, then attach flags, credentials, hosts, ports and notes to it without scattering secrets across flat files.

SQLCipherGPG-wrapped keyXDG pathstarget-first
Start here: run pe doctor, initialize once with pe init, then use pe help whenever the command surface changes.

The active-target model

The active target is the current scope. New findings attach to it automatically unless a command accepts and receives an explicit --target. The Zsh prompt and tmux bar read only a small name | ip state cache, so they do not repeatedly unlock the database.

pe target add keeper --ip 10.10.11.227 --platform htb
pe status
pe target use keeper
pe target show keeper
Before adding a credential or flag, glance at pe status. Target-first convenience is powerful, but a stale active target can misfile evidence.

Bootstrap and health

CommandPurposeNotes
pe initCreate and key the encrypted database.Generates a key when neither PENTEST_DB_KEY nor a wrapped key file exists.
pe doctorAudit tools, ARM64 helpers, permissions, tunnel and safety defaults.“Not found” can be optional; read each section rather than treating every line as fatal.
pe statusShow active target, IP and flag count.Fast pre-command scope check.
pe versionPrint pentest-env command version.Useful when reporting a setup issue.
pe helpShow the authoritative top-level command list.Aliases -h and --help work too.

Targets

pe target add <name> [--ip 10.10.10.10] [--platform htb]
  [--hostname host.domain] [--os linux] [--difficulty medium]

pe target ls
pe target use <name-or-id>
pe target show [<name-or-id>]
pe target status
pe target edit <id> --ip 10.10.10.11 --status owned
pe target rm <name-or-id>

t is the noun alias; tl, tu and ts cover list, use and status. Removing a target cascade-deletes its attached flags, credentials, hosts, ports and notes after confirmation—back up first.

Flags

pe flag add [user|root|web|blood] <value> [--notes "where found"]
pe flag ls [--all]
pe flag show <id>
pe flag search <term>
pe flag rm <id>

The default type is user. Use --all only when you intentionally need cross-target output. Shell aliases: f and fl. Widget: Ctrl-X then f uses fzf to insert a selected flag at the cursor.

Credentials

pe cred add -u <user> -s <secret>
  [-t password|hash|ssh-key|token] [-S <service>]
  [--source <where-found>] [--host <host-id>] [--target <target>]

pe cred ls [--all]
pe cred show <id>
pe cred valid <id> 1|0
pe cred search <term>
pe cred rm <id>
Command-line exposure: a secret passed with -s may briefly appear in process inspection and would normally enter history. Begin the command with a literal space, and prefer pasting only when needed. Clear the clipboard afterward.

Aliases: c and cl. Widget: Ctrl-X then c selects a stored credential and inserts its secret into the current line; it does not execute it.

Hosts and ports

pe host add --ip <address> [--hostname <name>] [--os <os>]
  [--label <role>] [--target <target>]

pe host ls [--all]
pe host show <id>
pe host port <host-id> <port> [--proto tcp] [--service ssh] [--version <text>]
pe host rm <id>

Use hosts for additional interfaces, domain controllers or pivot-only systems belonging to the active lab target. Aliases: h and hl; the short h intentionally replaces common history aliases.

Notes

pe note add -t <title> [-b <body>] [--tags <tags>]
  [--target <target>] [--global]

pe note ls [--all] [--global]
pe note show <id>
pe note edit <id> [-t <title>] [-b <body>] [--tags <tags>]
pe note search <term>
pe note rm <id>

Without -b, pe note add opens $EDITOR (or reads piped input). Use global notes sparingly for reusable methodology; host-specific discoveries belong to their target. Aliases: n and nl.

VPN profiles and routes

pe vpn import ~/Downloads/lab.ovpn lab
pe vpn ls
pe vpn up lab
pe vpn status
pe vpn route "$IP"
  • Import copies a profile into ~/.config/htb/vpn/ with mode 600.
  • With one profile, pe vpn up selects it automatically. With several, pass a name or choose through fzf in a terminal.
  • The OpenVPN process remains in the foreground under sudo; Ctrl+C is the disconnect action.
  • pe vpn status lists lab-like interfaces. pe vpn route <ip> answers the stronger question: where will this target packet go?
  • Do not run a local HTB VPN and HTB Pwnbox against the same lab at the same time.

Sessions

pe session
pe session keeper
htb-session
box

All four enter the deterministic tmux workflow; a supplied target is activated first. The session name is htb-<safe-target-name>, and its panes start in $PE_WORKROOT/<target>. See the tmux cockpit for layout and keys.

Backup, restore and destructive actions

CommandBehaviorGuard
pe backupIntegrity-checks, timestamps, compresses and prunes old snapshots.Default retention is 20.
pe restoreSelects a backup, validates a private staged copy, and snapshots the current DB before the atomic swap.Rejects a wrong-key or corrupt candidate without touching the live DB.
pe resetDeletes all rows while preserving the schema.Snapshots first and requires typing RESET.
pe destroyDeletes the current database file.Backups remain; requires typing DESTROY.
A database backup without its wrapped key—or the passphrase needed to unwrap it—may be unrecoverable. Protect both, but store copies separately where practical.

Terminal cheatsheets

pe cheat
pe cheat env
pe cheat vpn
cheat nmap

With no query, pe cheat opens an fzf browser and preview. With a query, it searches the local Markdown sheets. This HTML manual is a separate, browser-friendly and printable layer; it uses no network resources.

Storage and key behavior

Database

~/.local/share/pentest-env/pentest.db is SQLCipher-encrypted. The data, state and backup directories are created mode 700.

Wrapped key

~/.local/state/pentest-env/db.key.gpg contains the encrypted key material. GPG agent may cache its passphrase for a session.

Automation override

PENTEST_DB_KEY bypasses the wrapped file. Environment variables can leak through process context and crash reports; use it only in a controlled environment.

Hot-path cache

The active display file contains target name and IP only. It lets the prompt and status bar remain responsive without database decryption.