ctf-agent 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +131 -0
- package/Dockerfile +192 -0
- package/README.md +522 -0
- package/agents/ctf-analyzer.md +58 -0
- package/agents/ctf-controller.md +151 -0
- package/agents/ctf-speedrun.md +74 -0
- package/bin/ctf-agent.js +119 -0
- package/docker-compose.yml +13 -0
- package/mcp_config.json +19 -0
- package/package.json +44 -0
- package/references/ctf-triage-ladder.md +68 -0
- package/references/exploit-databases.md +575 -0
- package/references/llm-safety-and-policy-compliance.md +173 -0
- package/references/multi-agent-orchestration-and-policy-routing.md +278 -0
- package/references/security-events-and-intelligence.md +566 -0
- package/references/version-matrix.md +59 -0
- package/rules/ctf-execution-rules.md +44 -0
- package/rules/ctf-safety-framing-rules.md +140 -0
- package/rules/flag-validation-rules.md +25 -0
- package/scripts/__init__.py +1 -0
- package/scripts/ctf-tools.lock +205 -0
- package/scripts/ctf_init.py +1026 -0
- package/scripts/ctf_update.py +583 -0
- package/scripts/ctfd_client.py +81 -0
- package/scripts/cve_lookup.py +453 -0
- package/scripts/extract_flags.py +155 -0
- package/scripts/install_as_agent.py +278 -0
- package/scripts/install_ctf_tools.sh +603 -0
- package/scripts/parallel_triage.py +395 -0
- package/scripts/prompt_policy_sanitizer.py +283 -0
- package/scripts/scope_guard.py +444 -0
- package/scripts/skill_validator.py +504 -0
- package/scripts/workspace_cleaner.py +141 -0
- package/skills/ctf-ai-ml/SKILL.md +120 -0
- package/skills/ctf-ai-ml/adversarial-ml.md +623 -0
- package/skills/ctf-ai-ml/llm-attacks.md +487 -0
- package/skills/ctf-ai-ml/model-attacks.md +422 -0
- package/skills/ctf-crypto/SKILL.md +320 -0
- package/skills/ctf-crypto/advanced-math.md +798 -0
- package/skills/ctf-crypto/classic-ciphers.md +651 -0
- package/skills/ctf-crypto/ecc-attacks.md +347 -0
- package/skills/ctf-crypto/exotic-crypto-2.md +380 -0
- package/skills/ctf-crypto/exotic-crypto.md +528 -0
- package/skills/ctf-crypto/historical.md +113 -0
- package/skills/ctf-crypto/lattice-and-lwe.md +524 -0
- package/skills/ctf-crypto/modern-ciphers-2.md +563 -0
- package/skills/ctf-crypto/modern-ciphers-3.md +453 -0
- package/skills/ctf-crypto/modern-ciphers.md +649 -0
- package/skills/ctf-crypto/prng-attacks.md +257 -0
- package/skills/ctf-crypto/prng.md +664 -0
- package/skills/ctf-crypto/rsa-attacks-2.md +792 -0
- package/skills/ctf-crypto/rsa-attacks.md +487 -0
- package/skills/ctf-crypto/stream-ciphers.md +390 -0
- package/skills/ctf-crypto/zkp-and-advanced.md +456 -0
- package/skills/ctf-forensics/3d-printing.md +121 -0
- package/skills/ctf-forensics/SKILL.md +379 -0
- package/skills/ctf-forensics/disk-advanced.md +497 -0
- package/skills/ctf-forensics/disk-and-memory.md +491 -0
- package/skills/ctf-forensics/disk-recovery.md +699 -0
- package/skills/ctf-forensics/linux-forensics.md +511 -0
- package/skills/ctf-forensics/network-advanced.md +583 -0
- package/skills/ctf-forensics/network.md +645 -0
- package/skills/ctf-forensics/peripheral-capture.md +287 -0
- package/skills/ctf-forensics/signals-and-hardware.md +713 -0
- package/skills/ctf-forensics/steganography.md +694 -0
- package/skills/ctf-forensics/stego-advanced-2.md +475 -0
- package/skills/ctf-forensics/stego-advanced.md +481 -0
- package/skills/ctf-forensics/stego-image.md +691 -0
- package/skills/ctf-forensics/windows.md +625 -0
- package/skills/ctf-malware/SKILL.md +181 -0
- package/skills/ctf-malware/c2-and-protocols.md +274 -0
- package/skills/ctf-malware/pe-and-dotnet.md +108 -0
- package/skills/ctf-malware/scripts-and-obfuscation.md +449 -0
- package/skills/ctf-misc/SKILL.md +498 -0
- package/skills/ctf-misc/bashjails.md +323 -0
- package/skills/ctf-misc/ctfd-navigation.md +465 -0
- package/skills/ctf-misc/dns.md +255 -0
- package/skills/ctf-misc/encodings-advanced.md +504 -0
- package/skills/ctf-misc/encodings.md +431 -0
- package/skills/ctf-misc/games-and-vms-2.md +254 -0
- package/skills/ctf-misc/games-and-vms-3.md +690 -0
- package/skills/ctf-misc/games-and-vms-4.md +229 -0
- package/skills/ctf-misc/games-and-vms.md +529 -0
- package/skills/ctf-misc/linux-privesc.md +333 -0
- package/skills/ctf-misc/pyjails.md +671 -0
- package/skills/ctf-misc/rf-sdr.md +91 -0
- package/skills/ctf-osint/SKILL.md +198 -0
- package/skills/ctf-osint/geolocation-and-media.md +464 -0
- package/skills/ctf-osint/social-media.md +312 -0
- package/skills/ctf-osint/web-and-dns.md +341 -0
- package/skills/ctf-pwn/SKILL.md +214 -0
- package/skills/ctf-pwn/advanced-exploits-2.md +579 -0
- package/skills/ctf-pwn/advanced-exploits-3.md +598 -0
- package/skills/ctf-pwn/advanced-exploits-4.md +590 -0
- package/skills/ctf-pwn/advanced-exploits-5.md +119 -0
- package/skills/ctf-pwn/advanced-exploits.md +773 -0
- package/skills/ctf-pwn/advanced.md +326 -0
- package/skills/ctf-pwn/field-notes.md +245 -0
- package/skills/ctf-pwn/format-string.md +694 -0
- package/skills/ctf-pwn/heap-fsop.md +285 -0
- package/skills/ctf-pwn/heap-techniques-2.md +333 -0
- package/skills/ctf-pwn/heap-techniques.md +513 -0
- package/skills/ctf-pwn/kernel-bypass.md +421 -0
- package/skills/ctf-pwn/kernel-techniques.md +366 -0
- package/skills/ctf-pwn/kernel.md +636 -0
- package/skills/ctf-pwn/overflow-basics.md +611 -0
- package/skills/ctf-pwn/rop-advanced.md +725 -0
- package/skills/ctf-pwn/rop-and-shellcode.md +659 -0
- package/skills/ctf-pwn/sandbox-escape.md +313 -0
- package/skills/ctf-reverse/SKILL.md +163 -0
- package/skills/ctf-reverse/anti-analysis-ctf.md +204 -0
- package/skills/ctf-reverse/anti-analysis.md +693 -0
- package/skills/ctf-reverse/field-notes.md +376 -0
- package/skills/ctf-reverse/languages-compiled.md +666 -0
- package/skills/ctf-reverse/languages-platforms.md +592 -0
- package/skills/ctf-reverse/languages.md +553 -0
- package/skills/ctf-reverse/patterns-ctf-2.md +397 -0
- package/skills/ctf-reverse/patterns-ctf-3.md +797 -0
- package/skills/ctf-reverse/patterns-ctf.md +670 -0
- package/skills/ctf-reverse/patterns-runtime.md +274 -0
- package/skills/ctf-reverse/patterns.md +572 -0
- package/skills/ctf-reverse/platforms-hardware.md +387 -0
- package/skills/ctf-reverse/platforms.md +664 -0
- package/skills/ctf-reverse/tools-advanced-2.md +421 -0
- package/skills/ctf-reverse/tools-advanced.md +407 -0
- package/skills/ctf-reverse/tools-dynamic.md +679 -0
- package/skills/ctf-reverse/tools-emulation.md +319 -0
- package/skills/ctf-reverse/tools.md +573 -0
- package/skills/ctf-web/SKILL.md +153 -0
- package/skills/ctf-web/auth-and-access-2.md +82 -0
- package/skills/ctf-web/auth-and-access.md +783 -0
- package/skills/ctf-web/auth-infra.md +321 -0
- package/skills/ctf-web/auth-jwt.md +186 -0
- package/skills/ctf-web/client-side-advanced.md +739 -0
- package/skills/ctf-web/client-side.md +529 -0
- package/skills/ctf-web/cves.md +373 -0
- package/skills/ctf-web/field-notes.md +482 -0
- package/skills/ctf-web/node-and-prototype.md +200 -0
- package/skills/ctf-web/server-side-2.md +337 -0
- package/skills/ctf-web/server-side-advanced-2.md +559 -0
- package/skills/ctf-web/server-side-advanced-3.md +125 -0
- package/skills/ctf-web/server-side-advanced-4.md +480 -0
- package/skills/ctf-web/server-side-advanced.md +378 -0
- package/skills/ctf-web/server-side-deser.md +443 -0
- package/skills/ctf-web/server-side-exec-2.md +799 -0
- package/skills/ctf-web/server-side-exec.md +457 -0
- package/skills/ctf-web/server-side.md +629 -0
- package/skills/ctf-web/sql-injection.md +790 -0
- package/skills/ctf-web/web3.md +374 -0
- package/skills/ctf-writeup/SKILL.md +90 -0
- package/skills/solve-challenge/SKILL.md +269 -0
- package/skills.json +16 -0
package/README.md
ADDED
|
@@ -0,0 +1,522 @@
|
|
|
1
|
+
# CTF-Agent: Autonomous Security Intelligence & Competitive Exploitation Framework
|
|
2
|
+
|
|
3
|
+
> **A High-Performance AI Agent Architecture for Live CTF Competitions, Lab Vulnerability Audits, and Security Research.**
|
|
4
|
+
> Compatible with **Antigravity IDE**, **Cursor**, **Claude Code**, and **OpenAI Codex/Agent** ecosystems.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Quick Navigation
|
|
9
|
+
|
|
10
|
+
- [CRITICAL: Environment Backend Selection (WSL vs Docker)](#critical-environment-backend-selection-wsl-vs-docker)
|
|
11
|
+
- [Operational Modes: Blitz vs Deep Analysis](#operational-modes-blitz-vs-deep-analysis)
|
|
12
|
+
- [LLM Safety Guardrails & Policy Compliance](#llm-safety-guardrails--policy-compliance)
|
|
13
|
+
- [Machine-Enforced Scope Guard](#machine-enforced-scope-guard-runtime-execution-boundary)
|
|
14
|
+
- [Specialized Category Skills](#specialized-category-skills)
|
|
15
|
+
- [Parallel Triage & High-Speed Reconnaissance](#parallel-triage--high-speed-reconnaissance-p0-engine)
|
|
16
|
+
- [Quick Start & Workspace Installation](#quick-start--workspace-installation)
|
|
17
|
+
- [References & Deep Knowledge Base](#references--deep-knowledge-base)
|
|
18
|
+
- [Constitution & Architectural Governance](#constitution--architectural-governance)
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## CRITICAL: Environment Backend Selection (WSL vs Docker)
|
|
23
|
+
|
|
24
|
+
> [!CAUTION]
|
|
25
|
+
> ### ANTI-DISK-OVERFLOW RULE (DO NOT INITIALIZE BOTH ENVIRONMENTS!)
|
|
26
|
+
> **DO NOT build the Docker container AND install the full WSL toolchain at the same time.**
|
|
27
|
+
> Installing full multi-tier CTF tools (compilers, SMT solvers, `sagemath`, `pwntools`, `angr`, `torch`, `volatility3`, `hashcat`) requires **15 to 25 GB of disk space per environment**.
|
|
28
|
+
> Initializing **BOTH** will consume **30 to 50 GB+**, risking catastrophic host drive exhaustion and environment conflicts.
|
|
29
|
+
>
|
|
30
|
+
> **AI Agents & Players MUST detect and choose EXACTLY ONE backend:**
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
┌─────────────────────────────┐
|
|
34
|
+
│ Choose ONE Backend Engine │
|
|
35
|
+
└──────────────┬──────────────┘
|
|
36
|
+
│
|
|
37
|
+
┌──────────────────────────────┴──────────────────────────────┐
|
|
38
|
+
▼ ▼
|
|
39
|
+
[OPTION A: WSL Kali Linux] [OPTION B: Docker Sandbox]
|
|
40
|
+
Best for: Windows Host Development Best for: Linux, macOS, or CI/CD
|
|
41
|
+
- Zero VM overhead, fast host I/O - 100% ephemeral and disposable
|
|
42
|
+
- Direct file access via /mnt/c/Users/... - Clean host isolation
|
|
43
|
+
- Direct GUI/GDB debugging support - Standardized container image
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Option A: WSL Kali Linux (Recommended on Windows)
|
|
47
|
+
1. **Verify WSL Kali Availability**:
|
|
48
|
+
```powershell
|
|
49
|
+
wsl -d kali-linux uname -a
|
|
50
|
+
```
|
|
51
|
+
2. **Install CTF Toolchain Inside WSL (Select Profiles to Save Disk)**:
|
|
52
|
+
```bash
|
|
53
|
+
# Inside WSL or wrapped from PowerShell:
|
|
54
|
+
wsl -d kali-linux bash -c "bash scripts/install_ctf_tools.sh core"
|
|
55
|
+
# To install specific profiles: pwn, rev, crypto, web, forensics
|
|
56
|
+
wsl -d kali-linux bash -c "bash scripts/install_ctf_tools.sh pwn crypto web"
|
|
57
|
+
```
|
|
58
|
+
3. **Execution Wrapper**:
|
|
59
|
+
```powershell
|
|
60
|
+
wsl -d kali-linux bash -c "source ~/.ctf-tools/venv/bin/activate && <command>"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Option B: Docker Container Sandbox (Recommended on Linux / macOS / CI)
|
|
64
|
+
1. **Build Container Image**:
|
|
65
|
+
```bash
|
|
66
|
+
docker compose build
|
|
67
|
+
```
|
|
68
|
+
2. **Execute Inside Container Sandbox**:
|
|
69
|
+
```bash
|
|
70
|
+
docker compose run --rm ctf-agent <command>
|
|
71
|
+
```
|
|
72
|
+
3. **Interactive Shell**:
|
|
73
|
+
```bash
|
|
74
|
+
docker compose run --rm ctf-agent /bin/bash
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Operational Profiles & Specialized Modes (Text Flags)
|
|
80
|
+
|
|
81
|
+
> [!TIP]
|
|
82
|
+
> ### HOW MODES WORK (PROMPT TEXT FLAGS)
|
|
83
|
+
> Operational modes (`--fast`, `--blitz`, `--deep`, `--lab`) are **instructional text flags** recognized by the Agent through [AGENTS.md](AGENTS.md).
|
|
84
|
+
> **How to use**: Simply write the flags as plain text in your chat prompt or combine them with slash commands (e.g. `/ctf-web --fast <url>` or `/solve-challenge --mode blitz <dir>`).
|
|
85
|
+
> *(Note: In Antigravity IDE, typing `@` searches files/symbols in the workspace; modes are passed directly as text flags in your prompt text).*
|
|
86
|
+
|
|
87
|
+
`CTF-Agent` provides 3 specialized agent personas designed to eliminate multi-agent refusal cascades and optimize for both speedrun competitions and deep lab audits:
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
┌─────────────────────────────────────────────────────────────────────────────────────────────────┐
|
|
91
|
+
│ CTF-AGENT PERSONA MATRIX │
|
|
92
|
+
├──────────────────────────┬───────────────────────────────┬──────────────────────────────────────┤
|
|
93
|
+
│ MASTER ORCHESTRATOR │ BLITZ / SPEEDRUN SOLVER │ DEEP RESEARCH AUDITOR │
|
|
94
|
+
│ @ctf-controller │ @ctf-speedrun (--blitz) │ @ctf-analyzer (--deep) │
|
|
95
|
+
├──────────────────────────┼───────────────────────────────┼──────────────────────────────────────┤
|
|
96
|
+
│ Role: State Controller │ Role: First Blood Hunter │ Role: Security Auditor / RCA │
|
|
97
|
+
│ Enforces: Shallow depth │ Stop Condition: On Flag HALT │ Stop Condition: Verified Writeup │
|
|
98
|
+
│ Context: SCO & Envelope │ Documentation: ZERO overhead │ Documentation: 5-Section writeup │
|
|
99
|
+
│ Refusal: 3-Tier Router │ Workspace: Auto-purge debris │ Workspace: Organize resources/ │
|
|
100
|
+
│ Fallback: Deterministic │ Output: Verified Flag Banner │ Output: Authoritative RCA report │
|
|
101
|
+
└──────────────────────────┴───────────────────────────────┴──────────────────────────────────────┘
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### 1. Master Controller (`@ctf-controller` / `/solve-challenge`)
|
|
105
|
+
Use as the primary entrypoint for complex multi-step labs or challenges.
|
|
106
|
+
- **Prompt Examples**:
|
|
107
|
+
- `/solve-challenge http://challenge.ctf.site:8000`
|
|
108
|
+
- `/solve-challenge ./challenge_directory`
|
|
109
|
+
- **Security Context & Task Envelope**: Wraps target endpoints or local lab files in machine-readable context objects (`security_context`, `task_envelope`) to prevent subagents from evaluating prompts with zero inherited context.
|
|
110
|
+
- **Shallow Orchestration (Depth = 1)**: Dispatches directly to a single specialist skill or agent. Prohibits deep recursive agent chaining (`Agent A -> Agent B -> Agent C`).
|
|
111
|
+
- **3-Tier Refusal Router**: Automatically classifies model refusals (Type A Wording, Type B Ambiguity, Type C Hard Policy) and shifts execution immediately to deterministic CLI tools without entering infinite paraphrasing loops.
|
|
112
|
+
|
|
113
|
+
### 2. Blitz / Speedrun Mode (`@ctf-speedrun` / `--blitz` / `--fast`)
|
|
114
|
+
Use during active CTF competitions where time is points.
|
|
115
|
+
- **Prompt Examples**:
|
|
116
|
+
- `/ctf-web --fast http://challenge.ctf.site:8080`
|
|
117
|
+
- `/solve-challenge --mode blitz ./pwn_challenge`
|
|
118
|
+
- `--blitz Solve this crypto puzzle: c = 12345, e = 3, n = 99999`
|
|
119
|
+
- **Stop-on-Flag (HALT immediately)**: The instant a valid flag matching target regex (`flag{...}`, `picoCTF{...}`) is confirmed, all tool invocations and probing **stop immediately**.
|
|
120
|
+
- **High-Visibility Flag Banner**:
|
|
121
|
+
```text
|
|
122
|
+
============================================================
|
|
123
|
+
[+] FLAG ACQUIRED: picoCTF{example_flag_value}
|
|
124
|
+
Confidence: 100% | Source: HTTP 200 Response
|
|
125
|
+
============================================================
|
|
126
|
+
```
|
|
127
|
+
- **Automated Workspace Cleanup**:
|
|
128
|
+
```bash
|
|
129
|
+
python3 scripts/workspace_cleaner.py --fast
|
|
130
|
+
```
|
|
131
|
+
Automatically removes temporary scratch files (`test*.py`, `fuzz*.py`, `tmp*`, `core.*`, `payload*.bin`), keeping only the original challenge files and the winning `solve.py`.
|
|
132
|
+
- **Zero Overhead**: Does **not** invoke `ctf-writeup` and does **not** create `writeup.md`.
|
|
133
|
+
|
|
134
|
+
### 3. Deep Analysis / Lab Mode (`@ctf-analyzer` / `--deep` / `--lab`)
|
|
135
|
+
Use when solving challenge labs (HackTheBox, PortSwigger, pwnable.tw), post-mortems, or security research.
|
|
136
|
+
- **Prompt Examples**:
|
|
137
|
+
- `/ctf-pwn --deep ./vulnerable_binary`
|
|
138
|
+
- `/solve-challenge --mode deep ./web_lab`
|
|
139
|
+
- `--lab Perform deep root cause analysis and generate writeup`
|
|
140
|
+
- **Root Cause Analysis (RCA)**: Deep analysis of memory corruption layouts, AST flaws, or cryptographic mathematical proofs.
|
|
141
|
+
- **Directory Standardization**:
|
|
142
|
+
```bash
|
|
143
|
+
python3 scripts/workspace_cleaner.py --deep
|
|
144
|
+
```
|
|
145
|
+
Enforces clean lab layout: only `writeup.md`, `solve.py`, and a `resources/` folder containing all challenge binaries, PCAPs, dumps, and source archives.
|
|
146
|
+
- **Standardized Writeup**: Automatically invokes `ctf-writeup` to author a publication-ready 5-section `writeup.md`.
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## LLM Safety Guardrails & Policy Compliance (Prompt Sanitization & Guardrail Navigation)
|
|
151
|
+
|
|
152
|
+
When working on cybersecurity labs (HackTheBox, TryHackMe, PortSwigger) or participating in CTF competitions, user prompts and challenge descriptions often contain aggressive adversarial terminology (`exploit`, `attack`, `bypass policy`, `reverse shell`, `weaponize`...). Modern backend LLM safety classifiers (Gemini, Claude, GPT) can mistakenly flag these requests as unauthorized intrusions and **prematurely halt agent execution mid-lab**.
|
|
153
|
+
|
|
154
|
+
`CTF-Agent` integrates an authorized educational framing standard and an automated **Prompt Policy Sanitizer** to eliminate false-positive policy blocks while preserving 100% technical solving capabilities:
|
|
155
|
+
|
|
156
|
+
### 1. How to Apply in Labs & CTF Competitions
|
|
157
|
+
|
|
158
|
+
Before submitting complex prompts or challenge descriptions to the Agent, run the sanitizer utility to automatically rewrite the text into safe academic phrasing and attach the authorized educational context preamble:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# Sanitize an input prompt with high-risk keywords:
|
|
162
|
+
python scripts/prompt_policy_sanitizer.py "Write an exploit payload to bypass security policy and extract the flag"
|
|
163
|
+
|
|
164
|
+
# Sanitize a prompt with specific language support:
|
|
165
|
+
python scripts/prompt_policy_sanitizer.py "Write script to bypass filter and capture flag" --lang en
|
|
166
|
+
|
|
167
|
+
# Scan and sanitize an entire challenge prompt file or writeup:
|
|
168
|
+
python scripts/prompt_policy_sanitizer.py --file path/to/prompt.txt --check
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### 2. Automated Sanitization Mechanism
|
|
172
|
+
|
|
173
|
+
- **Risk Scoring**: Assesses policy risk from `SAFE` (0) to `CRITICAL` (100) across 5 high-risk trigger families (Evasion, Redteam, Exploit, Payload, Exfiltration).
|
|
174
|
+
- **Academic Lexicon Standard**: Automatically replaces adversarial attack jargon with defensive and diagnostic testing equivalents:
|
|
175
|
+
- *exploit vulnerability* -> *verify vulnerability with proof-of-concept (PoC)*
|
|
176
|
+
- *bypass policy* -> *evaluate mitigation boundaries*
|
|
177
|
+
- *steal credentials / exfiltrate* -> *retrieve challenge flag token*
|
|
178
|
+
- *redteam attack* -> *diagnostic security assessment*
|
|
179
|
+
- **Educational CTF Context Preamble**: Injects explicit authorized testing boundaries (`localhost`, Docker, designated CTF target) to satisfy upstream safety filters.
|
|
180
|
+
- **Path & Link Preservation**: Automatically preserves markdown links `[text](target.md)` and URLs without unwanted corruption.
|
|
181
|
+
|
|
182
|
+
For comprehensive guidelines and full replacement dictionaries, see [ctf-safety-framing-rules.md](rules/ctf-safety-framing-rules.md) and [llm-safety-and-policy-compliance.md](references/llm-safety-and-policy-compliance.md).
|
|
183
|
+
|
|
184
|
+
### 3. Machine-Enforced Scope Guard (Runtime Execution Boundary)
|
|
185
|
+
|
|
186
|
+
While the Prompt Policy Sanitizer protects prompts from semantic upstream LLM filter rejections, the **Scope Guard** ([scripts/scope_guard.py](scripts/scope_guard.py)) converts the Security Context Object (SCO) and Task Envelope into an active, machine-enforced runtime execution fence.
|
|
187
|
+
|
|
188
|
+
- **Network Boundary Validation**: Only authorized CTF targets are permitted:
|
|
189
|
+
- Local loopback: `127.0.0.1`, `localhost`, `::1`
|
|
190
|
+
- RFC1918 private subnets: `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`
|
|
191
|
+
- Authorized CTF domains & competition platforms: `*.challs.io`, `*.picoctf.net`, `*.ctfd.io`, `*.tryhackme.com`, `*.hackthebox.com`, `*.flagyard.com`, and localhost ports.
|
|
192
|
+
- Arbitrary external IP addresses and unauthorized internet endpoints are rejected with explicit policy violations.
|
|
193
|
+
- **Prohibited Action Guard**: Automatically intercepts and blocks commands containing:
|
|
194
|
+
- Destructive disk actions (`rm -rf /`, `mkfs`, `dd if=/dev/zero`)
|
|
195
|
+
- Backdoor persistence mechanisms (`crontab`, systemd services, SSH key installation in `~/.ssh/authorized_keys`, root password modification)
|
|
196
|
+
- Wide automated network sweeps (`nmap -iR`, masscan against external CIDR blocks)
|
|
197
|
+
- **Runtime Execution**:
|
|
198
|
+
```bash
|
|
199
|
+
# Validate a target endpoint before probing:
|
|
200
|
+
python scripts/scope_guard.py http://127.0.0.1:8080
|
|
201
|
+
|
|
202
|
+
# Validate a diagnostic CLI command before running:
|
|
203
|
+
python scripts/scope_guard.py --command "checksec --file=chall"
|
|
204
|
+
|
|
205
|
+
# Generate a formal Security Context Object (SCO):
|
|
206
|
+
python scripts/scope_guard.py --target http://chall.ctf.site:9000 --json
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## Specialized Category Skills
|
|
212
|
+
|
|
213
|
+
`CTF-Agent` equips models with 11 domain-specific skills accessible via slash commands or subagent delegation:
|
|
214
|
+
|
|
215
|
+
| Skill | Description | Key Capabilities |
|
|
216
|
+
|:---|:---|:---|
|
|
217
|
+
| [`solve-challenge`](skills/solve-challenge/SKILL.md) | **Master Dispatcher & Orchestrator** | Hint-First triage, category routing, mode branching (Blitz vs Deep). |
|
|
218
|
+
| [`ctf-web`](skills/ctf-web/SKILL.md) | **Web Vulnerability Assessment** | SQLi, SSTI, JWT verification, prototype pollution, RSC Flight RCE, SSRF. |
|
|
219
|
+
| [`ctf-pwn`](skills/ctf-pwn/SKILL.md) | **Binary Security Analysis** | Glibc heap (House of Apple 2, TLS dtors), ROP, ret2libc, boundary testing. |
|
|
220
|
+
| [`ctf-crypto`](skills/ctf-crypto/SKILL.md) | **Cryptanalysis & Math** | RSA, ECC, LLL/BKZ lattice reduction, HNP/CVP, padding oracle, ZKP. |
|
|
221
|
+
| [`ctf-reverse`](skills/ctf-reverse/SKILL.md) | **Reverse Engineering** | Anti-analysis, custom VMs, WASM, `.pyc` (`pycdc`), Ghidra/radare2/GDB. |
|
|
222
|
+
| [`ctf-forensics`](skills/ctf-forensics/SKILL.md) | **Digital Forensics** | Memory dumps (Volatility 3), PCAP analysis, disk recovery, steganography. |
|
|
223
|
+
| [`ctf-ai-ml`](skills/ctf-ai-ml/SKILL.md) | **AI & Machine Learning** | Adversarial ML, model robustness, extraction evaluation, AI puzzle triage. |
|
|
224
|
+
| [`ctf-osint`](skills/ctf-osint/SKILL.md) | **Open Source Intelligence** | Geolocation, social media tracking, Tor relay tracing, DNS footprinting. |
|
|
225
|
+
| [`ctf-misc`](skills/ctf-misc/SKILL.md) | **Miscellaneous & Jails** | PyJails, bash jails, esoteric encodings, RF/SDR signals, game reversing. |
|
|
226
|
+
| [`ctf-malware`](skills/ctf-malware/SKILL.md) | **Malware Analysis** | C2 protocol decoding, PE/.NET unpackers, obfuscated script analysis. |
|
|
227
|
+
| [`ctf-writeup`](skills/ctf-writeup/SKILL.md) | **Write-up Generator** | Standardized 5-section submission writeup and directory organizer. |
|
|
228
|
+
|
|
229
|
+
### Custom Skill Extension & Envelope Validation
|
|
230
|
+
|
|
231
|
+
When adding external or custom CTF skills into `.agents/skills/`, run the built-in validator ([scripts/skill_validator.py](scripts/skill_validator.py)) to ensure prompt envelope compatibility and prevent model policy rejections:
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
# Validate a specific custom skill:
|
|
235
|
+
ctf-agent validate-skill .agents/skills/my-custom-skill
|
|
236
|
+
|
|
237
|
+
# Audit all skills in the workspace:
|
|
238
|
+
ctf-agent validate-skill --all
|
|
239
|
+
|
|
240
|
+
# Via NPX:
|
|
241
|
+
npx ctf-agent validate-skill .agents/skills/my-custom-skill
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
**Compatibility Rules Checked**:
|
|
245
|
+
- **Shallow Orchestration (Depth <= 1)**: Verifies the skill operates as a direct specialist without recursive subagent chaining.
|
|
246
|
+
- **YAML Frontmatter Integrity**: Verifies `name`, `description` (>= 20 chars), and checks against collisions with reserved core skills.
|
|
247
|
+
- **Operational Mode Handling**: Checks for Blitz Mode (Stop-on-Flag) and Deep Mode (RCA / writeup).
|
|
248
|
+
- **LLM Safety Policy Lexicon**: Flags unshielded adversarial triggers (`evil_payload`, `jailbreak`, `weaponize`) and recommends academic diagnostic equivalents.
|
|
249
|
+
- **Command Boundary Guard**: Intercepts destructive host commands (`rm -rf /`, `mkfs`) and backdoor persistence attempts (`crontab`, `authorized_keys`).
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## Parallel Triage & High-Speed Reconnaissance (P0 Engine)
|
|
254
|
+
|
|
255
|
+
To maximize Time-to-Flag during live CTF competitions, `CTF-Agent` integrates a high-speed parallel reconnaissance scheduler ([scripts/parallel_triage.py](scripts/parallel_triage.py)) that executes Tier 1 and Tier 2 diagnostics concurrently:
|
|
256
|
+
|
|
257
|
+
```
|
|
258
|
+
┌────────────────────────────────┐
|
|
259
|
+
│ Target Challenge Diagnostic │
|
|
260
|
+
└───────────────┬────────────────┘
|
|
261
|
+
│
|
|
262
|
+
┌───────────────────────────────┴───────────────────────────────┐
|
|
263
|
+
▼ ▼
|
|
264
|
+
[Binary / ELF Target] [Web / HTTP Target]
|
|
265
|
+
ThreadPoolExecutor Concurrency ThreadPoolExecutor Concurrency
|
|
266
|
+
- Pure-Python ELF Parser (Arch, Endian, NX, PIE) - HTTP Server & Powered-By Headers
|
|
267
|
+
- checksec security mitigations - /robots.txt & /sitemap.xml leaks
|
|
268
|
+
- strings pattern match (flags, /bin/sh, libc) - Sensitive paths (.git/HEAD, .env)
|
|
269
|
+
- readelf / symbol table analysis - Flag regex candidate pre-scan
|
|
270
|
+
│ │
|
|
271
|
+
└───────────────────────────────┬───────────────────────────────┘
|
|
272
|
+
▼
|
|
273
|
+
┌────────────────────────────────┐
|
|
274
|
+
│ Synthesized Triage Plan │
|
|
275
|
+
│ - Discovered Vulnerabilities │
|
|
276
|
+
│ - Recommended Specialist │
|
|
277
|
+
│ - Immediate Exploit Vector │
|
|
278
|
+
└────────────────────────────────┘
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
- **Zero-Dependency Native ELF Parser**: Reads ELF binary headers using pure Python standard library (`struct`), extracting machine architecture, bitness, endianness, entry point, section counts, NX stack protection, and PIE position independence without requiring external tools.
|
|
282
|
+
- **Concurrent Execution Modes**:
|
|
283
|
+
```bash
|
|
284
|
+
# Concurrent triage of a binary challenge:
|
|
285
|
+
python scripts/parallel_triage.py ./chall.bin
|
|
286
|
+
|
|
287
|
+
# Concurrent triage of a web challenge:
|
|
288
|
+
python scripts/parallel_triage.py http://127.0.0.1:8080
|
|
289
|
+
|
|
290
|
+
# Machine-readable output for automated agent pipelines:
|
|
291
|
+
python scripts/parallel_triage.py ./chall.bin --json
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## Quick Start & Workspace Installation
|
|
297
|
+
|
|
298
|
+
### Method 0: Intelligent Workspace Initialization (Triple-Engine Architecture)
|
|
299
|
+
|
|
300
|
+
```
|
|
301
|
+
┌─────────────────────────────────────────┐
|
|
302
|
+
│ User Workspace Initialization │
|
|
303
|
+
└────────────────────┬────────────────────┘
|
|
304
|
+
│
|
|
305
|
+
┌────────────────────────────────┼────────────────────────────────┐
|
|
306
|
+
▼ ▼ ▼
|
|
307
|
+
[1. Web & JS Ecosystem] [2. Python Workstation] [3. Modern UV Toolchain]
|
|
308
|
+
npx ctf-agent init python scripts/ctf_init.py uvx ctf-agent init
|
|
309
|
+
│ │ │
|
|
310
|
+
└────────────────────────────────┼────────────────────────────────┘
|
|
311
|
+
▼
|
|
312
|
+
┌─────────────────────────────────────────┐
|
|
313
|
+
│ Step 1: Preflight Detection │
|
|
314
|
+
│ - OS, CPU, RAM & Disk Storage Free │
|
|
315
|
+
│ - WSL2 & Kali Linux Distro Status │
|
|
316
|
+
│ - Docker CLI & Daemon Connectivity │
|
|
317
|
+
│ - Check for Existing .agents/ Folder │
|
|
318
|
+
└────────────────────┬────────────────────┘
|
|
319
|
+
│
|
|
320
|
+
▼
|
|
321
|
+
┌─────────────────────────────────────────┐
|
|
322
|
+
│ Step 2: Backend Capability Score │
|
|
323
|
+
│ WSL Kali Score vs Docker Daemon Score │
|
|
324
|
+
│ (Objective transparent recommendation)│
|
|
325
|
+
└────────────────────┬────────────────────┘
|
|
326
|
+
│
|
|
327
|
+
▼
|
|
328
|
+
┌─────────────────────────────────────────┐
|
|
329
|
+
│ Step 3: Workload Purpose Selection │
|
|
330
|
+
│ [1] Live CTF: core, pwn, web, crypto │
|
|
331
|
+
│ [2] Security Lab: 10 deep profiles │
|
|
332
|
+
│ [3] Rev & Binary: pwn, rev, kernel │
|
|
333
|
+
│ [4] Full Workstation: all 15 profiles │
|
|
334
|
+
└────────────────────┬────────────────────┘
|
|
335
|
+
│
|
|
336
|
+
▼
|
|
337
|
+
┌─────────────────────────────────────────┐
|
|
338
|
+
│ Step 4: Provision & Conflict Guard │
|
|
339
|
+
│ - If .agents exists: Prompt / Confirm │
|
|
340
|
+
│ - Deploy .agents/ & AGENTS.md config │
|
|
341
|
+
│ - Preserve solve.py & resources/ │
|
|
342
|
+
│ - Provision Toolchain into Backend │
|
|
343
|
+
└────────────────────┬────────────────────┘
|
|
344
|
+
│
|
|
345
|
+
▼
|
|
346
|
+
┌─────────────────────────────────────────┐
|
|
347
|
+
│ Step 5: Health Verification │
|
|
348
|
+
│ Verify subagents, venv & CLI tools │
|
|
349
|
+
│ [OK] WORKSPACE READY TO SOLVE! │
|
|
350
|
+
└─────────────────────────────────────────┘
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
CTF-Agent provides three interchangeable execution engines tailored to different developer workflows:
|
|
354
|
+
|
|
355
|
+
#### 1. Web & JavaScript Ecosystem (`npx`)
|
|
356
|
+
Zero-clone setup for developers accustomed to npm and modern web toolchains:
|
|
357
|
+
```bash
|
|
358
|
+
# Initialize via NPX directly from GitHub (zero-clone):
|
|
359
|
+
npx github:nvtruongops/CTF-Agent init
|
|
360
|
+
|
|
361
|
+
# Target a specific challenge workspace:
|
|
362
|
+
npx github:nvtruongops/CTF-Agent init /path/to/ctf-workspace
|
|
363
|
+
|
|
364
|
+
# Run preflight inspection in dry-run mode:
|
|
365
|
+
npx github:nvtruongops/CTF-Agent init --dry-run
|
|
366
|
+
|
|
367
|
+
# Or install locally for direct 'ctf-agent' command:
|
|
368
|
+
npm link # run inside cloned repo once
|
|
369
|
+
ctf-agent init
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
#### 2. Native Python Security Workstation (`ctf-agent` / `ctf_agent_cli.py`)
|
|
373
|
+
Pure standard library execution with zero external third-party dependencies:
|
|
374
|
+
```bash
|
|
375
|
+
# Recommended: Install CLI entrypoint once (available everywhere):
|
|
376
|
+
pip install -e . # run inside cloned repo once
|
|
377
|
+
ctf-agent init /path/to/ctf-workspace
|
|
378
|
+
|
|
379
|
+
# Or execute directly from cloned repository root:
|
|
380
|
+
python ctf_agent_cli.py init /path/to/ctf-workspace
|
|
381
|
+
|
|
382
|
+
# Automated unattended setup (auto-selects highest-scored backend and purpose):
|
|
383
|
+
ctf-agent init /path/to/ctf-workspace --auto --purpose live-ctf
|
|
384
|
+
|
|
385
|
+
# Preflight analysis and dry-run inspection (zero filesystem writes):
|
|
386
|
+
ctf-agent init --dry-run
|
|
387
|
+
|
|
388
|
+
# Health check verification on an existing workspace:
|
|
389
|
+
ctf-agent init /path/to/ctf-workspace --check-only
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
#### 3. Modern Python Toolchain (`uvx`)
|
|
393
|
+
Ultra-fast ephemeral execution powered by the Rust-based `uv` package manager:
|
|
394
|
+
```bash
|
|
395
|
+
# Execute directly from repository source without installation:
|
|
396
|
+
uvx --from git+https://github.com/nvtruongops/CTF-Agent ctf-agent init
|
|
397
|
+
|
|
398
|
+
# Target a specific workspace:
|
|
399
|
+
uvx --from git+https://github.com/nvtruongops/CTF-Agent ctf-agent init /path/to/ctf-workspace
|
|
400
|
+
|
|
401
|
+
# Automated speedrun profile:
|
|
402
|
+
uvx --from git+https://github.com/nvtruongops/CTF-Agent ctf-agent init --auto --purpose live-ctf
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
---
|
|
406
|
+
|
|
407
|
+
### Workspace & Skill Updates (`ctf-agent update`)
|
|
408
|
+
|
|
409
|
+
Keep deployed CTF workspaces up to date with new skills, agent personas, rules, and security references without losing custom modifications or challenge files:
|
|
410
|
+
|
|
411
|
+
```bash
|
|
412
|
+
# Update current workspace via CLI (if installed):
|
|
413
|
+
ctf-agent update
|
|
414
|
+
|
|
415
|
+
# Or via NPX directly from GitHub:
|
|
416
|
+
npx github:nvtruongops/CTF-Agent update /path/to/ctf-workspace
|
|
417
|
+
|
|
418
|
+
# Modern toolchain (uvx):
|
|
419
|
+
uvx --from git+https://github.com/nvtruongops/CTF-Agent ctf-agent update /path/to/ctf-workspace
|
|
420
|
+
|
|
421
|
+
# Native Python from cloned repo root:
|
|
422
|
+
python ctf_agent_cli.py update /path/to/ctf-workspace
|
|
423
|
+
|
|
424
|
+
# Preview planned skill & rule updates without writing changes:
|
|
425
|
+
npx ctf-agent update --dry-run
|
|
426
|
+
|
|
427
|
+
# Only synchronize skills (preserve rules, agents, and scripts):
|
|
428
|
+
npx ctf-agent update --skills-only
|
|
429
|
+
|
|
430
|
+
# Update global configuration (~/.gemini/config/):
|
|
431
|
+
python scripts/ctf_update.py --global
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
**Zero Data Loss Guarantees**:
|
|
435
|
+
- **Conflict Guard**: Inspects SHA-256 hashes against `skills-lock.json`. If you made local modifications to a skill, it creates a safe backup (`SKILL.md.bak`) before updating.
|
|
436
|
+
- **Custom Skills & Non-Skill Directory Preservation**: Custom skills in `.agents/skills/`, custom subagents in `.agents/agents/`, custom rules in `.agents/rules/`, and custom scripts in `.agents/scripts/` that are not part of upstream CTF-Agent are preserved completely untouched without wholesale directory wipes.
|
|
437
|
+
- **Automated Backups for Modified Support Files**: Any modified upstream files in `.agents/rules/`, `.agents/agents/`, `.agents/references/`, or `scripts/` receive `.bak` backup files prior to update.
|
|
438
|
+
- **Challenge Assets Protected**: Exploit scripts (`solve.py`), challenge binaries (`resources/`), CTF notes (`notes/`), and credentials (`.env`) are never overwritten or deleted.
|
|
439
|
+
|
|
440
|
+
---
|
|
441
|
+
|
|
442
|
+
### Method 1: Deploy CTF-Agent into a CTF Challenge Project (`.agents/`)
|
|
443
|
+
Deploy CTF-Agent as an `.agents` bundle into any target CTF directory:
|
|
444
|
+
```bash
|
|
445
|
+
# Using symlinks/junctions (live synced with updates):
|
|
446
|
+
python scripts/install_as_agent.py /path/to/ctf-workspace --symlink
|
|
447
|
+
|
|
448
|
+
# Or standalone copy:
|
|
449
|
+
python scripts/install_as_agent.py /path/to/ctf-workspace
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
### Method 2: Global Installation Across All Projects
|
|
453
|
+
Install skills, rules, and subagents globally into `~/.gemini/config/`:
|
|
454
|
+
```bash
|
|
455
|
+
python scripts/install_as_agent.py --global
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
### Method 3: Direct Usage Within This Workspace
|
|
459
|
+
This workspace already has `.agents/` configured. You can start prompting directly using slash commands and text flags:
|
|
460
|
+
- **Master Orchestrator**: `/solve-challenge <target-url-or-dir>`
|
|
461
|
+
- **Speedrun / Blitz Mode (Fast Solve, Stop-on-Flag)**: `/solve-challenge --mode blitz <target>` or `/ctf-web --fast <target>` or `--blitz <prompt>`
|
|
462
|
+
- **Deep Analysis Mode (RCA & Writeup)**: `/solve-challenge --mode deep <target>` or `/ctf-pwn --deep <target>` or `--lab <prompt>`
|
|
463
|
+
- **Specific Category Skills**: `/ctf-web`, `/ctf-pwn`, `/ctf-crypto`, `/ctf-reverse`, `/ctf-forensics`, `/ctf-osint`, `/ctf-misc`, `/ctf-ai-ml`, `/ctf-malware`, `/ctf-writeup`
|
|
464
|
+
|
|
465
|
+
---
|
|
466
|
+
|
|
467
|
+
## Automated Automation Utilities
|
|
468
|
+
|
|
469
|
+
Located in [scripts/](scripts/):
|
|
470
|
+
|
|
471
|
+
- **`parallel_triage.py`**:
|
|
472
|
+
- `python3 scripts/parallel_triage.py <target-binary-or-url>`: Executes high-speed concurrent Tier 1 & 2 diagnostics (pure Python ELF parsing, checksec, strings, headers, robots.txt, sitemap.xml, sensitive leak probes) via ThreadPoolExecutor.
|
|
473
|
+
- `python3 scripts/parallel_triage.py <target> --json`: Emits machine-readable diagnostic synthesis with recommended specialist category skills.
|
|
474
|
+
- **`scope_guard.py`**:
|
|
475
|
+
- `python3 scripts/scope_guard.py <target-or-command>`: Machine-enforces authorized testing boundaries (RFC1918 subnets, loopback, CTF platform domains) and blocks destructive commands or root persistence attempts.
|
|
476
|
+
- `python3 scripts/scope_guard.py --target <url> --json`: Generates a formal Security Context Object (SCO) for multi-agent dispatch.
|
|
477
|
+
- **`skill_validator.py`**:
|
|
478
|
+
- `python3 scripts/skill_validator.py <path-to-skill>`: Validates external custom skills against YAML frontmatter schemas, shallow orchestration constraints (depth <= 1), mode awareness, policy lexicon, and prohibited commands.
|
|
479
|
+
- `python3 scripts/skill_validator.py --all --json`: Scans all skills across `.agents/skills/` and returns structured JSON reports for CI/CD or agent pipelines.
|
|
480
|
+
- **`prompt_policy_sanitizer.py`**:
|
|
481
|
+
- `python3 scripts/prompt_policy_sanitizer.py "<prompt>" --lang [vi|en]`: Scans, scores policy risk, and sanitizes prompts with academic terminology and educational CTF preambles.
|
|
482
|
+
- `python3 scripts/prompt_policy_sanitizer.py --file <path> --check`: Verifies that challenge writeups, prompts, or scripts do not trigger modern LLM backend filters.
|
|
483
|
+
- **`workspace_cleaner.py`**:
|
|
484
|
+
- `python3 scripts/workspace_cleaner.py --fast`: Purges scratch files (`test*.py`, `fuzz*.py`, `tmp*`), keeping challenge assets and winning `solve.py`.
|
|
485
|
+
- `python3 scripts/workspace_cleaner.py --deep`: Enforces `writeup.md`, `solve.py`, and `resources/` folder structure.
|
|
486
|
+
- **`extract_flags.py`**:
|
|
487
|
+
- `python3 scripts/extract_flags.py "<output>" --banner`: Prints high-visibility flag banner and verifies candidate regex.
|
|
488
|
+
- `python3 scripts/extract_flags.py -f output.log --json`: Emits machine-readable JSON candidate rankings.
|
|
489
|
+
- **`ctfd_client.py`**:
|
|
490
|
+
- Python API client for automated challenge retrieval, attachment downloading, and flag submission.
|
|
491
|
+
- **`cve_lookup.py`**:
|
|
492
|
+
- Automated CVE advisory and exploit lookup utility via Sploitus and Exploit-DB.
|
|
493
|
+
|
|
494
|
+
---
|
|
495
|
+
|
|
496
|
+
## References & Deep Knowledge Base
|
|
497
|
+
|
|
498
|
+
Detailed references offloaded to [references/](references/) to preserve maximum context window tokens during agent turns:
|
|
499
|
+
- [multi-agent-orchestration-and-policy-routing.md](references/multi-agent-orchestration-and-policy-routing.md) — Comprehensive guide on Security Context Objects, Task Envelopes, shallow orchestration, and the 3-Tier Refusal Router.
|
|
500
|
+
- [llm-safety-and-policy-compliance.md](references/llm-safety-and-policy-compliance.md) — Comprehensive guide on modern LLM safety filter architecture, trigger dictionary (EN/VI), and safe prompt engineering.
|
|
501
|
+
- [ctf-triage-ladder.md](references/ctf-triage-ladder.md) — Hierarchical 4-Tier progression (Tier 1 plaintext to Tier 4 in-meta).
|
|
502
|
+
- [version-matrix.md](references/version-matrix.md) — Glibc heap, PHP type juggling, and Python bytecode compatibility matrix.
|
|
503
|
+
- [exploit-databases.md](references/exploit-databases.md) — Exploit databases, CVE search, and GitHub PoC repositories.
|
|
504
|
+
- [security-events-and-intelligence.md](references/security-events-and-intelligence.md) — CTFtime intelligence and event key extraction techniques.
|
|
505
|
+
|
|
506
|
+
---
|
|
507
|
+
|
|
508
|
+
## Constitution & Architectural Governance
|
|
509
|
+
|
|
510
|
+
The rules governing all CTF-Agent behavior are defined in [AGENTS.md](AGENTS.md):
|
|
511
|
+
1. **Hint-First Rule**: Analyze metadata and hints before touching code or tools.
|
|
512
|
+
2. **Operational Mode Compliance**: Strictly follow Blitz or Deep Analysis protocols.
|
|
513
|
+
3. **Execution Guard**: Never modify original challenge files; wrap Linux binaries through WSL/Docker; enforce 60s command timeouts.
|
|
514
|
+
4. **Flag Anti-Hallucination**: 100% verified flag strings directly from runtime output.
|
|
515
|
+
5. **LLM Safety & Policy Compliance**: Enforce authorized educational sandbox scope and use academic diagnostic terminology per [ctf-safety-framing-rules.md](rules/ctf-safety-framing-rules.md).
|
|
516
|
+
6. **Context Propagation & Task Envelopes**: Propagate machine-readable Security Context Objects and enforce shallow execution depth (max depth: 1).
|
|
517
|
+
7. **Refusal Router & Deterministic Tool Fallback**: Enforce 3-tier refusal classification; never enter infinite paraphrasing loops on hard refusals, falling back directly to deterministic CLI tools.
|
|
518
|
+
|
|
519
|
+
---
|
|
520
|
+
|
|
521
|
+
### License & Attribution
|
|
522
|
+
Distributed under the MIT License. Designed for authorized security research, academic labs, and ethical CTF competitions.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ctf-analyzer
|
|
3
|
+
description: "In-depth CTF research and lab security auditor agent. Specializes in comprehensive root cause analysis (RCA), reverse engineering, artifact preservation, vulnerability documentation, and generating publication-ready writeups."
|
|
4
|
+
mainAgent: true
|
|
5
|
+
subagent: true
|
|
6
|
+
commandExecutionPolicy: auto
|
|
7
|
+
allowed-tools: Bash Read Write Edit Glob Grep Task WebFetch WebSearch Skill
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# CTF Analyzer / Deep Research Agent Persona
|
|
11
|
+
|
|
12
|
+
You are **CTF-Analyzer**, a senior vulnerability researcher and CTF education specialist. Your purpose is conducting rigorous, in-depth security analysis on CTF challenges, vulnerable labs, and complex exploit chains, followed by producing publication-ready documentation.
|
|
13
|
+
|
|
14
|
+
## Core Mission: Security Rigor & Exhaustive Documentation
|
|
15
|
+
Unlike sprint competitions where speed is everything, in research and lab environments the goal is deep understanding: how the vulnerability occurs at machine/source level, why mitigations failed, how the exploit chain is constructed step-by-step, and how it can be defended against.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## The 4 Cardinal Rules of Deep Analysis Mode
|
|
20
|
+
|
|
21
|
+
### 1. Exhaustive Root Cause Analysis (RCA)
|
|
22
|
+
- Never stop at "the exploit worked". Analyze and document the underlying flaw:
|
|
23
|
+
- **Memory Corruption / Pwn**: Exact stack/heap memory layouts, glibc version nuances, canary/PIE/ASLR bypass techniques, ROP gadget gadgets, TLS destructors, or FSOP structures.
|
|
24
|
+
- **Web / API**: Code execution vectors, source code AST analysis, parameter pollution, template engine internals, prototype pollution sinks, and auth flaws.
|
|
25
|
+
- **Cryptography**: Mathematical weakness proof, lattice reduction parameters, PRNG state recovery, small root conditions, or ECC curve anomalies.
|
|
26
|
+
- **Reverse Engineering**: Decompiled code logic, control flow graph (CFG), anti-analysis/anti-debugging mechanisms, VM instruction decoding.
|
|
27
|
+
|
|
28
|
+
### 2. Complete Artifact Preservation & Clean Organization
|
|
29
|
+
- Preserve all challenge artifacts, raw decompilations, network captures, memory traces, and exploit drafts.
|
|
30
|
+
- Follow the standardized directory structure:
|
|
31
|
+
```text
|
|
32
|
+
Category/XX-ChallengeName/
|
|
33
|
+
├── writeup.md # Full, authoritative writeup report
|
|
34
|
+
├── solve.py # Clean, self-contained, reproducible exploit script
|
|
35
|
+
└── resources/ # Challenge binaries, source code, PCAPs, dumps, images
|
|
36
|
+
```
|
|
37
|
+
- Move all raw files and temporary artifacts into `resources/` rather than deleting them, ensuring future reproducibility.
|
|
38
|
+
|
|
39
|
+
### 3. Standardized Writeup Generation
|
|
40
|
+
- Upon confirming the flag, invoke `ctf-writeup` and author a comprehensive `writeup.md` covering:
|
|
41
|
+
1. **Challenge & Hint Analysis**: Full semantic breakdown of author intent, puns, and explicit negative constraints.
|
|
42
|
+
2. **Target Architecture & RCA**: Technical breakdown of the stack, attack surface, and root cause flaw.
|
|
43
|
+
3. **Step-by-Step Exploitation Walkthrough**: Chronological guide explaining each stage of the attack chain with code snippets.
|
|
44
|
+
4. **Standalone Exploit Script (`solve.py`)**: A fully runnable, modular Python script using `pwntools`, `requests`, or cryptographic libraries.
|
|
45
|
+
5. **Verification & Flag**: Verified flag string with verification proof.
|
|
46
|
+
6. **Mitigation & Detection**: Security recommendations to patch the flaw, plus defensive detection signatures (e.g. YARA rule, Suricata rule, or input validation patch).
|
|
47
|
+
|
|
48
|
+
### 4. Reproducibility & Sanity Checks
|
|
49
|
+
- Verify that `solve.py` can be executed standalone from a clean environment without manual interaction and reliably retrieves the flag:
|
|
50
|
+
```bash
|
|
51
|
+
python3 solve.py
|
|
52
|
+
```
|
|
53
|
+
- Ensure all relative file paths inside `solve.py` reference `resources/` correctly.
|
|
54
|
+
|
|
55
|
+
### 5. Educational Scope & LLM Policy Compliance
|
|
56
|
+
- Maintain an objective, academic, and defensive vulnerability research framing in all RCA reports and generated code.
|
|
57
|
+
- Prepend proof-of-concept scripts with the educational CTF sandbox header.
|
|
58
|
+
- Adhere to the Academic Lexicon Standard in [ctf-safety-framing-rules.md](../rules/ctf-safety-framing-rules.md), avoiding red-team trigger words that cause backend agent policies to halt session execution.
|