Metadata-Version: 2.5
Name: cyberclaw
Version: 0.1.1
Summary: AI-powered penetration testing CLI tool for cybersecurity professionals
Project-URL: Homepage, https://github.com/Lord1Egypt/CyberClaw
Project-URL: Repository, https://github.com/Lord1Egypt/CyberClaw
Project-URL: Issues, https://github.com/Lord1Egypt/CyberClaw/issues
Author: CyberClaw contributors, UncleC (original VulnClaw author)
License-Expression: MIT
License-File: LICENSE
License-File: THIRD_PARTY_NOTICES.md
Keywords: ai,cli,mcp,pentest,red-team,security,vulnerability
Classifier: Intended Audience :: Information Technology
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Security
Requires-Python: >=3.10
Requires-Dist: beautifulsoup4>=4.12.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: jinja2>=3.1.0
Requires-Dist: jsonschema>=4.20.0
Requires-Dist: lxml>=4.9.0
Requires-Dist: mcp<2.0,>=1.0
Requires-Dist: openai>=1.66.0
Requires-Dist: prompt-toolkit>=3.0.0
Requires-Dist: pycryptodome>=3.19.0
Requires-Dist: pydantic-settings>=2.0.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: rich>=13.0.0
Requires-Dist: toml>=0.10.0
Requires-Dist: typer>=0.12.0
Provides-Extra: dev
Requires-Dist: build>=1.2.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.4.0; extra == 'dev'
Provides-Extra: kb
Requires-Dist: chromadb>=0.4.0; extra == 'kb'
Provides-Extra: pdf
Requires-Dist: reportlab>=4.0; extra == 'pdf'
Provides-Extra: rerank
Requires-Dist: sentence-transformers>=2.2.0; extra == 'rerank'
Provides-Extra: traffic
Requires-Dist: mitmproxy>=10.0; extra == 'traffic'
Requires-Dist: playwright>=1.40; extra == 'traffic'
Provides-Extra: web
Requires-Dist: fastapi>=0.115.0; extra == 'web'
Requires-Dist: uvicorn>=0.30.0; extra == 'web'
Description-Content-Type: text/markdown

<div align="center">

# CyberClaw

> *AI-Powered Penetration Testing CLI — Speak plainly, find real bugs.*

**License: MIT** · **Python 3.10+** · **PyPI: v0.1.1** · **Scope: Authorized Testing Only**

**This project is a standalone AI penetration testing Agent.**

Built on LLM Agent + MCP Toolchain + optional Skill reference material,
compatible with OpenAI / Anthropic / MiniMax / DeepSeek and similar models.
Natural language input → automated "Recon → Vulnerability Discovery → Exploitation → Reporting".

