Skip to content

Kali Toolbox

sm0k3net edited this page Nov 28, 2026 · 3 revisions

Kali toolbox

The toolbox is a plugin-owned Docker container, dsh-redteam-kali, built from kalilinux/kali-rolling with hardened defaults. The agent installs packages and runs tools inside it; the host is never modified with apt. Without Docker the executor uses tools already on the host PATH and the panel marks the degraded mode. The drawer is described in the panel tour.

Tool manager drawer with runtime badge, curated catalog and Kali package search

Choosing a runtime

Every call resolves a runtime before it runs:

  1. docker version --format '{{.Server.Version}}' (5 s budget, cached 10 s) decides whether Docker is usable.
  2. docker inspect classifies the container: running, stopped, missing or unknown.
  3. A running container wins (runtime: docker); otherwise allowHostFallback runs the call on the host (runtime: host). Install, remove and setup never fall back.

pentest_exec records the runtime on every run, so Activity and the report can tell the two apart.

Container creation

ensure() is the only creation path. It pulls the image if docker image inspect fails (900 s budget), starts a stopped container, and creates a missing one with this argv:

docker run -d --name dsh-redteam-kali --hostname dsh-redteam-kali \
  --label dsh.redteam=1 --restart unless-stopped \
  --cap-drop ALL --cap-add NET_RAW --cap-add NET_ADMIN --cap-add CHOWN \
  --cap-add DAC_OVERRIDE --cap-add FOWNER --cap-add FSETID --cap-add SETGID \
  --cap-add SETUID --cap-add MKNOD \
  --security-opt no-new-privileges=true --init --pids-limit 2048 \
  kalilinux/kali-rolling sleep infinity
Flag Why
--label dsh.redteam=1, --restart unless-stopped Marks the container as ours (recreate refuses anything else) and survives a daemon restart.
--cap-drop ALL Removes every capability first.
Nine --cap-add values NET_RAW/NET_ADMIN keep SYN scans, masscan, Metasploit raw sockets and Responder working; the other seven are what apt/dpkg needs in a dropped-capability container.
--security-opt no-new-privileges=true, --init No privilege gain through setuid; PID 1 reaps orphans.
--pids-limit 2048 Stops a fork bomb from taking the host down.
--memory, --cpus, --tmpfs Added only when configured; see Configuration.

The container is never --privileged. It is never recreated implicitly: only the explicit recreate action (ensure({ recreate: true })) replaces a labeled container, and that discards installed tools, not engagement state, which never lives in the container.

Curated catalog

The catalog is a planning aid, not an allowlist: any Kali package can be installed. It has 47 entries. pentest_tool_inventory reports each entry's installed state against the running container, so a catalog miss is visible rather than silent.

Category Tools
Scanning nmap, masscan, nuclei, naabu
Recon amass, subfinder, httpx, dnsx, katana, gau, gospider, hakrawler
Web whatweb, zaproxy, nikto, wpscan, mitmproxy
Exploitation sqlmap, metasploit-framework, searchsploit
Fuzzing gobuster, ffuf, wfuzz, feroxbuster
Active Directory crackmapexec, impacket, responder, certipy, bloodhound-python, enum4linux-ng, evil-winrm, ldapsearch, smbclient, rpcclient
Passwords hydra, john, hashcat
Tunneling chisel, ligolo-ng
Utilities netcat-openbsd, socat, curl, wget, jq
API arjun, paramspider
Network bettercap

Catalog names are not always binary names; the executor maps them before spawning, so metasploit-framework runs msfconsole, searchsploit comes from the exploitdb package, httpx from httpx-toolkit, crackmapexec from netexec (nxc), impacket from python3-impacket (impacket-secretsdump), ligolo-ng from ligolo-proxy, gau from the getallurls package (binary getallurls), certipy from certipy-ad, bloodhound-python from bloodhound.py, ldapsearch from ldap-utils and rpcclient from smbclient. A 127 means the mapped binary is genuinely absent.

The inventory reports installed state, version, size and source (dpkg, path or catalog) per entry. Nuclei ships no templates in the apt package: run nuclei -update-templates once (or pentest_exec({ tool: "nuclei", args: ["-update-templates"] })); templates land in /root/.local/nuclei-templates (-tl lists them without scanning). pentest_tool_inventory with refresh:true re-queries the container.

Setup, install, search, remove

  • Set up (pentest_setup_toolbox, or the drawer button) is idempotent: pull when needed, create or start, run apt-get update with DEBIAN_FRONTEND=noninteractive, then sync bundled wordlists. Installing the first tool does the same automatically.
  • Search uses apt-cache search inside the container (60 s, at most 50 rows, 200-character query cap). It needs the container; in host mode it returns an empty result with a note.
  • Install and remove are serialized through one promise chain, because concurrent apt-get runs would fight over the dpkg lock. Each mutation runs apt-get install|remove -y (up to 30 minutes), then apt-get clean, deletes /var/lib/apt/lists and refreshes the inventory. Remove checks apt-cache rdepends --installed first and warns about dependent catalog tools.
  • Package names must match ^[a-z0-9][a-z0-9+.-]+$; a permission failure returns a hint naming the seven apt capabilities. Nothing here touches the host, and install/remove still require Docker.

Wordlist sync

wordlists.sync() writes every bundled, uploaded and AI list to containerWordlistDir (/opt/redteam/wordlists by default) with mkdir -p and tee over docker exec -i, one list per call with a 60 s budget. No host shell is involved. In host mode the sync is a no-op with a note, because the lists are already local. See Wordlists.

Degraded host mode

allowHostFallback defaults to true. In host mode:

  • tools already on PATH run normally and report runtime: host;
  • installation, removal and container setup are refused;
  • the Tool manager badge reads HOST, and the status banner explains the degradation;
  • 126/127 means the binary is missing from the DSH user's PATH; the plugin never installs host packages.

Set allowHostFallback: false to refuse host execution entirely; pentest_exec then fails with docker-unavailable instead of silently running elsewhere.

Output, timeouts and runaway processes

Each run captures stdout and stderr with a 200 KiB cap per stream, exit code, duration, truncation flag and PID. The budget is execTimeoutMs (15 min) or a smaller per-call timeoutMs, capped at one hour. Activity rows offer a kill control; the controller tracks child PIDs and sends SIGKILL, and disposal kills anything left.

Inspecting the container manually

docker inspect --format '{{.State.Running}} {{.HostConfig.PidsLimit}}' dsh-redteam-kali
docker inspect --format '{{json .HostConfig.CapAdd}} {{json .HostConfig.SecurityOpt}}' dsh-redteam-kali
docker exec -i dsh-redteam-kali dpkg-query -W -f='${Package} ${Version}\n' nmap
docker exec -i dsh-redteam-kali apt-get update

A container beyond repair can be removed and rebuilt: docker rm -f dsh-redteam-kali, then Set up Kali container. That discards installed tools; sessions, evidence and reports stay under $DSH_HOME/redteam/.

Troubleshooting pointers

  • Badge UNAVAILABLE or HOST: check docker info as the DSH user and the socket permissions.
  • Setup stalls: pre-pull kalilinux/kali-rolling; the pull budget is 900 s.
  • apt-get errors: no container egress, a full disk or a stale mirror; run apt-get update manually.
  • 126/127: install the package, or check which binary the catalog name maps to. A permission hint on install means the seven apt/dpkg capabilities are missing from capAdd.

See Troubleshooting for the full symptom-to-fix list.

Related

Clone this wiki locally