repositories

NixDaemon

NixOS pentest workstation as one flake — IceBreaker's successor

clonegit clone https://git.daemon-sec.xyz/NixDaemon.git
pentesting.zshShell34 lines1.7 KiBraw download
#!/usr/bin/env zsh
# ── pentesting.zsh : lazy loader for the curated toolkit ─────────────────────
# Keeps boot fast (~170ms): the 3300-line toolkit in pentest-tools.zsh loads on
# first use. Each toolkit command gets a thin wrapper that, on first call, loads
# the real toolkit (which overwrites every wrapper) then dispatches. Wrappers are
# real functions, so they work correctly under redirection/pipes — unlike a
# command_not_found_handler, which zsh runs in a forked subshell when the missing
# command is redirected (definitions there never persist).

_PENTEST_TOOLS="${ZDOTDIR:-$HOME/.dotfiles}/config/pentest-tools.zsh"
typeset -g _PENTEST_TOOLS_LOADED=
[[ -r "${ZDOTDIR:-$HOME/.dotfiles}/config/pentest-cmds.zsh" ]] && \
  source "${ZDOTDIR:-$HOME/.dotfiles}/config/pentest-cmds.zsh"

_load_pentest_tools() {
  [[ -n $_PENTEST_TOOLS_LOADED ]] && return 0
  [[ -r $_PENTEST_TOOLS ]] || return 1
  _PENTEST_TOOLS_LOADED=1     # set FIRST so a toolkit command running mid-source can't recurse
  unset PENTEST_LOADED        # our loader is authoritative; ignore the toolkit's self-guard
  source "$_PENTEST_TOOLS"
}

# Install a lazy wrapper for every toolkit command. First call to any of them
# loads the toolkit (replacing all wrappers with the real definitions) then runs.
() {
  local c
  for c in $_PENTEST_CMDS; do
    (( $+functions[$c] )) && continue        # never clobber an already-real fn (e.g. DB-owned)
    functions[$c]="_load_pentest_tools && $c \"\$@\""
  done
}

# explicit entry points (not toolkit functions themselves)
pentest() { _load_pentest_tools; (( $+functions[pentest-status] )) && pentest-status || pentest-help 2>/dev/null }