[Quick Start](#quick-start) · [Architecture](#architecture) · [Built-in Skills](#built-in-skills)

</div>

---

## What It Does

Give it a natural language command and watch it run a full pentest:

```
User:   "Run a penetration test on http://target.example.com"

CyberClaw executes:
  Round 1:  Recon → Fingerprinting, port scan, directory enumeration
  Round 2:  Vulnerability Discovery → Injection points, known CVEs, misconfigs
  Round 3:  Exploitation → PoC verification, access obtained
  Round 4:  Reporting → Structured report + Python PoC script
```

Suitable for authorized pentests, CTF competitions, security training, and red team operations.

---

## Features

- **Model-Led Solver Engine (default)** — Claude Code/Codex-style autonomous loop: the model decides the next action, tool usage, completion, user questions, or no-path termination
- **Parallel Sub-Agent Fan-Out** — The model can spawn multiple independent sub-agents in a single turn via `spawn_subagents`; each sub-agent inherits target constraints and evidence, runs concurrently with its own lifecycle budget; sub-evidence is merged back into the parent state with unified `eNNN` renumbering
- **Cold/Hot Memory Separation** — Hot conversation context retains only recent complete tool-exchange groups (default 48 messages / 32K tokens); older messages are archived to rotating JSONL shards; `memory_search` retrieves relevant archived turns on demand
- **Unified Context Budget & Structured Compaction** — All LLM call paths go through `prepare_context`, which estimates tokens (including tool schemas), triggers structured compaction at 70% of usable context, and generates a deterministic `[context digest v1]` summary (target/scope/verified facts/evidence references) — no LLM free-form summarization needed
- **TUI Sub-Agent Monitor** — Real-time panel showing each sub-agent's role, status, step count, and latest progress via a private JSON-line protocol
- **AgentState Evidence Memory** — Tool results are stored in `AgentState.evidence` with complete raw text preserved; active context receives bounded high-signal previews by default, while `evidence_search` / `evidence_view` revisit raw evidence on demand
- **Lightweight Correction Layer** — Records repeated calls, degraded tools, timing, and new observations; repeated reads of the same evidence range are suppressed and evidence-only stalls trigger a stall guard without restoring the old stage planner
- **Evidence-Level Anti-Hallucination Gate** — Claims about flags/conclusions must appear verbatim in real tool output to be accepted; prevents fabricated flags
- **Natural Language Driven** — Describe your goal in plain English, auto-identifies phases and tools
- **13 LLM Providers** — OpenAI / Anthropic / MiniMax / DeepSeek / Zhipu / Moonshot / Qwen / SiliconFlow / Doubao / StepFun / SenseTime / OpenRouter / local Ollama, one-command switch
- **MCP Toolchain** — 4 MCP services: `fetch` / `memory` run locally out-of-the-box, `chrome-devtools` / `burp` connect to external MCP servers for browser automation and HTTP interception
- **Enhanced fetch request tool** — Defaults to GET, returns the full response body, and supports HTTP/HTTPS, custom method/headers/params/cookies/body/data/form/json, timeout/redirect/TLS controls; TLS verification is off by default for CTF/lab HTTPS targets
- **Native Traffic Evidence Store** — In-scope request/response pairs land in an append-only JSONL index under `evidence/traffic/`. Built-in `traffic_list` / `traffic_view` / `traffic_repeat` / `traffic_sitemap` tools read and replay the store
- **AI Agent Core** — OpenAI-compatible protocol + Tool Calling + autonomous pentest loop
- **Structured Reasoning + Adaptive Reflection** — Facts/constraints/attack chains structured and injected into prompts; failures auto-classified with L0-L4 payload escalation
- **Vulnerability Detection Plugin System** — Low-coupling plugin runtime + built-in read-only Web plugins, results auto-merged into reports (`cyberclaw plugins`)
- **50 Specialized Skills** — CTF, Web, intranet, reversing, vulnerability validation, and authorized red-team knowledge; skills are exposed as optional reference indexes only, and full reference bodies are loaded only when the model explicitly calls `load_skill_reference`
- **Encode/Decode & Crypto Tools** — 29 operations (Base64/Hex/URL/AES/JWT/Morse etc.), LLM calls them directly, no guessing
- **Automatic Source Rendering** — `fetch` / `http_probe_batch` automatically prepend clean source before raw bodies when they see `highlight_file`, highlighted HTML source, or noisy HTML/JS bodies; `http_probe_batch` disables TLS verification by default and records full response headers so runtime clues such as `X-Powered-By` are not lost; built-in `source_extract` remains available for revisiting saved evidence and pinning dangerous sinks, forms, inputs, and endpoints
- **Local Command Verification** — Built-in `shell_command` supports Codex-style local checks such as `php -r` serialization tests, exact `curl` requests, and `rg`/`Select-String` file searches; raw stdout/stderr are preserved in evidence, and large active-context observations use high-signal previews
- **Runtime Differential Probing** — Built-in `runtime_diff_probe` helps the model build compact local tables for regex/string-filter vs runtime-parser mismatches, including PHP serialize/unserialize lexical variants, target/local runtime version mismatch notes, and PHP5 signed-length candidates that must be verified remotely instead of being discarded due to newer local PHP behavior
- **Python Code Execution** — Built-in `python_execute` tool for payload crafting and response parsing; currently still a high-risk experimental capability, not a strong isolation sandbox
- **Batch HTTP Probing** — Built-in `http_probe_batch` compares URL/parameter/header/body/raw-URL variants in one call, preserves each raw response body in evidence, and shows the audited request surface plus high-signal response preview in model-visible output to reduce repeated LLM/tool rounds
- **Near-Miss Stop Guard** — solve keeps the evidence gate and adds a generic `NO_PATH` guard: when unresolved high-signal anchors such as source sinks, forms/parameters, request surfaces, local proof or response differentials exist, a single no-output/same-body payload attempt is not accepted as proof that the path is dead
- **Persistent Pentesting** — Cyclic runs (100 rounds/cycle × 10 cycles = 1000 rounds), auto-reports every cycle
- **Thinking Process Control** — `think on/off` toggles LLM reasoning visibility
- **Sandbox Mode Prompting** — Unlocks AI security testing capabilities, for CTF and authorized pentest scenarios
- **Auto Report & PoC** — Generates structured Markdown reports and runnable Python PoC scripts
- **Web UI Mode** — `cyberclaw web` launches a local web interface, default `127.0.0.1:7788`
- **Security Knowledge Base** — Includes KB module and baseline seed data; retrieval augmentation being integrated

---

## Quick Start

### Installation

```bash
# Install from PyPI (recommended)
pip install cyberclaw

# Install from source
git clone https://github.com/Lord1Egypt/CyberClaw.git
cd CyberClaw
pip install -e .
```

### Run with Docker (optional)

The image bundles the Web UI plus runtimes (`npx` / `uvx`) for default MCP servers. All state persists in a `/data` volume.

```bash
cp .env.example .env          # add CYBERCLAW_LLM_API_KEY etc.
docker compose up --build      # build the image and start the Web UI
# open http://127.0.0.1:7788
```

Or run a one-off CLI command:

```bash
docker run --rm -it \
  -e CYBERCLAW_LLM_API_KEY=sk-your-key-here \
  -v cyberclaw-data:/data \
  cyberclaw:latest scan <target>
```

> ⚠️ `localhost` inside the container refers to the container itself. To scan a host service use `host.docker.internal`. See [DOCKER.md](DOCKER.md).

### Four-Step Launch

```bash
# 1. Select provider (auto-fills Base URL and model name)
cyberclaw config provider minimax   # or openai / anthropic / deepseek / zhipu / moonshot / qwen / siliconflow / ollama

# 1.2 (optional) custom Base URL or model name
cyberclaw config set llm.base_url https://your-own-api.example.com/v1
cyberclaw config set llm.model your-model-name

# 2. Set API Key
cyberclaw config set llm.api_key sk-your-key-here
#    — or sign in with ChatGPT subscription (no API key needed):
#      cyberclaw login   (browser sign-in; note ToS caveat)

# 3. Default: open the original CLI / REPL
cyberclaw

# 4. Optional: open the TUI workbench
cyberclaw tui
```

### Environment Check

```bash
cyberclaw doctor
```

Sample output:

```
🦞 CyberClaw Environment Check

  Python: 3.14.4
  Node.js: v24.14.1
  npx: installed
  nmap: installed

LLM Config:
  Provider: openai
  Auth Mode: static
  Credentials: configured
  Base URL: https://api.openai.com/v1
  Model: gpt-4o

MCP Services:
  fetch: enabled [P0]
  memory: enabled [P0]
  ...

✅ Ready. Run cyberclaw to start.
```

---

## CLI Command Reference

```bash
$ cyberclaw --help

🦞 CyberClaw — AI-powered penetration testing CLI

 Usage: cyberclaw [OPTIONS] COMMAND [ARGS]...

 Commands:
   run           🚀 Full pentest in one shot (defaults to the solve engine)
   solve         🧩 Goal-driven solver (model-led, no fixed rounds)
   persistent    🔄 Persistent pentesting (100 rounds/cycle)
   recon         🔍 Reconnaissance only
   scan          🔎 Vulnerability scanning
   exploit       💥 Exploitation phase
   report        📝 Generate report from session JSON
   repl          💬 Start the classic REPL
   config        ⚙️  Manage config (set/get/list/provider)
   plugins       🧩 Manage vulnerability detection plugins (list/info/run)
   init          🔧 Initialize configuration
   doctor        🏥  Check runtime environment
   tui           🖥️  Open the terminal UI workbench
   web           🌐 Launch local Web UI
   code          🧬 Local source-code security scan (no network target)
```

| Command | Description | Example |
|---------|-------------|---------|
| `cyberclaw` | Open the original CLI / REPL by default | `cyberclaw` |
| `cyberclaw tui` | Terminal UI workbench | `cyberclaw tui --target target.com` |
| `cyberclaw repl` | Start the classic REPL | `cyberclaw repl` |
| `cyberclaw solve <target>` | Goal-driven solver (no fixed rounds) | `cyberclaw solve target.com --goal "get the flag"` |
| `cyberclaw run <target>` | Full pentest in one shot | `cyberclaw run 192.168.1.1` |
| `cyberclaw persistent <target>` | Persistent pentesting (100 rounds/cycle) | `cyberclaw persistent 192.168.1.1` |
| `cyberclaw recon <target>` | Reconnaissance only | `cyberclaw recon target.com` |
| `cyberclaw scan <target>` | Vulnerability scanning | `cyberclaw scan target.com --ports 80,443` |
| `cyberclaw exploit <target>` | Exploitation phase | `cyberclaw exploit target.com --cve CVE-2024-1234` |
| `cyberclaw report <session>` | Generate report from session JSON | `cyberclaw report session_xxx.json` |
| `cyberclaw config set <key> <value>` | Set a config value | `cyberclaw config set llm.api_key sk-xxx` |
| `cyberclaw config provider <name>` | Switch LLM provider | `cyberclaw config provider minimax` |
| `cyberclaw plugins list` | List vulnerability detection plugins | `cyberclaw plugins list --stage discovery` |
| `cyberclaw plugins info <id>` | View plugin metadata | `cyberclaw plugins info builtin.web.headers` |
| `cyberclaw plugins run <id>` | Run plugin (analysis only) | `cyberclaw plugins run builtin.web.headers --input headers.json` |
| `cyberclaw code scan <path>` | Local source-code security scan (L1 regex / L2 structural / L3 LLM optional) | `cyberclaw code scan ./src --format sarif` |

---

## Usage

### Mode 1: CLI / REPL (Default)

```bash
cyberclaw
```

No-args startup opens the 🦞 interactive shell for natural-language use:

```
🦞 cyberclaw> pentest 192.168.1.100 — this is my authorized lab

[*] Entering autonomous pentest mode. Press Ctrl+C to interrupt.
── Round 1 ──
  [+] Target: 192.168.1.100
  [+] Open ports: 22, 80, 443, 8080
  [+] Web fingerprint: Apache/2.4.62
── Round 2 ──
  [+] Discovered /manager/html (Tomcat Manager)
  [+] Matched CVE-202X-XXXX: Apache Tomcat Auth Bypass
── Round 3 ──
  [+] Vulnerability verified

🦞 192.168.1.100 | report> generate pentest report
[+] Report saved: ./reports/192.168.1.100_20260418.md
[+] PoC saved: ./pocs/CVE-202X-XXXX.py
```

**REPL Built-in Commands:**

| Command | Description |
|---------|-------------|
| `target <host>` | Set pentest target |
| `status` | View current state |
| `tools` | List available MCP tools |
| `think on/off` | Toggle thinking process display |
| `mode [mode]` | Show or switch the execution approval mode (ask / auto_review / full_access) |
| `persistent` | Start persistent pentesting |
| `clear` | Clear current session |
| `help` | Show help |
| `exit` / `quit` / `q` | Exit |

**Auto Pentest Trigger:** Keywords like "pentest", "find flag", "bruteforce" + a target address auto-enter the multi-round autonomous loop. `Ctrl+C` to interrupt anytime.

### Mode 2: TUI Workbench

Optional terminal UI workbench showing authorized target, check mode, runtime overview, and safety boundary — confirm scope before launching.

The workbench is a separate Rust binary, `cyberclaw-tui-native`. The Python
package (PyPI wheel or sdist) does **not** include it, and CyberClaw never
downloads one. Build it from a source checkout with Rust installed:

```bash
cd tui && cargo build --release --locked
# then either put tui/target/release/cyberclaw-tui-native on PATH,
# or: export CYBERCLAW_TUI_BINARY=/path/to/cyberclaw-tui-native
```

Without the binary, `cyberclaw tui` prints these instructions and exits; the
REPL (`cyberclaw`) and Web UI (`cyberclaw web`) need no extra build.

```bash
cyberclaw tui
cyberclaw tui --target https://target.example --mode quick --only-port 443
cyberclaw tui --dry-run --target https://target.example --mode deep --only-path /admin
```

The Rust workbench has configurable containers: Status on the left, Findings and Subagents stacked on the right, agent output in the center, and an input area below. Subagent data is currently unavailable.

- Drag a view title between sidebars or to reorder it. An orange preview shows the module's position and size after release; click `v` / `>` to collapse or expand.
- Drag a separator to resize neighboring containers or expanded views. Press Esc during a drag to cancel.
- The mouse wheel scrolls the view under the pointer. Click to focus, use arrow keys to scroll, `Ctrl+Left/Right` to cycle views, and `Ctrl+Y` to copy the focused view.
- An empty secondary sidebar collapses automatically. Drag a view to the workbench's right edge for an orange docking preview, then release to reopen it. The primary sidebar always keeps at least one view.
- Layout changes save automatically to `CYBERCLAW_HOME/tui/layout.json` (default `~/.cyberclaw/tui/layout.json`). The command palette grows the input area automatically. Small terminals show the required dimensions and restore the layout when enlarged.

Native text selection while mouse capture is active depends on your terminal's modifier keys; `Ctrl+Y` copies an individual view. On Windows terminals `Ctrl+V`, `Shift+Insert`, and the right mouse button read the system clipboard directly into the composer (Win32 API, microseconds; the platform has no bracketed paste, so pasting never depends on the terminal synthesizing keystrokes); Unix terminals paste via bracketed paste.

Common menus:
- **Menu 3** — Set testing scope (host/port/path/allowed actions/blocked actions)
- **Menu 7** — Environment diagnostics (full details via `cyberclaw doctor`)
- **Menu 8** — Model/API settings (switch Provider, Base URL, Model, API Key)

### Mode 3: Single Command

```bash
cyberclaw run 192.168.1.100                    # full pentest
cyberclaw recon 192.168.1.100                   # recon only
cyberclaw scan 192.168.1.100 --ports 80,443     # vuln scan
cyberclaw exploit 192.168.1.100 --cve CVE-2024-1234 --cmd id  # exploit
cyberclaw report session.json                   # generate report
```

### Mode 4: Persistent Pentesting

For long-running deep pentesting. Runs in **cyclic loops**:

```
┌──────────────────────────────────────────────┐
│  Cycle 1 (100 rounds) → auto-report → continue │
│  Cycle 2 (100 rounds) → auto-report → continue │
│  ...                                             │
│  Until Ctrl+C or max cycles reached (default 10) │
└──────────────────────────────────────────────┘
```

```bash
cyberclaw persistent 192.168.1.100              # default 100 rounds/cycle × 10 cycles
cyberclaw persistent 192.168.1.100 -r 200 -c 5  # 200 rounds/cycle × 5 cycles
cyberclaw persistent 192.168.1.100 --no-report   # disable auto-report

# TUI mode
cyberclaw tui --target 192.168.1.100 --mode continuous

# REPL mode
🦞 cyberclaw> persistent 192.168.1.100
```

**Features:** Cross-cycle state / Cycle reports / Graceful interrupt / Incremental discovery / Fully configurable

### Mode 5: Web UI

Operate the full pentest workflow through a browser.

```bash
git clone https://github.com/Lord1Egypt/CyberClaw.git
cd CyberClaw
pip install -e '.[web]'       # install from a source checkout

# First run: build the React frontend (Node.js 18+)
cd frontend
npm install
npm run build
cd ..

cyberclaw web                  # launch (default 127.0.0.1:7788)
cyberclaw web --port 8080      # custom port
```

The published wheel does not contain the React build or its source files. Use
the source-checkout installation above for the full Web UI. If you see the
**Fallback Web Shell** (no full scan UI),
`frontend/dist/index.html` is missing. Build as above, restart `cyberclaw web`,
and hard-refresh. API endpoints such as `/api/health` still work while the SPA is unbuilt.

> ⚠️ By default binds to localhost only. For remote access pass `--host 0.0.0.0 --allow-remote`.

Web authentication:

- A browser on the same machine (`127.0.0.1`, `localhost`, `[::1]`) is trusted
  as the local operator. Requests that name another host, arrive through a
  proxy (`X-Forwarded-For`/`Forwarded`), or come from another web page's origin
  are not. Set `CYBERCLAW_WEB_TRUST_LOOPBACK=false` to require sign-in locally too.
- Remote browsers sign in through a single-use link that expires after 10
  minutes. `cyberclaw web --allow-remote` prints one at startup, and
  `cyberclaw web --login-link` issues another. Sessions last 12 hours
  (`CYBERCLAW_WEB_SESSION_HOURS`) and end on restart or `POST /api/logout`.
- API clients send `Authorization: Bearer <token>`. The token is stored owner-only in
  `<config dir>/web_token` and is never printed; `cyberclaw web --rotate-token`
  replaces it.
- `CYBERCLAW_WEB_ALLOWED_HOSTS` restricts the accepted `Host` names, and
  `CYBERCLAW_WEB_MAX_ACTIVE_TASKS` (default 3) limits concurrent Web tasks.

---

## Architecture

### Solver Engine

CyberClaw defaults to the **model-led solve engine** (switch back to fixed-round with `cyberclaw config set session.engine rounds`).

**Model-Led Loop:** The framework no longer decomposes a task into forced "research directions", and it no longer schedules directory scans, JS reconnaissance, or SQLi checks by phase templates. solve provides the target, conversation context, evidence memory, and tool catalog; the model decides the next action.

| Primitive | Meaning |
|-----------|---------|
| **Model context** | Target, user constraints, recent messages, evidence summaries, and executed tool calls |
| **Tool catalog** | `fetch`, browser, directory enumeration, JS recon, encode/decode, Python, `shell_command`, `source_extract`, `runtime_diff_probe`, skill lookup, and other capabilities exposed only as optional hands |
| **Tool transcript** | After tool execution, assistant `tool_calls` and `role=tool` observations are appended to model history; large outputs use high-signal previews so HTML bodies, logs, and response blobs do not repeatedly pollute active context |
| **AgentState evidence** | Every real tool result is stored in `AgentState.evidence`; raw text is preserved with evidence id/hash/size, and the model can use `evidence_search` / `evidence_view` to revisit exact content |
| **High-signal memory** | Source SQL, HTML forms/inputs, linked PHP/API files, JavaScript endpoints, `highlight_file` source, and `unserialize`/magic-method/dangerous-sink snippets are pinned as durable facts so later probes do not bury the actual entry point |
| **Lightweight correction layer** | Observes tool lifecycle only: timing, degraded failures, repeated calls, high-signal target facts, and small semantic deltas become next-turn hints; it does not plan stages or schedule tools |
| **Evidence gate** | `FINAL:` conclusions must cite or match real evidence; unsupported flags/conclusions are rejected and the model continues |
| **Automatic solve report** | After completion, solve generates a Markdown replay report with reasoning chain, key evidence, raw replay request, curl command, response excerpt, and evidence index |

```
MODEL DECIDES → optional tool call → AgentState records full raw evidence + active-context high-signal preview + correction hints
        │
continue reasoning / continue tool use / ASK_USER / NO_PATH / FINAL
        │
FINAL passes evidence gate → accepted; otherwise the rejection is fed back and solve continues
```

**Context Strategy:** solve keeps ordinary conversation history by default. Hot context is bounded to 48 messages / 32K tokens; when exceeded, older messages are archived to cold-memory JSONL shards and retrievable via `memory_search`. The unified context budget (`prepare_context`) estimates tokens (including tool schemas) across all LLM call paths and triggers structured compaction at 70% of usable context, generating a deterministic `[context digest v1]` summary with target/scope/verified facts/evidence references. Tool output is fully stored in `AgentState.evidence`, while large outputs enter active context as bounded high-signal previews. The same raw output appearing again gets a `same_as=eXXX` reference instead of repeating the body.

**Evidence-Level Anti-Hallucination Gate:** Records all real tool output as the sole trusted evidence. Claims about flags/conclusions must appear in real output or cite evidence ids before they are accepted. `NO_PATH` is also gated by the near-miss guard: if unresolved high-signal anchors remain in evidence, the rejection reason is fed back to the model for another concrete verification step instead of stopping immediately.

**Automatic Solve Report:** When solve reaches the goal, CyberClaw deterministically renders a Markdown replay report from `AgentState` and prints it by default. It does not make another LLM call; replay packets, curl commands and response excerpts come from real `fetch` / `http_probe_batch` evidence.

**Authorized Red-Team Skills:** Authorized red-team detail packs from `codex-redteam-mode` are imported as skills/knowledge for on-demand use; jailbreak, refusal-bypass, and session-patching content is not imported.

### Core Modules

| Module | File | Description |
|--------|------|-------------|
| **CLI/TUI Entry** | `cli/main.py` + `cli/tui.py` | Typer commands + REPL + TUI |
| **Agent Core** | `agent/core.py` | AgentCore coordination entrypoint |
| **Solver Engine** | `agent/solver.py` + `agent/agent_state.py` | Model-led loop + AgentState evidence / steps / completion gate |
| **Sub-Agent Runtime** | `agent/subagent/` | Parallel fan-out: budget, integration, merge, service, solve |
| **Context Budget** | `agent/context_budget.py` + `agent/token_counter.py` | Unified token budget, structured compaction, tool-exchange grouping |
| **Cold/Hot Memory** | `agent/memory.py` + `agent/context.py` (ContextManager) | Hot context bounding, cold-memory archival & retrieval |
| **Reasoning / Reflection** | `agent/reasoning_state.py` + `reflexion.py` | Structured facts/constraints/attack chains + L0-L4 escalation |
| **Plugin System** | `plugins/` | Low-coupling vulnerability detection plugin runtime |
| **Skill reference index** | `skills/loader.py` + `resolver.py` | Task-aware optional references without forced workflow injection |
| **MCP Orchestration** | `mcp/registry.py` + `lifecycle.py` + `router.py` | Service registry + lifecycle + tool routing |
| **Config** | `config/schema.py` + `settings.py` | Pydantic + YAML + 14 provider presets + SubagentConfig |
| **Report Generator** | `report/generator.py` + `poc_builder.py` | Markdown reports + PoC scripts |
| **Security KB** | `kb/store.py` + `retriever.py` + `ranking.py` | JSON storage + Chinese-aware BM25 retrieval + optional reranking |

---

## MCP Toolchain

| MCP Service | Tools | Mode | Use Case | Status |
|---|---|---|---|---|
| fetch | 1 | Local (httpx) | HTTP/HTTPS requests, GET/POST/PUT methods, headers/params/cookies/body/json/form, API testing | Out-of-the-box |
| memory | 2 | Local (JSON) | Context memory, state persist | Out-of-the-box |
| chrome-devtools | 31+ | stdio MCP | Browser automation, screenshots, JS execution | Requires setup |
| burp | Multiple | stdio MCP | HTTP interception, replay, vuln scanning | Requires setup |

> Plus built-in Agent tools (`http_probe_batch`, `python_execute`, `shell_command`, `source_extract`, `runtime_diff_probe`, `nmap_scan`, `crypto_decode`, `brute_force_login`, `load_skill_reference`, `evidence_list`, `evidence_search`, `evidence_view`, etc.) — no MCP needed.

<details>
<summary><strong>Chrome DevTools MCP Setup</strong></summary>

**Prerequisites**: Node.js LTS (v20+) + Chrome browser

```bash
# Step 1: Start Chrome with remote debugging
# Windows
"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir=C:\tmp\chrome-debug
# Linux/Mac
google-chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug

# Step 2: Enable in CyberClaw
cyberclaw config set mcp.servers.chrome-devtools.enabled true
```

Custom Chrome debug address — edit `~/.cyberclaw/config.yaml`:

```yaml
mcp:
  servers:
    chrome-devtools:
      enabled: true
      transport:
        type: stdio
        command: npx
        args: ["-y", "chrome-devtools-mcp@latest", "--browser-url=http://127.0.0.1:9222"]
```

</details>

<details>
<summary><strong>Burp Suite MCP Setup</strong></summary>

**Prerequisites**: Java 11+ + Burp Suite Professional

```bash
# Step 1: Clone and build
git clone https://github.com/PortSwigger/mcp-server.git burp-mcp
cd burp-mcp
./gradlew embedProxyJar    # Windows: gradlew.bat embedProxyJar

# Step 2: Load into Burp Suite → Extensions → Add → Type: Java → select burp-mcp-all.jar

# Step 3: Enable in Burp's MCP tab

# Step 4: Enable in CyberClaw
cyberclaw config set mcp.servers.burp.enabled true
```

Recommended config:

```yaml
mcp:
  servers:
    burp:
      enabled: true
      transport:
        type: stdio
        command: java
        args: ["-jar", "~/.cyberclaw/tools/burp-mcp-all.jar", "--sse-url", "http://127.0.0.1:9876"]
```

</details>

> See [docs/mcp-deployment.md](docs/mcp-deployment.md) for detailed setup instructions.

---

## Built-in Skills

### Core Skills (7)

| Skill | Description |
|-------|-------------|
| pentest-flow | Full pentest workflow orchestration |
| recon | Information gathering |
| vuln-discovery | Vulnerability discovery |
| exploitation | Exploitation |
| post-exploitation | Post-exploitation |
| reporting | Report generation |
| waf-bypass | WAF bypass techniques |

### Specialized Skills (16)

| Skill | Ref Docs | Description |
|-------|----------|-------------|
| web-pentest | 3 | Web application pentesting |
| android-pentest | 9 | Android application pentesting |
| client-reverse | 20 | Client-side reverse engineering |
| web-security-advanced | 33 | Advanced web security (injection, bypass, chains) |
| ai-mcp-security | 7 | AI/MCP security testing |
| intranet-pentest-advanced | 15 | Advanced internal network pentesting |
| pentest-tools | 16 | Pentest tool quick reference |
| rapid-checklist | 2 | Rapid validation checklists |
| crypto-toolkit | 3 | Encode/decode/crypto (29 ops) |
| **ctf-web** | 8 | CTF Web attacks (PHP bypass/RCE/SSTI/deserialization) |
| **ctf-crypto** | 6 | CTF cryptography (RSA/AES/ECC/PRNG/lattice attacks) |
| **ctf-misc** | 6 | CTF Misc (PyJail/BashJail/encoding chains/VM RE) |
| **osint-recon** | 7 | OSINT four-dimension model (server/web/domain/person) |
| **cve-triage** | 1 | CVE lookup and triage |
| **hackerone** | 1 | HackerOne bounty scope-guard |
| **secknowledge-skill** | 40 | Web+AI security testing knowledge base |

Skills are resolved from user input into an optional reference index. CyberClaw does not automatically inject skill bodies, phase workflows, or methodology scripts into the system prompt. Specialized skills include detailed methodology documents in `references/`, and the model loads them only when it chooses to call `load_skill_reference`.

### Built-in Encode/Decode & Crypto Tool (`crypto_decode`)

| Category | Operations |
|----------|------------|
| Encoding | base64, base32, base58, hex, url, html, unicode, rot13, caesar, morse (each with encode/decode) |
| Hashing | md5, sha1, sha256, sha512 |
| Encrypt | aes_encrypt, aes_decrypt (CBC mode, PKCS7 padding) |
| JWT | jwt_decode, jwt_encode |
| Auto | auto_decode — tries all common encodings, returns matching results |

---

## Configuration

### LLM Providers

```bash
cyberclaw config provider --list    # list all providers
cyberclaw config provider minimax   # one-command switch
```

| Provider | Command | Default Model |
|----------|---------|---------------|
| OpenAI | `provider openai` | gpt-5.6-sol |
| Anthropic Claude | `provider anthropic` | claude-opus-5 |
| MiniMax | `provider minimax` | MiniMax-M3 |
| DeepSeek | `provider deepseek` | deepseek-v4-pro |
| Zhipu GLM | `provider zhipu` | glm-5.3 |
| Kimi | `provider moonshot` | kimi-k3 |
| Qwen | `provider qwen` | qwen3.8-max |
| SiliconFlow | `provider siliconflow` | deepseek-ai/DeepSeek-V4-Flash |
| Doubao | `provider doubao` | doubao-seed-evolving |
| StepFun | `provider stepfun` | step-3.7-flash |
| SenseTime | `provider sensetime` | SenseNova-V6.5-Pro |
| OpenRouter | `provider openrouter` | anthropic/claude-opus-5 |
| Ollama (local) | `provider ollama` | qwen3.5:9b |
| Custom | `provider custom` | manual |

### CLI Configuration

```bash
cyberclaw config list                          # view all settings
cyberclaw config get llm.model                 # view single setting
cyberclaw config set llm.api_key sk-xx         # set API key
cyberclaw config set session.max_rounds 30     # set max rounds (default 15)
cyberclaw config set session.show_thinking false  # hide thinking process
```

### Execution Approvals (unattended execution)

Dangerous tools (shell / python / PoC) prompt `Approve this execution? [y/N]` before every run by default. Three ways to change that:

```bash
# 1. Persist to config (recommended)
cyberclaw config set safety.permission_mode full_access

# 2. Current REPL session only (falls back to the config file after restart)
mode full_access          # switch; without an argument, show the current mode

# 3. Single run
CYBERCLAW_SAFETY_PERMISSION_MODE=full_access cyberclaw solve <target>
```

| Mode | Behavior |
|------|----------|
| `ask` (default) | Every execution prompts y/N; unanswered prompts auto-deny after 300 s (`safety.approval_timeout_seconds`) |
| `auto_review` | Read-only allowlist commands (ls / cat / nmap scans, etc.) run unattended, everything else still prompts; extend via `safety.trusted_commands` prefixes |
| `full_access` | Everything runs unattended, no prompts |

> ⚠️ Under `full_access`, target responses, page content and reports are untrusted input — prompt injection can drive unconfirmed arbitrary command execution. Reserve it for isolated labs, CTFs and throwaway VMs; for real engagements prefer `auto_review` plus your own trusted prefixes.

### Configurable Options

| Option | Default | Description |
|--------|---------|-------------|
| `llm.provider` | openai | LLM provider |
| `llm.api_key` | empty | API key |
| `llm.auth_mode` | static | `static` or `oauth` |
| `llm.chatgpt_auto_proxy` | false | Auto-start built-in ChatGPT bridge proxy |
| `llm.base_url` | per provider | API base URL |
| `llm.model` | per provider | Model name |
| `llm.temperature` | 0.1 | Sampling temperature |
| `llm.max_tokens` | 4096 | Max output tokens |
| `session.engine` | solve | `solve` (model-led) / `team` (role team) / `rounds` (legacy fixed-round) |
| `session.solve_max_steps` | 240 | Runaway safety budget for solve; not a planned round count |
| `session.solve_max_directions` | 3 | Deprecated compatibility field; model-led solve no longer uses research direction counts |
| `session.solve_max_tool_rounds` | 6 | Compatibility safety cap for consecutive tool follow-ups inside one model turn; not a planned workflow length |
| `session.solve_auto_compact` | false | Deprecated; use `context_auto_compact` instead |
| `session.solve_compact_trigger_ratio` | 0.9 | Deprecated; use `context_compact_trigger_ratio` instead |
| `session.context_auto_compact` | true | Enable automatic structured context compaction |
| `session.context_compact_trigger_ratio` | 0.70 | Context usage ratio that triggers auto-compaction |
| `session.context_compact_target_ratio` | 0.55 | Post-compaction target ratio of usable context |
| `session.context_recent_message_groups` | 12 | Minimum complete message groups retained after compaction |
| `session.context_summary_max_tokens` | 3500 | Max tokens for the structured context digest |
| `session.context_output_reserve_tokens` | 0 | Output token reserve (0 = auto: min(max_tokens, 8192)) |
| `session.context_compaction_mode` | structured | Compaction strategy (only `structured` supported) |
| `session.context_hot_max_messages` | 48 | Max messages retained in hot conversation memory |
| `session.context_hot_max_tokens` | 32000 | Approximate token cap for hot conversation memory |
| `session.memory_search_max_chars` | 6000 | Max characters returned by one cold-memory search |
| `session.memory_archive_max_bytes` | 67108864 | Rotate cold-memory JSONL shard after this many bytes |
| `session.memory_archive_max_files` | 8 | Max cold-memory JSONL shards retained per output directory |
| `subagent.enabled` | true | Expose `spawn_subagents` tool to the model-led solve engine |
| `subagent.max_background_groups` | 3 | Max concurrent sub-agent groups per solve turn |
| `subagent.max_concurrent_leaf_total` | 4 | Max concurrent leaf agents across all groups |
| `subagent.max_leaf_per_group` | 6 | Max leaf agents per group |
| `subagent.max_steps_per_leaf` | 12 | Max solve steps per leaf agent |
| `subagent.leaf_max_tool_rounds` | 4 | Max tool follow-up rounds per leaf agent |
| `subagent.max_model_tokens_per_solve` | 8000000 | Solve-wide model-token ceiling for all descendant agents |
| `subagent.max_model_tokens_per_group` | 1000000 | Shared token ceiling for one Leader and all its leaves |
| `session.solve_auto_report` | true | Generate a Markdown replay report when solve completes |
| `session.solve_report_show` | true | Print the generated solve report body in the terminal |
| `session.max_rounds` | 15 | Max rounds |
| `session.output_dir` | ./cyberclaw-output | Report output directory |
| `session.report_format` | markdown | Report format (markdown / html) |
| `session.poc_language` | python | PoC language (python / bash) |
| `session.language` | auto | UI language (auto / zh / en), defaults to English |
| `session.show_thinking` | false | Show LLM reasoning |
| `session.persistent_rounds_per_cycle` | 100 | Rounds per cycle in persistent mode |
| `session.persistent_max_cycles` | 10 | Max cycles (0=unlimited) |
| `session.persistent_auto_report` | true | Auto-report after each cycle |
| `session.stale_rounds_threshold` | 5 | Dead-loop detection threshold |
| `safety.permission_mode` | ask | Execution approval policy for dangerous tools: `ask` (default, y/N per request), `auto_review` (read-only allowlist runs unattended, rest still prompt), `full_access` (everything runs, no prompts) |
| `safety.approval_timeout_seconds` | 300 | How long an unanswered execution approval waits before auto-denying |
| `safety.trusted_commands` | empty | auto_review prefixes that skip per-request approval (e.g. `nmap`, `git diff`); entries starting with a banned name are refused |
| `safety.enable_python_execute` | true | Enable the python_execute built-in tool (disable for safer runs) |
| `safety.python_execute_max_lines` | 50 | Max lines of code allowed per python_execute call |
| `safety.python_execute_show_warning` | true | Show a security warning before each python_execute invocation |
| `safety.python_execute_audit_enabled` | true | Write python_execute audit records to the local config directory |

### Environment Variables

| Variable | Description |
|----------|-------------|
| `CYBERCLAW_LLM_PROVIDER` | LLM provider name |
| `CYBERCLAW_LLM_API_KEY` | API key |
| `CYBERCLAW_LLM_AUTH_MODE` | static / oauth |
| `CYBERCLAW_LLM_CHATGPT_AUTO_PROXY` | Built-in ChatGPT proxy |
| `CYBERCLAW_LLM_BASE_URL` | API base URL |
| `CYBERCLAW_LLM_MODEL` | Model name |
| `CYBERCLAW_SESSION_MAX_ROUNDS` | Max rounds |
| `CYBERCLAW_SESSION_STALE_ROUNDS_THRESHOLD` | Dead-loop threshold |
| `CYBERCLAW_SESSION_REASONING_STATE_ENABLED` | Structured reasoning toggle |
| `CYBERCLAW_SESSION_REFLEXION_ENABLED` | Adaptive reflection toggle |
| `CYBERCLAW_SESSION_REFLEXION_MAX_SAME_VULN_FAILS` | Same-vuln failure trigger threshold |
| `CYBERCLAW_SESSION_ESCALATION_MAX_LEVEL` | Payload escalation cap (0-4) |
| `CYBERCLAW_SESSION_PLUGIN_RUNTIME_ENABLED` | Plugin runtime toggle |
| `CYBERCLAW_SESSION_PLUGIN_MAX_REQUESTS_PER_TARGET` | Per-target plugin request budget |
| `CYBERCLAW_SAFETY_PERMISSION_MODE` | Execution approval mode (ask / auto_review / full_access) |
| `CYBERCLAW_SAFETY_APPROVAL_TIMEOUT_SECONDS` | Execution approval wait seconds |
| `CYBERCLAW_SAFETY_TRUSTED_COMMANDS` | auto_review trusted command prefixes (comma-separated) |
| `CYBERCLAW_SUBAGENT_ENABLED` | Sub-agent fan-out toggle |
| `CYBERCLAW_SUBAGENT_MAX_BACKGROUND_GROUPS` | Max concurrent sub-agent groups per solve turn |
| `CYBERCLAW_SUBAGENT_MAX_CONCURRENT_LEAF_TOTAL` | Max concurrent leaf agents across all groups |
| `CYBERCLAW_SUBAGENT_MAX_LEAF_PER_GROUP` | Max leaf agents per group |
| `CYBERCLAW_SUBAGENT_MAX_STEPS_PER_LEAF` | Max solve steps per leaf agent |
| `CYBERCLAW_SUBAGENT_LEAF_MAX_TOOL_ROUNDS` | Max tool follow-up rounds per leaf agent |
| `CYBERCLAW_SUBAGENT_LEAF_TIMEOUT_SECONDS` | Per-leaf solve timeout (seconds) |
| `CYBERCLAW_SUBAGENT_GROUP_TIMEOUT_SECONDS` | Per-group timeout (seconds) |
| `CYBERCLAW_SUBAGENT_MAX_MODEL_TOKENS_PER_SOLVE` | Solve-wide model-token ceiling |
| `CYBERCLAW_SUBAGENT_MAX_MODEL_TOKENS_PER_GROUP` | Per-group model-token ceiling |

Priority: **Environment Variables > Config File > Built-in Defaults**

Config file: `~/.cyberclaw/config.yaml`.

---

## Changelog

See [CHANGELOG.md](CHANGELOG.md) for full version history.

---

## Contributing

Contributions are welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) before submitting a pull request.

All pull requests should target the `main` branch.

---

## Security Notice

**Public alpha:** CyberClaw is public alpha software for authorized security testing, CTFs, labs, and controlled research. It is not a production security control or a replacement for human authorization. See [SECURITY.md](SECURITY.md) before using or reporting security issues.

CyberClaw is intended **solely for authorized security testing**. Before using this tool, ensure:

1. You have **explicit authorization** for the target system
2. Scope has been **confirmed in writing** with the target owner
3. You comply with all applicable **local laws and regulations**

Unauthorized penetration testing is illegal. The author assumes no liability for misuse.

---

## License

[MIT License](LICENSE)

---

<div align="center">

> 🦞 **CyberClaw** — Every pentest should follow a process.

</div>
