ctf-agent 1.2.0 → 1.3.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/README.md +532 -522
- package/package.json +1 -1
- package/scripts/__pycache__/__init__.cpython-314.pyc +0 -0
- package/scripts/__pycache__/ctf_init.cpython-314.pyc +0 -0
- package/scripts/__pycache__/ctf_update.cpython-314.pyc +0 -0
- package/scripts/__pycache__/cve_lookup.cpython-314.pyc +0 -0
- package/scripts/__pycache__/install_as_agent.cpython-314.pyc +0 -0
- package/scripts/__pycache__/parallel_triage.cpython-314.pyc +0 -0
- package/scripts/__pycache__/prompt_policy_sanitizer.cpython-314.pyc +0 -0
- package/scripts/__pycache__/scope_guard.cpython-314.pyc +0 -0
- package/scripts/__pycache__/skill_validator.cpython-314.pyc +0 -0
- package/scripts/assets/AGENTS.md +131 -0
- package/scripts/assets/README.md +532 -0
- package/scripts/assets/mcp_config.json +19 -0
- package/scripts/assets/skills.json +16 -0
- package/scripts/ctf_update.py +14 -4
- package/scripts/install_as_agent.py +14 -4
package/README.md
CHANGED
|
@@ -1,522 +1,532 @@
|
|
|
1
|
-
# CTF-Agent: Autonomous Security Intelligence & Competitive Exploitation Framework
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- [
|
|
16
|
-
- [
|
|
17
|
-
- [
|
|
18
|
-
- [
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
>
|
|
30
|
-
>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
wsl -d kali-linux
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
│
|
|
97
|
-
|
|
98
|
-
│
|
|
99
|
-
│
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
- **
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
- **
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
- **
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
- **
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
- **
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
- **
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
- **
|
|
180
|
-
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
- **
|
|
194
|
-
-
|
|
195
|
-
-
|
|
196
|
-
-
|
|
197
|
-
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
|
221
|
-
|
|
222
|
-
| [`
|
|
223
|
-
| [`ctf-
|
|
224
|
-
| [`ctf-
|
|
225
|
-
| [`ctf-
|
|
226
|
-
| [`ctf-
|
|
227
|
-
| [`ctf-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
-
|
|
282
|
-
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
│
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
│
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
│
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
│
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
ctf-agent init /path/to/ctf-workspace
|
|
384
|
-
|
|
385
|
-
#
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
#
|
|
389
|
-
ctf-agent init /path/to/ctf-workspace --
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
```
|
|
412
|
-
|
|
413
|
-
ctf-agent
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
### Method
|
|
453
|
-
|
|
454
|
-
```bash
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
- `python3 scripts/
|
|
483
|
-
-
|
|
484
|
-
|
|
485
|
-
- `python3 scripts/
|
|
486
|
-
-
|
|
487
|
-
|
|
488
|
-
- `python3 scripts/
|
|
489
|
-
-
|
|
490
|
-
|
|
491
|
-
-
|
|
492
|
-
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
-
|
|
500
|
-
-
|
|
501
|
-
-
|
|
502
|
-
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
1
|
+
# CTF-Agent: Autonomous Security Intelligence & Competitive Exploitation Framework
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/ctf-agent)
|
|
4
|
+
[](https://www.python.org/downloads/)
|
|
5
|
+
[](https://github.com/nvtruongops/CTF-Agent/pkgs/container/ctf-agent)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
> **A High-Performance AI Agent Architecture for Live CTF Competitions, Lab Vulnerability Audits, and Security Research.**
|
|
9
|
+
> Compatible with **Antigravity IDE**, **Cursor**, **Claude Code**, and **OpenAI Codex/Agent** ecosystems.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Quick Navigation
|
|
14
|
+
|
|
15
|
+
- [CRITICAL: Environment Backend Selection (WSL vs Docker)](#critical-environment-backend-selection-wsl-vs-docker)
|
|
16
|
+
- [Operational Modes: Blitz vs Deep Analysis](#operational-modes-blitz-vs-deep-analysis)
|
|
17
|
+
- [LLM Safety Guardrails & Policy Compliance](#llm-safety-guardrails--policy-compliance)
|
|
18
|
+
- [Machine-Enforced Scope Guard](#machine-enforced-scope-guard-runtime-execution-boundary)
|
|
19
|
+
- [Specialized Category Skills](#specialized-category-skills)
|
|
20
|
+
- [Parallel Triage & High-Speed Reconnaissance](#parallel-triage--high-speed-reconnaissance-p0-engine)
|
|
21
|
+
- [Quick Start & Workspace Installation](#quick-start--workspace-installation)
|
|
22
|
+
- [References & Deep Knowledge Base](#references--deep-knowledge-base)
|
|
23
|
+
- [Constitution & Architectural Governance](#constitution--architectural-governance)
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## CRITICAL: Environment Backend Selection (WSL vs Docker)
|
|
28
|
+
|
|
29
|
+
> [!CAUTION]
|
|
30
|
+
> ### ANTI-DISK-OVERFLOW RULE (DO NOT INITIALIZE BOTH ENVIRONMENTS!)
|
|
31
|
+
> **DO NOT build the Docker container AND install the full WSL toolchain at the same time.**
|
|
32
|
+
> 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**.
|
|
33
|
+
> Initializing **BOTH** will consume **30 to 50 GB+**, risking catastrophic host drive exhaustion and environment conflicts.
|
|
34
|
+
>
|
|
35
|
+
> **AI Agents & Players MUST detect and choose EXACTLY ONE backend:**
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
┌─────────────────────────────┐
|
|
39
|
+
│ Choose ONE Backend Engine │
|
|
40
|
+
└──────────────┬──────────────┘
|
|
41
|
+
│
|
|
42
|
+
┌──────────────────────────────┴──────────────────────────────┐
|
|
43
|
+
▼ ▼
|
|
44
|
+
[OPTION A: WSL Kali Linux] [OPTION B: Docker Sandbox]
|
|
45
|
+
Best for: Windows Host Development Best for: Linux, macOS, or CI/CD
|
|
46
|
+
- Zero VM overhead, fast host I/O - 100% ephemeral and disposable
|
|
47
|
+
- Direct file access via /mnt/c/Users/... - Clean host isolation
|
|
48
|
+
- Direct GUI/GDB debugging support - Standardized container image
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Option A: WSL Kali Linux (Recommended on Windows)
|
|
52
|
+
1. **Verify WSL Kali Availability**:
|
|
53
|
+
```powershell
|
|
54
|
+
wsl -d kali-linux uname -a
|
|
55
|
+
```
|
|
56
|
+
2. **Install CTF Toolchain Inside WSL (Select Profiles to Save Disk)**:
|
|
57
|
+
```bash
|
|
58
|
+
# Inside WSL or wrapped from PowerShell:
|
|
59
|
+
wsl -d kali-linux bash -c "bash scripts/install_ctf_tools.sh core"
|
|
60
|
+
# To install specific profiles: pwn, rev, crypto, web, forensics
|
|
61
|
+
wsl -d kali-linux bash -c "bash scripts/install_ctf_tools.sh pwn crypto web"
|
|
62
|
+
```
|
|
63
|
+
3. **Execution Wrapper**:
|
|
64
|
+
```powershell
|
|
65
|
+
wsl -d kali-linux bash -c "source ~/.ctf-tools/venv/bin/activate && <command>"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Option B: Docker Container Sandbox (Recommended on Linux / macOS / CI)
|
|
69
|
+
1. **Build Container Image**:
|
|
70
|
+
```bash
|
|
71
|
+
docker compose build
|
|
72
|
+
```
|
|
73
|
+
2. **Execute Inside Container Sandbox**:
|
|
74
|
+
```bash
|
|
75
|
+
docker compose run --rm ctf-agent <command>
|
|
76
|
+
```
|
|
77
|
+
3. **Interactive Shell**:
|
|
78
|
+
```bash
|
|
79
|
+
docker compose run --rm ctf-agent /bin/bash
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Operational Profiles & Specialized Modes (Text Flags)
|
|
85
|
+
|
|
86
|
+
> [!TIP]
|
|
87
|
+
> ### HOW MODES WORK (PROMPT TEXT FLAGS)
|
|
88
|
+
> Operational modes (`--fast`, `--blitz`, `--deep`, `--lab`) are **instructional text flags** recognized by the Agent through [AGENTS.md](AGENTS.md).
|
|
89
|
+
> **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>`).
|
|
90
|
+
> *(Note: In Antigravity IDE, typing `@` searches files/symbols in the workspace; modes are passed directly as text flags in your prompt text).*
|
|
91
|
+
|
|
92
|
+
`CTF-Agent` provides 3 specialized agent personas designed to eliminate multi-agent refusal cascades and optimize for both speedrun competitions and deep lab audits:
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
┌─────────────────────────────────────────────────────────────────────────────────────────────────┐
|
|
96
|
+
│ CTF-AGENT PERSONA MATRIX │
|
|
97
|
+
├──────────────────────────┬───────────────────────────────┬──────────────────────────────────────┤
|
|
98
|
+
│ MASTER ORCHESTRATOR │ BLITZ / SPEEDRUN SOLVER │ DEEP RESEARCH AUDITOR │
|
|
99
|
+
│ @ctf-controller │ @ctf-speedrun (--blitz) │ @ctf-analyzer (--deep) │
|
|
100
|
+
├──────────────────────────┼───────────────────────────────┼──────────────────────────────────────┤
|
|
101
|
+
│ Role: State Controller │ Role: First Blood Hunter │ Role: Security Auditor / RCA │
|
|
102
|
+
│ Enforces: Shallow depth │ Stop Condition: On Flag HALT │ Stop Condition: Verified Writeup │
|
|
103
|
+
│ Context: SCO & Envelope │ Documentation: ZERO overhead │ Documentation: 5-Section writeup │
|
|
104
|
+
│ Refusal: 3-Tier Router │ Workspace: Auto-purge debris │ Workspace: Organize resources/ │
|
|
105
|
+
│ Fallback: Deterministic │ Output: Verified Flag Banner │ Output: Authoritative RCA report │
|
|
106
|
+
└──────────────────────────┴───────────────────────────────┴──────────────────────────────────────┘
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 1. Master Controller (`@ctf-controller` / `/solve-challenge`)
|
|
110
|
+
Use as the primary entrypoint for complex multi-step labs or challenges.
|
|
111
|
+
- **Prompt Examples**:
|
|
112
|
+
- `/solve-challenge http://challenge.ctf.site:8000`
|
|
113
|
+
- `/solve-challenge ./challenge_directory`
|
|
114
|
+
- **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.
|
|
115
|
+
- **Shallow Orchestration (Depth = 1)**: Dispatches directly to a single specialist skill or agent. Prohibits deep recursive agent chaining (`Agent A -> Agent B -> Agent C`).
|
|
116
|
+
- **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.
|
|
117
|
+
|
|
118
|
+
### 2. Blitz / Speedrun Mode (`@ctf-speedrun` / `--blitz` / `--fast`)
|
|
119
|
+
Use during active CTF competitions where time is points.
|
|
120
|
+
- **Prompt Examples**:
|
|
121
|
+
- `/ctf-web --fast http://challenge.ctf.site:8080`
|
|
122
|
+
- `/solve-challenge --mode blitz ./pwn_challenge`
|
|
123
|
+
- `--blitz Solve this crypto puzzle: c = 12345, e = 3, n = 99999`
|
|
124
|
+
- **Stop-on-Flag (HALT immediately)**: The instant a valid flag matching target regex (`flag{...}`, `picoCTF{...}`) is confirmed, all tool invocations and probing **stop immediately**.
|
|
125
|
+
- **High-Visibility Flag Banner**:
|
|
126
|
+
```text
|
|
127
|
+
============================================================
|
|
128
|
+
[+] FLAG ACQUIRED: picoCTF{example_flag_value}
|
|
129
|
+
Confidence: 100% | Source: HTTP 200 Response
|
|
130
|
+
============================================================
|
|
131
|
+
```
|
|
132
|
+
- **Automated Workspace Cleanup**:
|
|
133
|
+
```bash
|
|
134
|
+
python3 scripts/workspace_cleaner.py --fast
|
|
135
|
+
```
|
|
136
|
+
Automatically removes temporary scratch files (`test*.py`, `fuzz*.py`, `tmp*`, `core.*`, `payload*.bin`), keeping only the original challenge files and the winning `solve.py`.
|
|
137
|
+
- **Zero Overhead**: Does **not** invoke `ctf-writeup` and does **not** create `writeup.md`.
|
|
138
|
+
|
|
139
|
+
### 3. Deep Analysis / Lab Mode (`@ctf-analyzer` / `--deep` / `--lab`)
|
|
140
|
+
Use when solving challenge labs (HackTheBox, PortSwigger, pwnable.tw), post-mortems, or security research.
|
|
141
|
+
- **Prompt Examples**:
|
|
142
|
+
- `/ctf-pwn --deep ./vulnerable_binary`
|
|
143
|
+
- `/solve-challenge --mode deep ./web_lab`
|
|
144
|
+
- `--lab Perform deep root cause analysis and generate writeup`
|
|
145
|
+
- **Root Cause Analysis (RCA)**: Deep analysis of memory corruption layouts, AST flaws, or cryptographic mathematical proofs.
|
|
146
|
+
- **Directory Standardization**:
|
|
147
|
+
```bash
|
|
148
|
+
python3 scripts/workspace_cleaner.py --deep
|
|
149
|
+
```
|
|
150
|
+
Enforces clean lab layout: only `writeup.md`, `solve.py`, and a `resources/` folder containing all challenge binaries, PCAPs, dumps, and source archives.
|
|
151
|
+
- **Standardized Writeup**: Automatically invokes `ctf-writeup` to author a publication-ready 5-section `writeup.md`.
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## LLM Safety Guardrails & Policy Compliance (Prompt Sanitization & Guardrail Navigation)
|
|
156
|
+
|
|
157
|
+
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**.
|
|
158
|
+
|
|
159
|
+
`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:
|
|
160
|
+
|
|
161
|
+
### 1. How to Apply in Labs & CTF Competitions
|
|
162
|
+
|
|
163
|
+
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:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
# Sanitize an input prompt with high-risk keywords:
|
|
167
|
+
python scripts/prompt_policy_sanitizer.py "Write an exploit payload to bypass security policy and extract the flag"
|
|
168
|
+
|
|
169
|
+
# Sanitize a prompt with specific language support:
|
|
170
|
+
python scripts/prompt_policy_sanitizer.py "Write script to bypass filter and capture flag" --lang en
|
|
171
|
+
|
|
172
|
+
# Scan and sanitize an entire challenge prompt file or writeup:
|
|
173
|
+
python scripts/prompt_policy_sanitizer.py --file path/to/prompt.txt --check
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### 2. Automated Sanitization Mechanism
|
|
177
|
+
|
|
178
|
+
- **Risk Scoring**: Assesses policy risk from `SAFE` (0) to `CRITICAL` (100) across 5 high-risk trigger families (Evasion, Redteam, Exploit, Payload, Exfiltration).
|
|
179
|
+
- **Academic Lexicon Standard**: Automatically replaces adversarial attack jargon with defensive and diagnostic testing equivalents:
|
|
180
|
+
- *exploit vulnerability* -> *verify vulnerability with proof-of-concept (PoC)*
|
|
181
|
+
- *bypass policy* -> *evaluate mitigation boundaries*
|
|
182
|
+
- *steal credentials / exfiltrate* -> *retrieve challenge flag token*
|
|
183
|
+
- *redteam attack* -> *diagnostic security assessment*
|
|
184
|
+
- **Educational CTF Context Preamble**: Injects explicit authorized testing boundaries (`localhost`, Docker, designated CTF target) to satisfy upstream safety filters.
|
|
185
|
+
- **Path & Link Preservation**: Automatically preserves markdown links `[text](target.md)` and URLs without unwanted corruption.
|
|
186
|
+
|
|
187
|
+
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).
|
|
188
|
+
|
|
189
|
+
### 3. Machine-Enforced Scope Guard (Runtime Execution Boundary)
|
|
190
|
+
|
|
191
|
+
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.
|
|
192
|
+
|
|
193
|
+
- **Network Boundary Validation**: Only authorized CTF targets are permitted:
|
|
194
|
+
- Local loopback: `127.0.0.1`, `localhost`, `::1`
|
|
195
|
+
- RFC1918 private subnets: `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`
|
|
196
|
+
- Authorized CTF domains & competition platforms: `*.challs.io`, `*.picoctf.net`, `*.ctfd.io`, `*.tryhackme.com`, `*.hackthebox.com`, `*.flagyard.com`, and localhost ports.
|
|
197
|
+
- Arbitrary external IP addresses and unauthorized internet endpoints are rejected with explicit policy violations.
|
|
198
|
+
- **Prohibited Action Guard**: Automatically intercepts and blocks commands containing:
|
|
199
|
+
- Destructive disk actions (`rm -rf /`, `mkfs`, `dd if=/dev/zero`)
|
|
200
|
+
- Backdoor persistence mechanisms (`crontab`, systemd services, SSH key installation in `~/.ssh/authorized_keys`, root password modification)
|
|
201
|
+
- Wide automated network sweeps (`nmap -iR`, masscan against external CIDR blocks)
|
|
202
|
+
- **Runtime Execution**:
|
|
203
|
+
```bash
|
|
204
|
+
# Validate a target endpoint before probing:
|
|
205
|
+
python scripts/scope_guard.py http://127.0.0.1:8080
|
|
206
|
+
|
|
207
|
+
# Validate a diagnostic CLI command before running:
|
|
208
|
+
python scripts/scope_guard.py --command "checksec --file=chall"
|
|
209
|
+
|
|
210
|
+
# Generate a formal Security Context Object (SCO):
|
|
211
|
+
python scripts/scope_guard.py --target http://chall.ctf.site:9000 --json
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Specialized Category Skills
|
|
217
|
+
|
|
218
|
+
`CTF-Agent` equips models with 11 domain-specific skills accessible via slash commands or subagent delegation:
|
|
219
|
+
|
|
220
|
+
| Skill | Description | Key Capabilities |
|
|
221
|
+
|:---|:---|:---|
|
|
222
|
+
| [`solve-challenge`](skills/solve-challenge/SKILL.md) | **Master Dispatcher & Orchestrator** | Hint-First triage, category routing, mode branching (Blitz vs Deep). |
|
|
223
|
+
| [`ctf-web`](skills/ctf-web/SKILL.md) | **Web Vulnerability Assessment** | SQLi, SSTI, JWT verification, prototype pollution, RSC Flight RCE, SSRF. |
|
|
224
|
+
| [`ctf-pwn`](skills/ctf-pwn/SKILL.md) | **Binary Security Analysis** | Glibc heap (House of Apple 2, TLS dtors), ROP, ret2libc, boundary testing. |
|
|
225
|
+
| [`ctf-crypto`](skills/ctf-crypto/SKILL.md) | **Cryptanalysis & Math** | RSA, ECC, LLL/BKZ lattice reduction, HNP/CVP, padding oracle, ZKP. |
|
|
226
|
+
| [`ctf-reverse`](skills/ctf-reverse/SKILL.md) | **Reverse Engineering** | Anti-analysis, custom VMs, WASM, `.pyc` (`pycdc`), Ghidra/radare2/GDB. |
|
|
227
|
+
| [`ctf-forensics`](skills/ctf-forensics/SKILL.md) | **Digital Forensics** | Memory dumps (Volatility 3), PCAP analysis, disk recovery, steganography. |
|
|
228
|
+
| [`ctf-ai-ml`](skills/ctf-ai-ml/SKILL.md) | **AI & Machine Learning** | Adversarial ML, model robustness, extraction evaluation, AI puzzle triage. |
|
|
229
|
+
| [`ctf-osint`](skills/ctf-osint/SKILL.md) | **Open Source Intelligence** | Geolocation, social media tracking, Tor relay tracing, DNS footprinting. |
|
|
230
|
+
| [`ctf-misc`](skills/ctf-misc/SKILL.md) | **Miscellaneous & Jails** | PyJails, bash jails, esoteric encodings, RF/SDR signals, game reversing. |
|
|
231
|
+
| [`ctf-malware`](skills/ctf-malware/SKILL.md) | **Malware Analysis** | C2 protocol decoding, PE/.NET unpackers, obfuscated script analysis. |
|
|
232
|
+
| [`ctf-writeup`](skills/ctf-writeup/SKILL.md) | **Write-up Generator** | Standardized 5-section submission writeup and directory organizer. |
|
|
233
|
+
|
|
234
|
+
### Custom Skill Extension & Envelope Validation
|
|
235
|
+
|
|
236
|
+
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:
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
# Validate a specific custom skill:
|
|
240
|
+
ctf-agent validate-skill .agents/skills/my-custom-skill
|
|
241
|
+
|
|
242
|
+
# Audit all skills in the workspace:
|
|
243
|
+
ctf-agent validate-skill --all
|
|
244
|
+
|
|
245
|
+
# Via NPX:
|
|
246
|
+
npx ctf-agent validate-skill .agents/skills/my-custom-skill
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
**Compatibility Rules Checked**:
|
|
250
|
+
- **Shallow Orchestration (Depth <= 1)**: Verifies the skill operates as a direct specialist without recursive subagent chaining.
|
|
251
|
+
- **YAML Frontmatter Integrity**: Verifies `name`, `description` (>= 20 chars), and checks against collisions with reserved core skills.
|
|
252
|
+
- **Operational Mode Handling**: Checks for Blitz Mode (Stop-on-Flag) and Deep Mode (RCA / writeup).
|
|
253
|
+
- **LLM Safety Policy Lexicon**: Flags unshielded adversarial triggers (`evil_payload`, `jailbreak`, `weaponize`) and recommends academic diagnostic equivalents.
|
|
254
|
+
- **Command Boundary Guard**: Intercepts destructive host commands (`rm -rf /`, `mkfs`) and backdoor persistence attempts (`crontab`, `authorized_keys`).
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## Parallel Triage & High-Speed Reconnaissance (P0 Engine)
|
|
259
|
+
|
|
260
|
+
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:
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
┌────────────────────────────────┐
|
|
264
|
+
│ Target Challenge Diagnostic │
|
|
265
|
+
└───────────────┬────────────────┘
|
|
266
|
+
│
|
|
267
|
+
┌───────────────────────────────┴───────────────────────────────┐
|
|
268
|
+
▼ ▼
|
|
269
|
+
[Binary / ELF Target] [Web / HTTP Target]
|
|
270
|
+
ThreadPoolExecutor Concurrency ThreadPoolExecutor Concurrency
|
|
271
|
+
- Pure-Python ELF Parser (Arch, Endian, NX, PIE) - HTTP Server & Powered-By Headers
|
|
272
|
+
- checksec security mitigations - /robots.txt & /sitemap.xml leaks
|
|
273
|
+
- strings pattern match (flags, /bin/sh, libc) - Sensitive paths (.git/HEAD, .env)
|
|
274
|
+
- readelf / symbol table analysis - Flag regex candidate pre-scan
|
|
275
|
+
│ │
|
|
276
|
+
└───────────────────────────────┬───────────────────────────────┘
|
|
277
|
+
▼
|
|
278
|
+
┌────────────────────────────────┐
|
|
279
|
+
│ Synthesized Triage Plan │
|
|
280
|
+
│ - Discovered Vulnerabilities │
|
|
281
|
+
│ - Recommended Specialist │
|
|
282
|
+
│ - Immediate Exploit Vector │
|
|
283
|
+
└────────────────────────────────┘
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
- **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.
|
|
287
|
+
- **Concurrent Execution Modes**:
|
|
288
|
+
```bash
|
|
289
|
+
# Concurrent triage of a binary challenge:
|
|
290
|
+
python scripts/parallel_triage.py ./chall.bin
|
|
291
|
+
|
|
292
|
+
# Concurrent triage of a web challenge:
|
|
293
|
+
python scripts/parallel_triage.py http://127.0.0.1:8080
|
|
294
|
+
|
|
295
|
+
# Machine-readable output for automated agent pipelines:
|
|
296
|
+
python scripts/parallel_triage.py ./chall.bin --json
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## Quick Start & Workspace Installation
|
|
302
|
+
|
|
303
|
+
### Method 0: Intelligent Workspace Initialization (Triple-Engine Architecture)
|
|
304
|
+
|
|
305
|
+
```
|
|
306
|
+
┌─────────────────────────────────────────┐
|
|
307
|
+
│ User Workspace Initialization │
|
|
308
|
+
└────────────────────┬────────────────────┘
|
|
309
|
+
│
|
|
310
|
+
┌────────────────────────────────┼────────────────────────────────┐
|
|
311
|
+
▼ ▼ ▼
|
|
312
|
+
[1. Zero-Install NPX] [2. Python Workstation] [3. Modern UV Toolchain]
|
|
313
|
+
npx ctf-agent init ctf-agent init (pip) uvx --from git+... init
|
|
314
|
+
│ │ │
|
|
315
|
+
└────────────────────────────────┼────────────────────────────────┘
|
|
316
|
+
▼
|
|
317
|
+
┌─────────────────────────────────────────┐
|
|
318
|
+
│ Step 1: Preflight Detection │
|
|
319
|
+
│ - OS, CPU, RAM & Disk Storage Free │
|
|
320
|
+
│ - WSL2 & Kali Linux Distro Status │
|
|
321
|
+
│ - Docker CLI & Daemon Connectivity │
|
|
322
|
+
│ - Check for Existing .agents/ Folder │
|
|
323
|
+
└────────────────────┬────────────────────┘
|
|
324
|
+
│
|
|
325
|
+
▼
|
|
326
|
+
┌─────────────────────────────────────────┐
|
|
327
|
+
│ Step 2: Backend Capability Score │
|
|
328
|
+
│ WSL Kali Score vs Docker Daemon Score │
|
|
329
|
+
│ (Objective transparent recommendation)│
|
|
330
|
+
└────────────────────┬────────────────────┘
|
|
331
|
+
│
|
|
332
|
+
▼
|
|
333
|
+
┌─────────────────────────────────────────┐
|
|
334
|
+
│ Step 3: Workload Purpose Selection │
|
|
335
|
+
│ [1] Live CTF: core, pwn, web, crypto │
|
|
336
|
+
│ [2] Security Lab: 10 deep profiles │
|
|
337
|
+
│ [3] Rev & Binary: pwn, rev, kernel │
|
|
338
|
+
│ [4] Full Workstation: all 15 profiles │
|
|
339
|
+
└────────────────────┬────────────────────┘
|
|
340
|
+
│
|
|
341
|
+
▼
|
|
342
|
+
┌─────────────────────────────────────────┐
|
|
343
|
+
│ Step 4: Provision & Conflict Guard │
|
|
344
|
+
│ - If .agents exists: Prompt / Confirm │
|
|
345
|
+
│ - Deploy .agents/ & AGENTS.md config │
|
|
346
|
+
│ - Preserve solve.py & resources/ │
|
|
347
|
+
│ - Provision Toolchain into Backend │
|
|
348
|
+
└────────────────────┬────────────────────┘
|
|
349
|
+
│
|
|
350
|
+
▼
|
|
351
|
+
┌─────────────────────────────────────────┐
|
|
352
|
+
│ Step 5: Health Verification │
|
|
353
|
+
│ Verify subagents, venv & CLI tools │
|
|
354
|
+
│ [OK] WORKSPACE READY TO SOLVE! │
|
|
355
|
+
└─────────────────────────────────────────┘
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
CTF-Agent provides three interchangeable execution engines tailored to different developer environments and host constraints:
|
|
359
|
+
|
|
360
|
+
#### 1. Zero-Install Global NPX (`npx ctf-agent init`) - Recommended Default
|
|
361
|
+
Zero-clone setup for developers accustomed to npm and modern command-line toolchains:
|
|
362
|
+
```bash
|
|
363
|
+
# Initialize current workspace (Zero clone, zero manual install):
|
|
364
|
+
npx ctf-agent init
|
|
365
|
+
|
|
366
|
+
# Target a specific challenge workspace:
|
|
367
|
+
npx ctf-agent init /path/to/ctf-workspace
|
|
368
|
+
|
|
369
|
+
# Run preflight inspection in dry-run mode (zero filesystem writes):
|
|
370
|
+
npx ctf-agent init --dry-run
|
|
371
|
+
|
|
372
|
+
# Or run bleeding-edge unreleased commits directly from GitHub:
|
|
373
|
+
npx github:nvtruongops/CTF-Agent init /path/to/ctf-workspace
|
|
374
|
+
```
|
|
375
|
+
> [!NOTE]
|
|
376
|
+
> **Prerequisites**: Node.js (v18+) and Python 3 (v3.10+). The `ctf-agent` npm package acts as a lightweight global launcher bridge that orchestrates the Python backend engine.
|
|
377
|
+
|
|
378
|
+
#### 2. Native Python Security Workstation (`ctf-agent` / `ctf_agent_cli.py`)
|
|
379
|
+
Pure standard library execution with zero third-party dependencies. Recommended for headless Linux boxes, Kali Linux, offline environments, or systems where Node.js is not installed:
|
|
380
|
+
```bash
|
|
381
|
+
# Scenario A: Globally installed CLI command (available anywhere):
|
|
382
|
+
pip install -e . # run once inside cloned repository
|
|
383
|
+
ctf-agent init /path/to/ctf-workspace
|
|
384
|
+
|
|
385
|
+
# Scenario B: Run directly from cloned repository root:
|
|
386
|
+
python ctf_agent_cli.py init /path/to/ctf-workspace
|
|
387
|
+
|
|
388
|
+
# Automated unattended setup (auto-selects highest-scored backend and purpose):
|
|
389
|
+
ctf-agent init /path/to/ctf-workspace --auto --purpose live-ctf
|
|
390
|
+
|
|
391
|
+
# Preflight analysis and dry-run inspection:
|
|
392
|
+
ctf-agent init --dry-run
|
|
393
|
+
|
|
394
|
+
# Health check verification on an existing workspace:
|
|
395
|
+
ctf-agent init /path/to/ctf-workspace --check-only
|
|
396
|
+
```
|
|
397
|
+
> [!IMPORTANT]
|
|
398
|
+
> **Prevent Relative Path Errors**: Do not execute `python scripts/ctf_init.py` from outside the cloned `CTF-Agent` directory. If you are in an arbitrary target folder without cloning, use `npx ctf-agent init`, the installed `ctf-agent` CLI, or the `uvx` toolchain below.
|
|
399
|
+
|
|
400
|
+
#### 3. Ephemeral Modern Python Toolchain (`uvx`)
|
|
401
|
+
Ultra-fast ephemeral execution powered by the Rust-based `uv` package manager without Node.js or local `venv` activation:
|
|
402
|
+
```bash
|
|
403
|
+
# Execute directly from repository source without cloning or manual installation:
|
|
404
|
+
uvx --from git+https://github.com/nvtruongops/CTF-Agent ctf-agent init
|
|
405
|
+
|
|
406
|
+
# Target a specific workspace:
|
|
407
|
+
uvx --from git+https://github.com/nvtruongops/CTF-Agent ctf-agent init /path/to/ctf-workspace
|
|
408
|
+
|
|
409
|
+
# Automated speedrun profile:
|
|
410
|
+
uvx --from git+https://github.com/nvtruongops/CTF-Agent ctf-agent init --auto --purpose live-ctf
|
|
411
|
+
```
|
|
412
|
+
> [!NOTE]
|
|
413
|
+
> **Why `--from git+...` is Required**: Because `ctf-agent` is hosted on GitHub and npm rather than PyPI, the `--from git+https://github.com/nvtruongops/CTF-Agent` flag directs `uvx` to build directly from the verified source repository.
|
|
414
|
+
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
### Workspace & Skill Updates (`ctf-agent update`)
|
|
418
|
+
|
|
419
|
+
Keep deployed CTF workspaces up to date with new skills, agent personas, rules, and security references without losing custom modifications or challenge files:
|
|
420
|
+
|
|
421
|
+
```bash
|
|
422
|
+
# Method 1: Zero-install NPX:
|
|
423
|
+
npx ctf-agent update /path/to/ctf-workspace
|
|
424
|
+
|
|
425
|
+
# Method 2: Native CLI (if installed via pip or npm link):
|
|
426
|
+
ctf-agent update /path/to/ctf-workspace
|
|
427
|
+
|
|
428
|
+
# Method 3: Ephemeral modern toolchain (uvx):
|
|
429
|
+
uvx --from git+https://github.com/nvtruongops/CTF-Agent ctf-agent update /path/to/ctf-workspace
|
|
430
|
+
|
|
431
|
+
# Method 4: Native Python from cloned repository root:
|
|
432
|
+
python ctf_agent_cli.py update /path/to/ctf-workspace
|
|
433
|
+
|
|
434
|
+
# Preview planned skill & rule updates without writing changes:
|
|
435
|
+
npx ctf-agent update --dry-run
|
|
436
|
+
|
|
437
|
+
# Only synchronize skills (preserve rules, agents, and scripts):
|
|
438
|
+
npx ctf-agent update --skills-only
|
|
439
|
+
|
|
440
|
+
# Update global configuration (~/.gemini/config/):
|
|
441
|
+
python scripts/ctf_update.py --global
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
**Zero Data Loss Guarantees**:
|
|
445
|
+
- **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.
|
|
446
|
+
- **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.
|
|
447
|
+
- **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.
|
|
448
|
+
- **Challenge Assets Protected**: Exploit scripts (`solve.py`), challenge binaries (`resources/`), CTF notes (`notes/`), and credentials (`.env`) are never overwritten or deleted.
|
|
449
|
+
|
|
450
|
+
---
|
|
451
|
+
|
|
452
|
+
### Method 1: Deploy CTF-Agent into a CTF Challenge Project (`.agents/`)
|
|
453
|
+
Deploy CTF-Agent as an `.agents` bundle into any target CTF directory:
|
|
454
|
+
```bash
|
|
455
|
+
# Using symlinks/junctions (live synced with updates):
|
|
456
|
+
python scripts/install_as_agent.py /path/to/ctf-workspace --symlink
|
|
457
|
+
|
|
458
|
+
# Or standalone copy:
|
|
459
|
+
python scripts/install_as_agent.py /path/to/ctf-workspace
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
### Method 2: Global Installation Across All Projects
|
|
463
|
+
Install skills, rules, and subagents globally into `~/.gemini/config/`:
|
|
464
|
+
```bash
|
|
465
|
+
python scripts/install_as_agent.py --global
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
### Method 3: Direct Usage Within This Workspace
|
|
469
|
+
This workspace already has `.agents/` configured. You can start prompting directly using slash commands and text flags:
|
|
470
|
+
- **Master Orchestrator**: `/solve-challenge <target-url-or-dir>`
|
|
471
|
+
- **Speedrun / Blitz Mode (Fast Solve, Stop-on-Flag)**: `/solve-challenge --mode blitz <target>` or `/ctf-web --fast <target>` or `--blitz <prompt>`
|
|
472
|
+
- **Deep Analysis Mode (RCA & Writeup)**: `/solve-challenge --mode deep <target>` or `/ctf-pwn --deep <target>` or `--lab <prompt>`
|
|
473
|
+
- **Specific Category Skills**: `/ctf-web`, `/ctf-pwn`, `/ctf-crypto`, `/ctf-reverse`, `/ctf-forensics`, `/ctf-osint`, `/ctf-misc`, `/ctf-ai-ml`, `/ctf-malware`, `/ctf-writeup`
|
|
474
|
+
|
|
475
|
+
---
|
|
476
|
+
|
|
477
|
+
## Automated Automation Utilities
|
|
478
|
+
|
|
479
|
+
Located in [scripts/](scripts/):
|
|
480
|
+
|
|
481
|
+
- **`parallel_triage.py`**:
|
|
482
|
+
- `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.
|
|
483
|
+
- `python3 scripts/parallel_triage.py <target> --json`: Emits machine-readable diagnostic synthesis with recommended specialist category skills.
|
|
484
|
+
- **`scope_guard.py`**:
|
|
485
|
+
- `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.
|
|
486
|
+
- `python3 scripts/scope_guard.py --target <url> --json`: Generates a formal Security Context Object (SCO) for multi-agent dispatch.
|
|
487
|
+
- **`skill_validator.py`**:
|
|
488
|
+
- `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.
|
|
489
|
+
- `python3 scripts/skill_validator.py --all --json`: Scans all skills across `.agents/skills/` and returns structured JSON reports for CI/CD or agent pipelines.
|
|
490
|
+
- **`prompt_policy_sanitizer.py`**:
|
|
491
|
+
- `python3 scripts/prompt_policy_sanitizer.py "<prompt>" --lang [vi|en]`: Scans, scores policy risk, and sanitizes prompts with academic terminology and educational CTF preambles.
|
|
492
|
+
- `python3 scripts/prompt_policy_sanitizer.py --file <path> --check`: Verifies that challenge writeups, prompts, or scripts do not trigger modern LLM backend filters.
|
|
493
|
+
- **`workspace_cleaner.py`**:
|
|
494
|
+
- `python3 scripts/workspace_cleaner.py --fast`: Purges scratch files (`test*.py`, `fuzz*.py`, `tmp*`), keeping challenge assets and winning `solve.py`.
|
|
495
|
+
- `python3 scripts/workspace_cleaner.py --deep`: Enforces `writeup.md`, `solve.py`, and `resources/` folder structure.
|
|
496
|
+
- **`extract_flags.py`**:
|
|
497
|
+
- `python3 scripts/extract_flags.py "<output>" --banner`: Prints high-visibility flag banner and verifies candidate regex.
|
|
498
|
+
- `python3 scripts/extract_flags.py -f output.log --json`: Emits machine-readable JSON candidate rankings.
|
|
499
|
+
- **`ctfd_client.py`**:
|
|
500
|
+
- Python API client for automated challenge retrieval, attachment downloading, and flag submission.
|
|
501
|
+
- **`cve_lookup.py`**:
|
|
502
|
+
- Automated CVE advisory and exploit lookup utility via Sploitus and Exploit-DB.
|
|
503
|
+
|
|
504
|
+
---
|
|
505
|
+
|
|
506
|
+
## References & Deep Knowledge Base
|
|
507
|
+
|
|
508
|
+
Detailed references offloaded to [references/](references/) to preserve maximum context window tokens during agent turns:
|
|
509
|
+
- [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.
|
|
510
|
+
- [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.
|
|
511
|
+
- [ctf-triage-ladder.md](references/ctf-triage-ladder.md) — Hierarchical 4-Tier progression (Tier 1 plaintext to Tier 4 in-meta).
|
|
512
|
+
- [version-matrix.md](references/version-matrix.md) — Glibc heap, PHP type juggling, and Python bytecode compatibility matrix.
|
|
513
|
+
- [exploit-databases.md](references/exploit-databases.md) — Exploit databases, CVE search, and GitHub PoC repositories.
|
|
514
|
+
- [security-events-and-intelligence.md](references/security-events-and-intelligence.md) — CTFtime intelligence and event key extraction techniques.
|
|
515
|
+
|
|
516
|
+
---
|
|
517
|
+
|
|
518
|
+
## Constitution & Architectural Governance
|
|
519
|
+
|
|
520
|
+
The rules governing all CTF-Agent behavior are defined in [AGENTS.md](AGENTS.md):
|
|
521
|
+
1. **Hint-First Rule**: Analyze metadata and hints before touching code or tools.
|
|
522
|
+
2. **Operational Mode Compliance**: Strictly follow Blitz or Deep Analysis protocols.
|
|
523
|
+
3. **Execution Guard**: Never modify original challenge files; wrap Linux binaries through WSL/Docker; enforce 60s command timeouts.
|
|
524
|
+
4. **Flag Anti-Hallucination**: 100% verified flag strings directly from runtime output.
|
|
525
|
+
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).
|
|
526
|
+
6. **Context Propagation & Task Envelopes**: Propagate machine-readable Security Context Objects and enforce shallow execution depth (max depth: 1).
|
|
527
|
+
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.
|
|
528
|
+
|
|
529
|
+
---
|
|
530
|
+
|
|
531
|
+
### License & Attribution
|
|
532
|
+
Distributed under the MIT License. Designed for authorized security research, academic labs, and ethical CTF competitions.
|