Autonomous OODA-loop pentesting agent. Hermes brain, Kali + Playwright tools over MCP, ATT&CK as the Orient language.
Python ai-agentsautonomous-agentskali-linuxllm-agentsoffensive-securityooda-looppentestingplaywrightsecurity
feat(install): easy install.sh + slim README with docs/ split
irraze5a6d25b1393
diff --git a/.env.example b/.env.exampleindex 23fe462..ddb9db8 100644--- a/.env.example+++ b/.env.example@@ -2,6 +2,10 @@# vulnerator-ai — environment variables template.# Copy this file to .env and fill in the values. Do NOT put real secrets here.# cp .env.example .env+#+# EASIEST PATH: run ./install.sh instead. It only asks for OPENROUTER_API_KEY,+# auto-generates HERMES_API_SERVER_KEY and VULNERATOR_MCP_INBOUND_TOKEN, writes+# this file for you, and brings the default stack up.# =============================================================================# --- LLM (OpenRouter) ---------------------------------------------------------diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5f01252..3e877c3 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,7 +7,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [1.4.0] - 2026-10-16+### Added+- **`install.sh` easy installer.** An interactive installer that reduces first-run setup to a single+ input: the `OPENROUTER_API_KEY`. It checks prerequisites (`docker`, `docker compose` v2,+ `openssl`), auto-generates the two secret tokens `HERMES_API_SERVER_KEY` and+ `VULNERATOR_MCP_INBOUND_TOKEN` as **separate** 32-byte hex values (`openssl rand -hex 32`), builds+ the `.env` from `.env.example` (filling in only those three keys and preserving every other default+ and the template comments), and brings the **default** stack up with `docker compose up -d --build`+ — **without** the Juice Shop lab. The OpenRouter key is read with no terminal echo, or taken from an+ exported `OPENROUTER_API_KEY` for non-interactive runs. Flags: `--with-juice-shop` (also start the+ OWASP Juice Shop practice lab), `--no-up` (write the `.env` only), `--force` (overwrite an existing+ `.env`; otherwise it refuses to clobber one). The manual `cp .env.example .env` path still works.+- **README "Let an AI assistant set it up for you" block.** A copy-paste prompt the user hands to an+ LLM coding assistant (Claude Code / Kiro / Cursor) with shell access, so the assistant runs+ `install.sh` and wires up the `vulnerator-mcp` stdio server end to end — the user only supplies the+ OpenRouter key when asked.+### Changed+- **README trimmed to a short Quick Start; detail moved into `docs/`.** The README now leads with the+ `./install.sh` Quick Start (plus a collapsed manual-setup fallback) and a documentation index,+ keeping only a condensed architecture summary and the authorized-use warning. The long-form content+ was split into new topic docs: `docs/configuration.md` (every `.env` variable, AWS credentials,+ local Ollama inference), `docs/usage.md` (driving a pentest via TUI / MCP client / raw HTTP, the+ Juice Shop lab, clean restarts between exercises), and `docs/security.md` (the no-guardrails model,+ the opt-in scope-guard, the MCP inbound token). No behavior changed; this is a documentation+ reorganization.- **`pentest-report` now emits the report in English.** `docker/kali/report_gen.py` previouslyrendered the Markdown deliverable in Spanish; its output strings (section headings, statuslabels, executive summary, methodology, evidence labels, and the `main` summary line) are nowdiff --git a/README.md b/README.mdindex 415af3e..9ca654a 100644--- a/README.md+++ b/README.md@@ -52,384 +52,119 @@ end to end.-- **kali** — deterministic runtime for pentest and collection tools (nmap, Prowler,- ScoutSuite, Cloudsplaining, ...). Exposes a `kali-mcp` server on `:8900` (and the artifacts- channel on `:8901`).-- **playwright-mcp** — real browser (headless Chromium, official Microsoft image) exposed- over MCP on `:8931`. Gives Hermes the web surface (navigation/DOM/interaction) without re-enabling- any native toolset. The `web-pentest` skill uses it.-- **ooda-agent** — Hermes (`nousresearch/hermes-agent`) as the OODA loop driver. It is a client- of both MCPs (`kali:8900`, `playwright-mcp:8931`) and runs the pentest tools directly.- It keeps its gateway alive with `hermes gateway run` (OpenAI-compatible API server on `:8642`,- **published to the host** by default so you can pilot it — see "Driving a pentest").--- **vulnerator-mcp** — a thin MCP **front door** over Hermes' `:8642` runs API so external MCP- clients (Claude Code / Kiro, BugTraceAI, ...) can trigger/observe/steer/stop a pentest as MCP- tools. It is **up by default** (4th container) because the intended UX is driving the engine- from an MCP client. In the default stack it runs **streamable-HTTP on the internal network**- (`http://vulnerator-mcp:8700`, **no host port**) and is **fail-closed** on- `VULNERATOR_MCP_INBOUND_TOKEN`. For **local** Claude Code / Kiro the recommended path is instead- the **stdio** mode (`docker run -i …`, zero network surface, no token). It wraps, does **not**- replace, the HTTP API: it exposes **only** the runs lifecycle (no raw `kali_run`, no- `/v1/chat/completions`) so the client stays a trigger/observer, never the brain. See "Driving a- pentest → From an MCP client" below.--There are no `api` or `ui` services: the agent talks directly to the MCPs (Kali and browser),-and the MCP front door only forwards the runs lifecycle.--### Tools included in the Kali image--The Kali image bakes in a **curated** set of pentest CLIs the skills assume exist and invoke via-`kali_run` (the base `kalilinux/kali-rolling` image is minimal and ships none of them). This is a-deliberate, small selection — **not** the full `kali-linux-headless` metapackage — to keep the-image reasonably sized:--| Baked-in tool | Used for |-| --- | --- |-| `nmap` | network/port/service enumeration |-| `whatweb` | web tech fingerprinting |-| `nuclei` | templated vulnerability scanning |-| `ffuf` | web fuzzing |-| `sqlmap` | SQL injection testing |-| `gobuster` | directory/DNS/vhost brute forcing |-| `impacket-scripts` | Impacket CLI helpers (AD/network) — invoked with the `impacket-` prefix, e.g. `impacket-secretsdump`, `impacket-GetUserSPNs` |-| `bloodhound.py` | BloodHound Python ingestor (AD) — command `bloodhound-python` |--Plus the cloud-collection tooling in the Python venv (Prowler, ScoutSuite, Cloudsplaining, Pacu).-Anything else a specific engagement needs can still be `apt install`-ed on the fly inside the-`kali` container; note it lives in the container's ephemeral layer and disappears on the next-`down`/`up` (bake it into the `Dockerfile` to make it permanent — see "Start clean between-exercises").--## How to bring it up--**All keys and credentials go in a `.env` file** at the repo root. It is not-versioned (it is in `.gitignore`) and is the only place where you put secrets. Start by copying-the template, which documents every variable:--```sh-cp .env.example .env-```+- **kali** — deterministic runtime for pentest and collection tools (nmap, whatweb, nuclei, ffuf,+ sqlmap, Prowler, ...) over a `kali-mcp` server (`:8900`).+- **playwright-mcp** — real browser (headless Chromium) over MCP (`:8931`), the web surface used by+ the `web-pentest` skill.+- **ooda-agent** — Hermes (`nousresearch/hermes-agent`) as the OODA loop driver and client of both+ MCPs. Keeps its OpenAI-compatible API server alive on `:8642`.+- **vulnerator-mcp** — thin MCP **front door** over Hermes' `:8642` runs API so MCP clients+ (Claude Code / Kiro, BugTraceAI, ...) can trigger/observe/steer/stop a run. **Up by default**;+ it exposes **only** the runs lifecycle, never raw `kali_run` or `/v1/chat/completions`.-Open the `.env` and fill in the values. At a minimum you need the three required ones:+No `api` or `ui` service: the agent talks directly to the MCPs. See+**[`docs/design.md`](docs/design.md)** for the full architecture and the curated Kali toolset.-| Variable | Required | Where to put it / how to get it |-| --- | --- | --- |-| `OPENROUTER_API_KEY` | **Yes** | Your OpenRouter API key (the provider of the LLM that reasons the OODA). Create it at <https://openrouter.ai/keys> and paste it into the `.env`. |-| `HERMES_API_SERVER_KEY` | **Yes** | Key for Hermes' API server (min. 8 chars). Generate one with `openssl rand -hex 32` and paste it into the `.env`. It is also the Bearer to pilot Hermes over HTTP. |-| `VULNERATOR_MCP_INBOUND_TOKEN` | **Yes** | Inbound Bearer for the `vulnerator-mcp` front door, which is **up by default** in streamable-HTTP mode. Generate one with `openssl rand -hex 32` and paste it into the `.env`. The default stack is **fail-closed** on this: `docker compose up` aborts without it. It is a **separate** secret from `HERMES_API_SERVER_KEY` and gates a different edge. (The local **stdio** mode for Claude Code / Kiro does not need it.) |+## Quick Start-The **AWS credentials are OPTIONAL**: they are only needed if you are going to use the cloud-collection tools (Prowler / ScoutSuite / Cloudsplaining). If you are not auditing AWS, leave these-variables empty in the `.env`:--| Variable | Required | Where to put it / how to get it |-| --- | --- | --- |-| `AWS_ACCESS_KEY_ID` | No | **Read-only** credential for the account you are AUTHORIZED to audit. In the `.env`. |-| `AWS_SECRET_ACCESS_KEY` | No | Secret for that same credential. In the `.env`. |-| `AWS_SESSION_TOKEN` | No | Only for temporary credentials (STS). In the `.env`. |-| `AWS_REGION` | No | Default region (e.g. `us-east-1`). In the `.env`. |-| `OPENROUTER_MODEL` | No | Overrides the OpenRouter model Hermes reasons with. Empty = the profile default (`mistralai/mistral-large-4-0`). **Caveat:** the project uses Mistral Large on purpose because models like Claude (`anthropic/*`) refuse the authorized-offensive pentest framing (OpenRouter/Anthropic returns "violative cyber content"); overriding with such a model may make the agent refuse to work. |-| `VULNERATOR_MCP_HOST_PORT` | No | HOST port to publish the `vulnerator-mcp` streamable-HTTP server. By default it publishes **no** host port (internal docker network only). Set this **and** uncomment the service's `ports:` block in `docker-compose.yml` to publish on a controlled machine. |--The rest of the `.env.example` variables (host ports, artifacts token, Prowler-scoping) are optional and come with defaults; leave them empty unless you need to-change them. Once your `.env` is ready:+The installer is the fast path: the **only** thing you provide is your OpenRouter API key. It+checks prerequisites (`docker`, `docker compose` v2, `openssl`), auto-generates the two secret+tokens, writes the `.env` from the template, and brings the default stack up.```sh-docker compose up -d --build+./install.sh```-### Local inference with Ollama (optional)--By default Hermes reasons with Mistral Large on OpenRouter. If you prefer to run the model-yourself, you can point Hermes at an [Ollama](https://ollama.com) endpoint (OpenAI-compatible)-instead. This is **opt-in** and fully controlled from the `.env`:--| Variable | Required | Where to put it / how to get it |-| --- | --- | --- |-| `OLLAMA_BASE_URL` | No | Empty = use OpenRouter (default). Set it to an Ollama OpenAI-compatible endpoint to use Ollama instead: `http://host.docker.internal:11434/v1` for a local host Ollama, or `http://<host>:11434/v1` for a remote one. When set, `OPENROUTER_API_KEY` is **not** required. |-| `OLLAMA_MODEL` | No | The Ollama model name used in Ollama mode, e.g. `qwen2.5-coder:32b`. |--At startup the stack branches on `OLLAMA_BASE_URL`: when it is empty the OpenRouter path is used-exactly as before (and a missing `OPENROUTER_API_KEY` still aborts startup); when it is set, the-startup script runs `hermes config set model.provider custom`, `model.base_url <OLLAMA_BASE_URL>`-and `model.default <OLLAMA_MODEL>`, so Hermes talks to Ollama.--Caveats before you rely on it:--- **Context window (hard blocker):** Hermes refuses to start against an endpoint serving less than- ~64K tokens of context, and Ollama defaults to as low as 4K. Raise it **server-side** where Ollama- runs with `OLLAMA_CONTEXT_LENGTH=64000` (it cannot be raised through the API).-- **Networking:** make Ollama listen on all interfaces (`OLLAMA_HOST=0.0.0.0`) so the container can- reach it. On Linux, reaching a host-run Ollama relies on the- `extra_hosts: ["host.docker.internal:host-gateway"]` mapping already set on `ooda-agent` (Docker- Desktop on macOS/Windows resolves `host.docker.internal` automatically).-- **Model suitability (experimental):** every pentest action routes through MCP, so the model must do- reliable tool/function-calling and must not refuse the authorized-offensive pentest framing. Parity- with Mistral-Large-on-OpenRouter is **not guaranteed** — treat local inference as experimental and- validate your chosen model before relying on it.--## Driving a pentest--Three ways to pilot an engagement, from simplest to most programmatic. All of them drive the same-OODA loop; pick by how you work.--### 1. Interactive TUI (`hermes chat`)+Then open the interactive TUI:```sh-docker compose up -d --builddocker compose exec -it ooda-agent hermes chat```-`hermes chat` opens the agent's REPL. Ask for a pentest in natural language; Hermes drives the OODA-and runs tools on Kali directly via `kali_run` (talking to `kali:8900`). The container's command-`hermes gateway run` also keeps Hermes' API server alive on `:8642`, which powers ways 2 and 3.--### 2. From an MCP client — recommended for assistants--If your tooling speaks **MCP** (Claude Code, Kiro, Cursor, BugTraceAI, …), the stack ships-**`vulnerator-mcp`** (`docker/mcp/`): a thin MCP server that wraps Hermes' runs API and exposes it-as MCP tools. It wraps, it does **not** replace, the HTTP API — it exposes **only** the runs-lifecycle, so the client stays a trigger/observer and never the brain. It never exposes-`/v1/chat/completions` or any raw `kali_run`.--**Five tools + a health check**, mapped 1:1 onto the runs API:--| Tool | Does |-| --- | --- |-| `start_pentest(input, scope, …)` | starts a run; returns `{run_id, status, replayed}` |-| `get_run_status(run_id)` | the full run object (status + `completed`/`partial`/`interrupted` + output + usage) |-| `stream_run_events(run_id, cursor, …)` | pages the lifecycle events with a `seq` cursor (`{events, next_cursor, done}`); also emits one MCP progress notification per page over streamable-HTTP |-| `steer_run(run_id, input)` | injects a correction mid-run; surfaces the `409 run_not_accepting_steer` verbatim |-| `stop_run(run_id)` | stops the run; returns the full run object |-| `health()` | upstream health (`{status, platform, version}`) |--Event/status/output payloads are forwarded verbatim as **untrusted data** (never interpreted).--**Local — stdio (recommended for Claude Code / Kiro).** Zero network surface: the client spawns the-server as a subprocess over stdin/stdout — no listener, no token, no port. Build the image once and-add an `mcpServers` entry:--```sh-docker build -f docker/mcp/Dockerfile -t vulnerator-ai-mcp:dev .-```--```json-{- "mcpServers": {- "vulnerator-mcp": {- "command": "docker",- "args": [- "run", "-i", "--rm",- "--add-host", "host.docker.internal:host-gateway",- "-e", "HERMES_API_SERVER_KEY",- "-e", "HERMES_API_BASE_URL=http://host.docker.internal:8642",- "vulnerator-ai-mcp:dev"- ],- "env": { "HERMES_API_SERVER_KEY": "<your HERMES_API_SERVER_KEY>" }- }- }-}-```--The upstream Bearer is a pass-through of `HERMES_API_SERVER_KEY` (no second secret for the hop). On-Docker Desktop `host.docker.internal` resolves out of the box; on stock Linux the `--add-host`-above is what makes it resolve (or point `HERMES_API_BASE_URL` at the host's reachable address).--**In-docker / remote — streamable-HTTP (up by default).** The streamable-HTTP service is part of the-default stack, reachable on the internal network at `http://vulnerator-mcp:8700` (an in-docker-consumer like a BugTraceAI container reaches it there with no extra steps). It is **fail-closed** on-`VULNERATOR_MCP_INBOUND_TOKEN` (`docker compose up` aborts without it) and every request must carry-`Authorization: Bearer <VULNERATOR_MCP_INBOUND_TOKEN>` (the `/healthz` route is the one exception).-Host publication is **off by default** — set `VULNERATOR_MCP_HOST_PORT` and uncomment the service's-`ports:` block in `docker-compose.yml` to publish on a controlled machine. See **Security & scope**-below for the threat model.--### 3. Raw HTTP API (`:8642`)--For CI scripts or plain `curl`, Hermes exposes an OpenAI-compatible API server directly on `:8642`-(the same endpoints `vulnerator-mcp` wraps). Full reference — access modes, the runs flow,-`chat/completions`, and the request/response contract — in **[`docs/http-api.md`](docs/http-api.md)**.--### Quickstart against a lab target (Juice Shop)--To practice the `web-pentest` skill without going out to the internet or touching real systems,-the repo ships an **optional** target override, `docker-compose.target.yml`, that adds an-[OWASP Juice Shop](https://owasp.org/www-project-juice-shop/) service. Juice Shop is a-**deliberately-vulnerable** web application (OWASP project), the de facto standard for practicing-web pentesting (XSS, SQLi, broken auth, etc.).--Bring the whole stack up **with** the target by layering both compose files:--```sh-docker compose -f docker-compose.yml -f docker-compose.target.yml up -d --build+Useful flags: `--with-juice-shop` (also start the OWASP Juice Shop practice lab), `--no-up`+(just write the `.env`), `--force` (overwrite an existing `.env`).++### Let an AI assistant set it up for you++Don't want to read any of this? Paste the block below to an LLM coding assistant (Claude Code,+Kiro, Cursor, …) that has shell access in this repo. It tells the assistant everything it needs to+install the stack and wire up the MCP server — you provide only your OpenRouter key when asked.++```text+You are setting up the "vulnerator-ai" repo for me. Do the following, in order:++1. From the repo root, run the installer: ./install.sh+ It is interactive and will ask for ONE value, OPENROUTER_API_KEY — ask me for it+ and pass it through (or run it non-interactively as+ `OPENROUTER_API_KEY=<the key> ./install.sh`). The installer auto-generates the two+ secret tokens (HERMES_API_SERVER_KEY, VULNERATOR_MCP_INBOUND_TOKEN), writes the .env,+ and brings the default 4-container stack up (no Juice Shop lab). Do NOT invent or ask+ me for the two tokens — the installer makes them.++2. Wait until the stack is healthy, then verify with: docker compose ps++3. Register the local MCP server (stdio mode — zero network surface, no inbound token).+ First build the image once:+ docker build -f docker/mcp/Dockerfile -t vulnerator-ai-mcp:dev .+ Then add this entry to my assistant's MCP config (mcpServers), filling HERMES_API_SERVER_KEY+ with the value the installer wrote into the repo's .env (read it from there, do not print it):+ {+ "mcpServers": {+ "vulnerator-mcp": {+ "command": "docker",+ "args": [+ "run", "-i", "--rm",+ "--add-host", "host.docker.internal:host-gateway",+ "-e", "HERMES_API_SERVER_KEY",+ "-e", "HERMES_API_BASE_URL=http://host.docker.internal:8642",+ "vulnerator-ai-mcp:dev"+ ],+ "env": { "HERMES_API_SERVER_KEY": "<value from .env>" }+ }+ }+ }++4. Confirm the MCP tools are available (health(), start_pentest, get_run_status,+ stream_run_events, steer_run, stop_run). Then tell me it's ready and remind me this engine+ has NO scope-guard/consent/audit by default: it must be used only against authorized targets.```-The target joins the **same internal docker network** and publishes **no port to the host**, so it-only exists inside the docker environment — scoping the exercise to a controlled lab. Hermes/Kali-reach it by its DNS name at **`http://juice-shop:3000`**. Point an engagement at that URL, e.g. via-the interactive TUI:+<details>+<summary>Manual setup (without the installer)</summary>```sh-docker compose -f docker-compose.yml -f docker-compose.target.yml exec -it ooda-agent hermes chat-# then ask, in natural language:-# "Authorized web pentest against http://juice-shop:3000 (scope: that host only).-# Enumerate, fingerprint, and test for injection/auth flaws. Report confirmed findings."-```--This is the authorized target for practicing the `web-pentest` skill. Only the web lab is in scope-here (no AD or other labs for now).--## Start clean between exercises--So that each pentest starts without remembering anything from the previous one (conversation history-and Hermes' memory), bring the stack up from scratch. The cleanest and most deterministic way:--```sh-docker compose down -v # stops the containers and DELETES Hermes' state volume-docker compose up -d # starts with fresh state (the profile regenerates from agent-ooda/)-```--In a single line:--```sh-docker compose down -v && docker compose up -d-```--### What is deleted and what is kept--The `-v` flag deletes the named volume `hermes-data` (`/opt/data`), where Hermes' state-lives: the profile and its SQLite (`state.db`). That is where the history/memory you want to-forget between exercises resides. You don't lose configuration: the profile (`config.yaml`, `SOUL.md`,-`skills`) **regenerates** on each startup by copying the declarative template from `agent-ooda/`.--| What | Does it survive `down -v` + `up`? |-|---|---|-| Tools baked into the image by the Kali `Dockerfile` | **Yes** |-| Packages Hermes installed on the fly during a pentest | **No** (ephemeral layer of the `kali` container) |-| Hermes' state / memory / history (`hermes-data`) | **No** (exactly what `-v` deletes) |--Notes:--- The `kali` container **has no volume**: anything installed on the fly (e.g. an- `apt install` Hermes does mid-engagement) lives in the container's ephemeral layer and- disappears on the next `down`/`up`. If you want a tool to always be- available without reinstalling it every session, **add it to the Kali `Dockerfile`** so- it is baked into the image.-- To lose only the Kali packages you don't need `-v`: a plain `docker compose down`- already recreates the `kali` container from the image. The `-v` adds the deletion of Hermes'- state.-- `docker compose restart` does **not** recreate the containers, so it keeps both Hermes'- state and whatever was installed on the fly in the Kali: it is not useful for starting clean.--### Alternative: new session without deleting the volume--If you prefer to keep the history but work in a clean conversation, open a-session with a new name instead of reusing the default one:--```sh-docker compose exec -it ooda-agent hermes chat --continue <new-session-name>+cp .env.example .env+# edit .env: set OPENROUTER_API_KEY, and generate the two tokens with `openssl rand -hex 32`:+# HERMES_API_SERVER_KEY, VULNERATOR_MCP_INBOUND_TOKEN+docker compose up -d --build```-This does not delete the previous memory; it just avoids dragging it into the new conversation.+Every variable is documented in **[`docs/configuration.md`](docs/configuration.md)**.+</details>-## How it works+## Documentation-The "OODA loop" is **prompt-induced behavior**, not a scheduler: it is defined across the declarative-profile (`agent-ooda/` — `SOUL.md`, the `pentest-ooda` skill, and domain skills for network, cloud and-web). Hermes orients with **MITRE ATT&CK** as the loop's language (tagging each finding with its-`technique_id`), advances while there is real progress, and hands off when the path is exhausted or-the goal is confirmed unreachable. Evidence is persisted to a **per-engagement findings store** on the-artifacts plane (`:8901`) via the `record_finding` / `read_findings` MCP tools, and the-**`pentest-report`** skill turns that store into the formal Markdown deliverable at close.+The README is intentionally short. The detail lives under [`docs/`](docs/):-Full design detail — the skill breakdown, the comparison with public OODA patterns-(`neurofoo/agent-skills`, `jomadu/rooda`), the findings-store schema, and the browser/web flank — is-in **[`docs/design.md`](docs/design.md)**.--### Sample report--A real `pentest-report` artifact from an authorized, operator-owned fingerprint engagement is-included as a sample: [`docs/example-report.md`](docs/example-report.md), with its matching findings-store [`docs/example-findings.jsonl`](docs/example-findings.jsonl). Both are **redacted** (target IP-replaced with the RFC 5737 documentation address `192.0.2.1`; device serial and hostname removed).-They show the end-to-end output: an OODA recon loop driven over MCP, each finding recorded with its-ATT&CK `technique_id` and verbatim command/output evidence, closed by the generated Markdown report.+| Topic | Doc |+| --- | --- |+| Every `.env` variable, AWS creds, local Ollama inference | [`docs/configuration.md`](docs/configuration.md) |+| Driving a pentest (TUI, MCP client, raw HTTP), the Juice Shop lab, clean restarts | [`docs/usage.md`](docs/usage.md) |+| The no-guardrails model, opt-in scope-guard, MCP inbound token | [`docs/security.md`](docs/security.md) |+| Raw HTTP API reference (`:8642`) | [`docs/http-api.md`](docs/http-api.md) |+| Architecture, OODA design, findings-store schema | [`docs/design.md`](docs/design.md) |+| Sample redacted deliverable | [`docs/example-report.md`](docs/example-report.md) |-## Security & scope+## ⚠️ Security & authorized use-> ⚠️ **By default this product has no guardrails: no scope-guard, no consent, no audit, no+> **By default this product has no guardrails: no scope-guard, no consent, no audit, no> authorization gate.** Hermes runs directly whatever it decides against the target. This is> **intentional.** Use it **only against explicitly authorized targets** and in a **controlled> environment**. All responsibility for the scope and for lawful use rests with the operator.-There are two things you *can* turn on, and it helps to know what each does and does **not** cover.--### The opt-in scope-guard (`kali_run` / `kali_exec`)--A deterministic (code, not prompt) gate that validates the destination of every raw-shell action-**before** executing it. It lives inside the Kali MCP, in front of the two raw-shell runners. It-does **not** touch the cloud tools (Prowler/Pacu/IAM) or the browser MCP.--It activates **only** if a scope file exists and contains `enabled: true`; with no file, behavior is-identical to the default (no gate). When active it is **fail-closed**: a destination that is not-allowed — or a call where Hermes did not declare its `targets` — fails with a structured-`SCOPE_VIOLATION` and does not execute. Every violation is logged into the findings store as a-`discarded` record, so an attempt to leave scope is auditable in the report.--Turn it on:--1. Copy the template and edit it with your lab's allowed destinations (`scope.json` is git-ignored):-- ```sh- cp scope.example.json scope.json- ```-- ```json- {- "enabled": true,- "allow": [{ "cidr": "10.0.0.0/24" }, { "host": "juice-shop" }],- "deny": [{ "cidr": "10.0.0.1/32" }],- "ports": [80, 443, 3000]- }- ```-- - `allow`: `{cidr}` matches an IP against a CIDR; `{host}` is a **literal** hostname match (no- DNS, a suffix does not match). `deny` takes **priority** over `allow`. `ports` is optional:- when set, only those ports are allowed when the target carries one.--2. Uncomment the bind-mount in `docker-compose.yml` (kali service) so the file lands at- `/scope/scope.json`, then recreate the service. Create `scope.json` **before** `docker compose- up` so Docker mounts a file, not a directory.-- ```yaml- # volumes:- # - ./scope.json:/scope/scope.json:ro- ```-- **Strict `targets`:** with the scope active, Hermes **must** declare the `targets` argument (the- IP/host/URL the command touches) on `kali_run`/`kali_exec`, or the call is blocked. A best-effort- parse of the command is an extra belt that can only **block**, never approve — the declared- `targets` are the source of truth.-- **Kill-switch:** `SCOPE_ENFORCE=0` force-disables the guard even if the file says `enabled: true`.--### The MCP inbound token (`vulnerator-mcp` over HTTP)--When the `vulnerator-mcp` streamable-HTTP service is reachable, it is **fail-closed** on-`VULNERATOR_MCP_INBOUND_TOKEN` and every request must carry it as a Bearer. This gates **only** the-*client → vulnerator-mcp* edge. It does **not** re-protect the pre-existing `:8642` exposure (that-stays under its own `HERMES_API_SERVER_KEY` Bearer), and it is **not** a scope-guard — it controls-*who can reach the trigger*, not *what the engine is allowed to touch*. The local **stdio** mode has-no listener and needs no token.--### What none of this is--The scope-guard gates `kali_run`/`kali_exec` by destination; the inbound token gates reachability.-Neither is consent, a human-approval workflow, or a network firewall. The `scope` argument on the-MCP `start_pentest` tool is **advisory** (folded into the prompt for operator clarity), not an-enforced constraint. The hard brake is the opt-in scope-guard above.+There are two opt-in controls (a deterministic scope-guard for `kali_run`/`kali_exec`, and the MCP+inbound token). Neither is consent or a firewall. See **[`docs/security.md`](docs/security.md)** for+what each does and does **not** cover.## Media & brand assetsdiff --git a/docs/configuration.md b/docs/configuration.mdnew file mode 100644index 0000000..fed63e5--- /dev/null+++ b/docs/configuration.md@@ -0,0 +1,86 @@+# Configuration (`.env`)++All keys and credentials live in a `.env` file at the repo root. It is **not** versioned (it is in+`.gitignore`) and is the only place where you put secrets. The template `.env.example` documents+every variable.++The easiest way to produce a working `.env` is the installer — it only asks for your OpenRouter key+and auto-generates the two secret tokens:++```sh+./install.sh+```++To do it by hand, copy the template and fill in the values:++```sh+cp .env.example .env+```++## Required variables++| Variable | Required | Where to put it / how to get it |+| --- | --- | --- |+| `OPENROUTER_API_KEY` | **Yes** | Your OpenRouter API key (the provider of the LLM that reasons the OODA). Create it at <https://openrouter.ai/keys> and paste it into the `.env`. Not required in Ollama mode (see below). |+| `HERMES_API_SERVER_KEY` | **Yes** | Key for Hermes' API server (min. 8 chars). Generate one with `openssl rand -hex 32` and paste it into the `.env`. It is also the Bearer to pilot Hermes over HTTP. |+| `VULNERATOR_MCP_INBOUND_TOKEN` | **Yes** | Inbound Bearer for the `vulnerator-mcp` front door, which is **up by default** in streamable-HTTP mode. Generate one with `openssl rand -hex 32` and paste it into the `.env`. The default stack is **fail-closed** on this: `docker compose up` aborts without it. It is a **separate** secret from `HERMES_API_SERVER_KEY` and gates a different edge. (The local **stdio** mode for Claude Code / Kiro does not need it.) |++> The installer (`./install.sh`) fills `OPENROUTER_API_KEY` from your input and auto-generates both+> `HERMES_API_SERVER_KEY` and `VULNERATOR_MCP_INBOUND_TOKEN` as separate 32-byte hex secrets.++## Optional — AWS (cloud collection)++Only needed if you are going to use the cloud collection tools (Prowler / ScoutSuite /+Cloudsplaining). If you are not auditing AWS, leave these empty. Use **read-only** credentials for+the account you are AUTHORIZED to audit.++| Variable | Required | Where to put it / how to get it |+| --- | --- | --- |+| `AWS_ACCESS_KEY_ID` | No | **Read-only** credential for the account you are AUTHORIZED to audit. |+| `AWS_SECRET_ACCESS_KEY` | No | Secret for that same credential. |+| `AWS_SESSION_TOKEN` | No | Only for temporary credentials (STS). |+| `AWS_REGION` | No | Default region (e.g. `us-east-1`). |++## Optional — model, ports, scoping++| Variable | Required | Where to put it / how to get it |+| --- | --- | --- |+| `OPENROUTER_MODEL` | No | Overrides the OpenRouter model Hermes reasons with. Empty = the profile default (`mistralai/mistral-large-4-0`). **Caveat:** the project uses Mistral Large on purpose because models like Claude (`anthropic/*`) refuse the authorized-offensive pentest framing (OpenRouter/Anthropic returns "violative cyber content"); overriding with such a model may make the agent refuse to work. |+| `VULNERATOR_MCP_HOST_PORT` | No | HOST port to publish the `vulnerator-mcp` streamable-HTTP server. By default it publishes **no** host port (internal docker network only). Set this **and** uncomment the service's `ports:` block in `docker-compose.yml` to publish on a controlled machine. |+| `HERMES_API_HOST_PORT` | No | HOST port where Hermes' `:8642` API server is published. Empty = `8642`. |+| `KALI_MCP_HOST_PORT` | No | HOST port where `kali-mcp` is published for host-side inspection. Empty = `8900`. |+| `KALI_ARTIFACTS_TOKEN` | No | Shared token for the Kali artifacts data channel. |+| `PROWLER_STATUS` / `PROWLER_REGIONS` / `PROWLER_SERVICES` / `PROWLER_TIMEOUT` | No | Scope the Prowler cloud scan. Empty = compose defaults. |++The rest of the `.env.example` variables come with sane defaults; leave them empty unless you need+to change them.++## Local inference with Ollama (optional)++By default Hermes reasons with Mistral Large on OpenRouter. If you prefer to run the model yourself,+point Hermes at an [Ollama](https://ollama.com) endpoint (OpenAI-compatible) instead. This is+**opt-in** and fully controlled from the `.env`:++| Variable | Required | Where to put it / how to get it |+| --- | --- | --- |+| `OLLAMA_BASE_URL` | No | Empty = use OpenRouter (default). Set it to an Ollama OpenAI-compatible endpoint to use Ollama instead: `http://host.docker.internal:11434/v1` for a local host Ollama, or `http://<host>:11434/v1` for a remote one. When set, `OPENROUTER_API_KEY` is **not** required. |+| `OLLAMA_MODEL` | No | The Ollama model name used in Ollama mode, e.g. `qwen2.5-coder:32b`. |++At startup the stack branches on `OLLAMA_BASE_URL`: when it is empty the OpenRouter path is used+exactly as before (and a missing `OPENROUTER_API_KEY` still aborts startup); when it is set, the+startup script runs `hermes config set model.provider custom`, `model.base_url <OLLAMA_BASE_URL>`+and `model.default <OLLAMA_MODEL>`, so Hermes talks to Ollama.++Caveats before you rely on it:++- **Context window (hard blocker):** Hermes refuses to start against an endpoint serving less than+ ~64K tokens of context, and Ollama defaults to as low as 4K. Raise it **server-side** where Ollama+ runs with `OLLAMA_CONTEXT_LENGTH=64000` (it cannot be raised through the API).+- **Networking:** make Ollama listen on all interfaces (`OLLAMA_HOST=0.0.0.0`) so the container can+ reach it. On Linux, reaching a host-run Ollama relies on the+ `extra_hosts: ["host.docker.internal:host-gateway"]` mapping already set on `ooda-agent` (Docker+ Desktop on macOS/Windows resolves `host.docker.internal` automatically).+- **Model suitability (experimental):** every pentest action routes through MCP, so the model must do+ reliable tool/function-calling and must not refuse the authorized-offensive pentest framing. Parity+ with Mistral-Large-on-OpenRouter is **not guaranteed** — treat local inference as experimental and+ validate your chosen model before relying on it.diff --git a/docs/security.md b/docs/security.mdnew file mode 100644index 0000000..0e2be6f--- /dev/null+++ b/docs/security.md@@ -0,0 +1,73 @@+# Security & scope++> ⚠️ **By default this product has no guardrails: no scope-guard, no consent, no audit, no+> authorization gate.** Hermes runs directly whatever it decides against the target. This is+> **intentional.** Use it **only against explicitly authorized targets** and in a **controlled+> environment**. All responsibility for the scope and for lawful use rests with the operator.++There are two things you *can* turn on, and it helps to know what each does and does **not** cover.++## The opt-in scope-guard (`kali_run` / `kali_exec`)++A deterministic (code, not prompt) gate that validates the destination of every raw-shell action+**before** executing it. It lives inside the Kali MCP, in front of the two raw-shell runners. It+does **not** touch the cloud tools (Prowler/Pacu/IAM) or the browser MCP.++It activates **only** if a scope file exists and contains `enabled: true`; with no file, behavior is+identical to the default (no gate). When active it is **fail-closed**: a destination that is not+allowed — or a call where Hermes did not declare its `targets` — fails with a structured+`SCOPE_VIOLATION` and does not execute. Every violation is logged into the findings store as a+`discarded` record, so an attempt to leave scope is auditable in the report.++Turn it on:++1. Copy the template and edit it with your lab's allowed destinations (`scope.json` is git-ignored):++ ```sh+ cp scope.example.json scope.json+ ```++ ```json+ {+ "enabled": true,+ "allow": [{ "cidr": "10.0.0.0/24" }, { "host": "juice-shop" }],+ "deny": [{ "cidr": "10.0.0.1/32" }],+ "ports": [80, 443, 3000]+ }+ ```++ - `allow`: `{cidr}` matches an IP against a CIDR; `{host}` is a **literal** hostname match (no+ DNS, a suffix does not match). `deny` takes **priority** over `allow`. `ports` is optional:+ when set, only those ports are allowed when the target carries one.++2. Uncomment the bind-mount in `docker-compose.yml` (kali service) so the file lands at+ `/scope/scope.json`, then recreate the service. Create `scope.json` **before** `docker compose+ up` so Docker mounts a file, not a directory.++ ```yaml+ # volumes:+ # - ./scope.json:/scope/scope.json:ro+ ```++ **Strict `targets`:** with the scope active, Hermes **must** declare the `targets` argument (the+ IP/host/URL the command touches) on `kali_run`/`kali_exec`, or the call is blocked. A best-effort+ parse of the command is an extra belt that can only **block**, never approve — the declared+ `targets` are the source of truth.++ **Kill-switch:** `SCOPE_ENFORCE=0` force-disables the guard even if the file says `enabled: true`.++## The MCP inbound token (`vulnerator-mcp` over HTTP)++When the `vulnerator-mcp` streamable-HTTP service is reachable, it is **fail-closed** on+`VULNERATOR_MCP_INBOUND_TOKEN` and every request must carry it as a Bearer. This gates **only** the+*client → vulnerator-mcp* edge. It does **not** re-protect the pre-existing `:8642` exposure (that+stays under its own `HERMES_API_SERVER_KEY` Bearer), and it is **not** a scope-guard — it controls+*who can reach the trigger*, not *what the engine is allowed to touch*. The local **stdio** mode has+no listener and needs no token.++## What none of this is++The scope-guard gates `kali_run`/`kali_exec` by destination; the inbound token gates reachability.+Neither is consent, a human-approval workflow, or a network firewall. The `scope` argument on the+MCP `start_pentest` tool is **advisory** (folded into the prompt for operator clarity), not an+enforced constraint. The hard brake is the opt-in scope-guard above.diff --git a/docs/usage.md b/docs/usage.mdnew file mode 100644index 0000000..fc97c48--- /dev/null+++ b/docs/usage.md@@ -0,0 +1,171 @@+# Driving a pentest++Three ways to pilot an engagement, from simplest to most programmatic. All of them drive the same+OODA loop; pick by how you work.++## 1. Interactive TUI (`hermes chat`)++```sh+docker compose up -d --build+docker compose exec -it ooda-agent hermes chat+```++`hermes chat` opens the agent's REPL. Ask for a pentest in natural language; Hermes drives the OODA+and runs tools on Kali directly via `kali_run` (talking to `kali:8900`). The container's command+`hermes gateway run` also keeps Hermes' API server alive on `:8642`, which powers ways 2 and 3.++## 2. From an MCP client — recommended for assistants++If your tooling speaks **MCP** (Claude Code, Kiro, Cursor, BugTraceAI, …), the stack ships+**`vulnerator-mcp`** (`docker/mcp/`): a thin MCP server that wraps Hermes' runs API and exposes it+as MCP tools. It wraps, it does **not** replace, the HTTP API — it exposes **only** the runs+lifecycle, so the client stays a trigger/observer and never the brain. It never exposes+`/v1/chat/completions` or any raw `kali_run`.++**Five tools + a health check**, mapped 1:1 onto the runs API:++| Tool | Does |+| --- | --- |+| `start_pentest(input, scope, …)` | starts a run; returns `{run_id, status, replayed}` |+| `get_run_status(run_id)` | the full run object (status + `completed`/`partial`/`interrupted` + output + usage) |+| `stream_run_events(run_id, cursor, …)` | pages the lifecycle events with a `seq` cursor (`{events, next_cursor, done}`); also emits one MCP progress notification per page over streamable-HTTP |+| `steer_run(run_id, input)` | injects a correction mid-run; surfaces the `409 run_not_accepting_steer` verbatim |+| `stop_run(run_id)` | stops the run; returns the full run object |+| `health()` | upstream health (`{status, platform, version}`) |++Event/status/output payloads are forwarded verbatim as **untrusted data** (never interpreted).++### Local — stdio (recommended for Claude Code / Kiro)++Zero network surface: the client spawns the server as a subprocess over stdin/stdout — no listener,+no token, no port. Build the image once and add an `mcpServers` entry:++```sh+docker build -f docker/mcp/Dockerfile -t vulnerator-ai-mcp:dev .+```++```json+{+ "mcpServers": {+ "vulnerator-mcp": {+ "command": "docker",+ "args": [+ "run", "-i", "--rm",+ "--add-host", "host.docker.internal:host-gateway",+ "-e", "HERMES_API_SERVER_KEY",+ "-e", "HERMES_API_BASE_URL=http://host.docker.internal:8642",+ "vulnerator-ai-mcp:dev"+ ],+ "env": { "HERMES_API_SERVER_KEY": "<your HERMES_API_SERVER_KEY>" }+ }+ }+}+```++The upstream Bearer is a pass-through of `HERMES_API_SERVER_KEY` (no second secret for the hop). On+Docker Desktop `host.docker.internal` resolves out of the box; on stock Linux the `--add-host`+above is what makes it resolve (or point `HERMES_API_BASE_URL` at the host's reachable address).++### In-docker / remote — streamable-HTTP (up by default)++The streamable-HTTP service is part of the default stack, reachable on the internal network at+`http://vulnerator-mcp:8700` (an in-docker consumer like a BugTraceAI container reaches it there+with no extra steps). It is **fail-closed** on `VULNERATOR_MCP_INBOUND_TOKEN` (`docker compose up`+aborts without it) and every request must carry `Authorization: Bearer <VULNERATOR_MCP_INBOUND_TOKEN>`+(the `/healthz` route is the one exception). Host publication is **off by default** — set+`VULNERATOR_MCP_HOST_PORT` and uncomment the service's `ports:` block in `docker-compose.yml` to+publish on a controlled machine. See [`security.md`](security.md) for the threat model.++## 3. Raw HTTP API (`:8642`)++For CI scripts or plain `curl`, Hermes exposes an OpenAI-compatible API server directly on `:8642`+(the same endpoints `vulnerator-mcp` wraps). Full reference — access modes, the runs flow,+`chat/completions`, and the request/response contract — in [`http-api.md`](http-api.md).++# Practice against a lab target (Juice Shop)++To practice the `web-pentest` skill without going out to the internet or touching real systems,+the repo ships an **optional** target override, `docker-compose.target.yml`, that adds an+[OWASP Juice Shop](https://owasp.org/www-project-juice-shop/) service. Juice Shop is a+**deliberately-vulnerable** web application (OWASP project), the de facto standard for practicing+web pentesting (XSS, SQLi, broken auth, etc.).++The installer can bring it up for you:++```sh+./install.sh --with-juice-shop+```++Or layer both compose files by hand:++```sh+docker compose -f docker-compose.yml -f docker-compose.target.yml up -d --build+```++The target joins the **same internal docker network** and publishes **no port to the host**, so it+only exists inside the docker environment — scoping the exercise to a controlled lab. Hermes/Kali+reach it by its DNS name at **`http://juice-shop:3000`**. Point an engagement at that URL, e.g. via+the interactive TUI:++```sh+docker compose -f docker-compose.yml -f docker-compose.target.yml exec -it ooda-agent hermes chat+# then ask, in natural language:+# "Authorized web pentest against http://juice-shop:3000 (scope: that host only).+# Enumerate, fingerprint, and test for injection/auth flaws. Report confirmed findings."+```++This is the authorized target for practicing the `web-pentest` skill. Only the web lab is in scope+here (no AD or other labs for now).++# Start clean between exercises++So that each pentest starts without remembering anything from the previous one (conversation history+and Hermes' memory), bring the stack up from scratch. The cleanest and most deterministic way:++```sh+docker compose down -v # stops the containers and DELETES Hermes' state volume+docker compose up -d # starts with fresh state (the profile regenerates from agent-ooda/)+```++In a single line:++```sh+docker compose down -v && docker compose up -d+```++## What is deleted and what is kept++The `-v` flag deletes the named volume `hermes-data` (`/opt/data`), where Hermes' state+lives: the profile and its SQLite (`state.db`). That is where the history/memory you want to+forget between exercises resides. You don't lose configuration: the profile (`config.yaml`, `SOUL.md`,+`skills`) **regenerates** on each startup by copying the declarative template from `agent-ooda/`.++| What | Does it survive `down -v` + `up`? |+|---|---|+| Tools baked into the image by the Kali `Dockerfile` | **Yes** |+| Packages Hermes installed on the fly during a pentest | **No** (ephemeral layer of the `kali` container) |+| Hermes' state / memory / history (`hermes-data`) | **No** (exactly what `-v` deletes) |++Notes:++- The `kali` container **has no volume**: anything installed on the fly (e.g. an+ `apt install` Hermes does mid-engagement) lives in the container's ephemeral layer and+ disappears on the next `down`/`up`. If you want a tool to always be+ available without reinstalling it every session, **add it to the Kali `Dockerfile`** so+ it is baked into the image.+- To lose only the Kali packages you don't need `-v`: a plain `docker compose down`+ already recreates the `kali` container from the image. The `-v` adds the deletion of Hermes'+ state.+- `docker compose restart` does **not** recreate the containers, so it keeps both Hermes'+ state and whatever was installed on the fly in the Kali: it is not useful for starting clean.++## Alternative: new session without deleting the volume++If you prefer to keep the history but work in a clean conversation, open a+session with a new name instead of reusing the default one:++```sh+docker compose exec -it ooda-agent hermes chat --continue <new-session-name>+```++This does not delete the previous memory; it just avoids dragging it into the new conversation.diff --git a/install.sh b/install.shnew file mode 100755index 0000000..eabdd3f--- /dev/null+++ b/install.sh@@ -0,0 +1,201 @@+#!/usr/bin/env bash+# =============================================================================+# install.sh — the "easy" installer for vulnerator-ai.+# =============================================================================+# The fast path: the ONLY thing the user must provide is OPENROUTER_API_KEY.+# The script:+# 1. Checks prerequisites (docker, docker compose v2, openssl).+# 2. Reads OPENROUTER_API_KEY (from a prompt, the environment, or a flag).+# 3. Auto-generates HERMES_API_SERVER_KEY and VULNERATOR_MCP_INBOUND_TOKEN+# (SEPARATE secrets).+# 4. Builds the .env from .env.example, filling in only those three keys+# (everything else keeps the template defaults, comments included).+# 5. Brings the default stack up (WITHOUT the Juice Shop lab) with+# docker compose up -d --build.+#+# Usage:+# ./install.sh # interactive: prompts for the OpenRouter key+# OPENROUTER_API_KEY=sk-... ./install.sh # non-interactive (takes the key from the env)+# ./install.sh --with-juice-shop # also brings up the OWASP Juice Shop lab (opt-in)+# ./install.sh --no-up # writes the .env but does NOT run docker+# ./install.sh --force # overwrites an existing .env+# =============================================================================+set -euo pipefail++# --- Locate the repo directory (where this script lives) ---------------------+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+cd "$SCRIPT_DIR"++ENV_FILE="$SCRIPT_DIR/.env"+ENV_EXAMPLE="$SCRIPT_DIR/.env.example"++# --- Flags -------------------------------------------------------------------+FORCE=0+NO_UP=0+WITH_JUICE_SHOP=0++usage() {+ cat <<'EOF'+install.sh — easy installer for vulnerator-ai++Usage:+ ./install.sh [options]++Options:+ --force Overwrite an existing .env (default: abort if .env exists).+ --no-up Generate the .env but do NOT run docker compose up.+ --with-juice-shop Also bring up the OWASP Juice Shop lab target (opt-in).+ -h, --help Show this help.++The only value you must provide is OPENROUTER_API_KEY. It is read interactively,+or taken from the OPENROUTER_API_KEY environment variable if already exported.+HERMES_API_SERVER_KEY and VULNERATOR_MCP_INBOUND_TOKEN are generated automatically.+EOF+}++while [ $# -gt 0 ]; do+ case "$1" in+ --force) FORCE=1 ;;+ --no-up) NO_UP=1 ;;+ --with-juice-shop) WITH_JUICE_SHOP=1 ;;+ -h|--help) usage; exit 0 ;;+ *) echo "ERROR: unknown option '$1' (use --help)" >&2; exit 2 ;;+ esac+ shift+done++# --- Output helpers ----------------------------------------------------------+info() { printf '\033[1;36m==>\033[0m %s\n' "$*"; }+ok() { printf '\033[1;32m OK\033[0m %s\n' "$*"; }+warn() { printf '\033[1;33m !\033[0m %s\n' "$*" >&2; }+die() { printf '\033[1;31mERR\033[0m %s\n' "$*" >&2; exit 1; }++# --- 1. Prerequisites --------------------------------------------------------+check_prereqs() {+ info "Checking prerequisites..."++ command -v docker >/dev/null 2>&1 \+ || die "docker is not installed or not in PATH. Install Docker: https://docs.docker.com/get-docker/"++ # docker compose v2 (plugin). The legacy 'docker-compose' (v1) is not supported.+ if ! docker compose version >/dev/null 2>&1; then+ die "the 'docker compose' v2 plugin is not available. Install/update Docker Desktop or the compose plugin: https://docs.docker.com/compose/install/"+ fi++ command -v openssl >/dev/null 2>&1 \+ || die "openssl is not installed or not in PATH (needed to generate the secret keys)."++ [ -f "$ENV_EXAMPLE" ] \+ || die ".env.example not found at $ENV_EXAMPLE. Run this script from the repo root."++ ok "docker, docker compose v2 and openssl are available."+}++# --- 2. OPENROUTER_API_KEY ---------------------------------------------------+# Resolution order: exported environment variable > interactive prompt.+read_openrouter_key() {+ if [ -n "${OPENROUTER_API_KEY:-}" ]; then+ info "Using OPENROUTER_API_KEY from the environment."+ return+ fi++ if [ ! -t 0 ]; then+ die "OPENROUTER_API_KEY is not set and no interactive terminal is available. Export OPENROUTER_API_KEY and re-run, e.g.: OPENROUTER_API_KEY=sk-... ./install.sh"+ fi++ echo+ info "Enter your OpenRouter API key (the LLM provider that reasons the OODA loop)."+ info "Create one at https://openrouter.ai/keys"+ # -s suppresses the on-screen echo; -r keeps backslashes literal.+ printf 'OPENROUTER_API_KEY: '+ read -rs OPENROUTER_API_KEY+ echo+ export OPENROUTER_API_KEY+}++# --- 3. Secret generation ----------------------------------------------------+gen_secret() { openssl rand -hex 32; }++# --- 4. Build the .env -------------------------------------------------------+# Copy .env.example (preserving comments and order) and substitute ONLY the lines+# for the three managed keys. Every other variable stays as-is (defaults/empty).+# awk receives the values via -v so they are never interpolated into the program,+# avoiding any injection coming from the user-supplied API key.+build_env() {+ local openrouter_key="$1" hermes_key="$2" mcp_token="$3"++ info "Building .env from .env.example (only the three required keys are filled in)..."++ awk -v ork="$openrouter_key" -v hk="$hermes_key" -v mt="$mcp_token" '+ /^OPENROUTER_API_KEY=/ { print "OPENROUTER_API_KEY=" ork; next }+ /^HERMES_API_SERVER_KEY=/ { print "HERMES_API_SERVER_KEY=" hk; next }+ /^VULNERATOR_MCP_INBOUND_TOKEN=/ { print "VULNERATOR_MCP_INBOUND_TOKEN=" mt; next }+ { print }+ ' "$ENV_EXAMPLE" > "$ENV_FILE.tmp"++ # Sanity check: the three keys must have ended up with a non-empty value.+ grep -q "^OPENROUTER_API_KEY=.\+" "$ENV_FILE.tmp" || { rm -f "$ENV_FILE.tmp"; die "failed to write OPENROUTER_API_KEY into .env (is the key in .env.example?)."; }+ grep -q "^HERMES_API_SERVER_KEY=.\+" "$ENV_FILE.tmp" || { rm -f "$ENV_FILE.tmp"; die "failed to write HERMES_API_SERVER_KEY into .env."; }+ grep -q "^VULNERATOR_MCP_INBOUND_TOKEN=.\+" "$ENV_FILE.tmp" || { rm -f "$ENV_FILE.tmp"; die "failed to write VULNERATOR_MCP_INBOUND_TOKEN into .env."; }++ mv "$ENV_FILE.tmp" "$ENV_FILE"+ chmod 600 "$ENV_FILE" 2>/dev/null || true+ ok ".env written (OpenRouter key set; Hermes API key and MCP inbound token auto-generated)."+}++# --- 5. Bring the stack up ---------------------------------------------------+compose_up() {+ local -a compose_args=(compose)+ if [ "$WITH_JUICE_SHOP" -eq 1 ]; then+ compose_args+=(-f docker-compose.yml -f docker-compose.target.yml)+ info "Bringing the stack up WITH the Juice Shop lab target..."+ else+ info "Bringing the default stack up (no Juice Shop lab)..."+ fi+ compose_args+=(up -d --build)++ docker "${compose_args[@]}"+}++# --- Orchestration -----------------------------------------------------------+main() {+ check_prereqs++ if [ -f "$ENV_FILE" ] && [ "$FORCE" -ne 1 ]; then+ die ".env already exists at $ENV_FILE. Refusing to overwrite it. Re-run with --force to replace it, or delete it first."+ fi++ read_openrouter_key+ [ -n "${OPENROUTER_API_KEY:-}" ] || die "OPENROUTER_API_KEY is empty. It is required in OpenRouter mode (the default)."++ local hermes_key mcp_token+ hermes_key="$(gen_secret)"+ mcp_token="$(gen_secret)"++ build_env "$OPENROUTER_API_KEY" "$hermes_key" "$mcp_token"++ if [ "$NO_UP" -eq 1 ]; then+ echo+ ok "Done (--no-up): .env is ready. Bring the stack up yourself with: docker compose up -d --build"+ return+ fi++ compose_up++ # --- Final summary -------------------------------------------------------+ echo+ ok "vulnerator-ai is coming up."+ echo+ info "Secrets written to .env:"+ echo " - OPENROUTER_API_KEY (the key you provided)"+ echo " - HERMES_API_SERVER_KEY (auto-generated, 32-byte hex)"+ echo " - VULNERATOR_MCP_INBOUND_TOKEN (auto-generated, 32-byte hex)"+ echo+ info "Open the interactive TUI once the containers are healthy:"+ echo " docker compose exec -it ooda-agent hermes chat"+ echo+ warn "This engine has NO scope-guard, consent or audit by default. Use it ONLY against"+ warn "explicitly authorized targets and in a controlled environment. See docs/security.md."+}++main "$@"