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.
Files changed (152) hide show
  1. package/AGENTS.md +131 -0
  2. package/Dockerfile +192 -0
  3. package/README.md +522 -0
  4. package/agents/ctf-analyzer.md +58 -0
  5. package/agents/ctf-controller.md +151 -0
  6. package/agents/ctf-speedrun.md +74 -0
  7. package/bin/ctf-agent.js +119 -0
  8. package/docker-compose.yml +13 -0
  9. package/mcp_config.json +19 -0
  10. package/package.json +44 -0
  11. package/references/ctf-triage-ladder.md +68 -0
  12. package/references/exploit-databases.md +575 -0
  13. package/references/llm-safety-and-policy-compliance.md +173 -0
  14. package/references/multi-agent-orchestration-and-policy-routing.md +278 -0
  15. package/references/security-events-and-intelligence.md +566 -0
  16. package/references/version-matrix.md +59 -0
  17. package/rules/ctf-execution-rules.md +44 -0
  18. package/rules/ctf-safety-framing-rules.md +140 -0
  19. package/rules/flag-validation-rules.md +25 -0
  20. package/scripts/__init__.py +1 -0
  21. package/scripts/ctf-tools.lock +205 -0
  22. package/scripts/ctf_init.py +1026 -0
  23. package/scripts/ctf_update.py +583 -0
  24. package/scripts/ctfd_client.py +81 -0
  25. package/scripts/cve_lookup.py +453 -0
  26. package/scripts/extract_flags.py +155 -0
  27. package/scripts/install_as_agent.py +278 -0
  28. package/scripts/install_ctf_tools.sh +603 -0
  29. package/scripts/parallel_triage.py +395 -0
  30. package/scripts/prompt_policy_sanitizer.py +283 -0
  31. package/scripts/scope_guard.py +444 -0
  32. package/scripts/skill_validator.py +504 -0
  33. package/scripts/workspace_cleaner.py +141 -0
  34. package/skills/ctf-ai-ml/SKILL.md +120 -0
  35. package/skills/ctf-ai-ml/adversarial-ml.md +623 -0
  36. package/skills/ctf-ai-ml/llm-attacks.md +487 -0
  37. package/skills/ctf-ai-ml/model-attacks.md +422 -0
  38. package/skills/ctf-crypto/SKILL.md +320 -0
  39. package/skills/ctf-crypto/advanced-math.md +798 -0
  40. package/skills/ctf-crypto/classic-ciphers.md +651 -0
  41. package/skills/ctf-crypto/ecc-attacks.md +347 -0
  42. package/skills/ctf-crypto/exotic-crypto-2.md +380 -0
  43. package/skills/ctf-crypto/exotic-crypto.md +528 -0
  44. package/skills/ctf-crypto/historical.md +113 -0
  45. package/skills/ctf-crypto/lattice-and-lwe.md +524 -0
  46. package/skills/ctf-crypto/modern-ciphers-2.md +563 -0
  47. package/skills/ctf-crypto/modern-ciphers-3.md +453 -0
  48. package/skills/ctf-crypto/modern-ciphers.md +649 -0
  49. package/skills/ctf-crypto/prng-attacks.md +257 -0
  50. package/skills/ctf-crypto/prng.md +664 -0
  51. package/skills/ctf-crypto/rsa-attacks-2.md +792 -0
  52. package/skills/ctf-crypto/rsa-attacks.md +487 -0
  53. package/skills/ctf-crypto/stream-ciphers.md +390 -0
  54. package/skills/ctf-crypto/zkp-and-advanced.md +456 -0
  55. package/skills/ctf-forensics/3d-printing.md +121 -0
  56. package/skills/ctf-forensics/SKILL.md +379 -0
  57. package/skills/ctf-forensics/disk-advanced.md +497 -0
  58. package/skills/ctf-forensics/disk-and-memory.md +491 -0
  59. package/skills/ctf-forensics/disk-recovery.md +699 -0
  60. package/skills/ctf-forensics/linux-forensics.md +511 -0
  61. package/skills/ctf-forensics/network-advanced.md +583 -0
  62. package/skills/ctf-forensics/network.md +645 -0
  63. package/skills/ctf-forensics/peripheral-capture.md +287 -0
  64. package/skills/ctf-forensics/signals-and-hardware.md +713 -0
  65. package/skills/ctf-forensics/steganography.md +694 -0
  66. package/skills/ctf-forensics/stego-advanced-2.md +475 -0
  67. package/skills/ctf-forensics/stego-advanced.md +481 -0
  68. package/skills/ctf-forensics/stego-image.md +691 -0
  69. package/skills/ctf-forensics/windows.md +625 -0
  70. package/skills/ctf-malware/SKILL.md +181 -0
  71. package/skills/ctf-malware/c2-and-protocols.md +274 -0
  72. package/skills/ctf-malware/pe-and-dotnet.md +108 -0
  73. package/skills/ctf-malware/scripts-and-obfuscation.md +449 -0
  74. package/skills/ctf-misc/SKILL.md +498 -0
  75. package/skills/ctf-misc/bashjails.md +323 -0
  76. package/skills/ctf-misc/ctfd-navigation.md +465 -0
  77. package/skills/ctf-misc/dns.md +255 -0
  78. package/skills/ctf-misc/encodings-advanced.md +504 -0
  79. package/skills/ctf-misc/encodings.md +431 -0
  80. package/skills/ctf-misc/games-and-vms-2.md +254 -0
  81. package/skills/ctf-misc/games-and-vms-3.md +690 -0
  82. package/skills/ctf-misc/games-and-vms-4.md +229 -0
  83. package/skills/ctf-misc/games-and-vms.md +529 -0
  84. package/skills/ctf-misc/linux-privesc.md +333 -0
  85. package/skills/ctf-misc/pyjails.md +671 -0
  86. package/skills/ctf-misc/rf-sdr.md +91 -0
  87. package/skills/ctf-osint/SKILL.md +198 -0
  88. package/skills/ctf-osint/geolocation-and-media.md +464 -0
  89. package/skills/ctf-osint/social-media.md +312 -0
  90. package/skills/ctf-osint/web-and-dns.md +341 -0
  91. package/skills/ctf-pwn/SKILL.md +214 -0
  92. package/skills/ctf-pwn/advanced-exploits-2.md +579 -0
  93. package/skills/ctf-pwn/advanced-exploits-3.md +598 -0
  94. package/skills/ctf-pwn/advanced-exploits-4.md +590 -0
  95. package/skills/ctf-pwn/advanced-exploits-5.md +119 -0
  96. package/skills/ctf-pwn/advanced-exploits.md +773 -0
  97. package/skills/ctf-pwn/advanced.md +326 -0
  98. package/skills/ctf-pwn/field-notes.md +245 -0
  99. package/skills/ctf-pwn/format-string.md +694 -0
  100. package/skills/ctf-pwn/heap-fsop.md +285 -0
  101. package/skills/ctf-pwn/heap-techniques-2.md +333 -0
  102. package/skills/ctf-pwn/heap-techniques.md +513 -0
  103. package/skills/ctf-pwn/kernel-bypass.md +421 -0
  104. package/skills/ctf-pwn/kernel-techniques.md +366 -0
  105. package/skills/ctf-pwn/kernel.md +636 -0
  106. package/skills/ctf-pwn/overflow-basics.md +611 -0
  107. package/skills/ctf-pwn/rop-advanced.md +725 -0
  108. package/skills/ctf-pwn/rop-and-shellcode.md +659 -0
  109. package/skills/ctf-pwn/sandbox-escape.md +313 -0
  110. package/skills/ctf-reverse/SKILL.md +163 -0
  111. package/skills/ctf-reverse/anti-analysis-ctf.md +204 -0
  112. package/skills/ctf-reverse/anti-analysis.md +693 -0
  113. package/skills/ctf-reverse/field-notes.md +376 -0
  114. package/skills/ctf-reverse/languages-compiled.md +666 -0
  115. package/skills/ctf-reverse/languages-platforms.md +592 -0
  116. package/skills/ctf-reverse/languages.md +553 -0
  117. package/skills/ctf-reverse/patterns-ctf-2.md +397 -0
  118. package/skills/ctf-reverse/patterns-ctf-3.md +797 -0
  119. package/skills/ctf-reverse/patterns-ctf.md +670 -0
  120. package/skills/ctf-reverse/patterns-runtime.md +274 -0
  121. package/skills/ctf-reverse/patterns.md +572 -0
  122. package/skills/ctf-reverse/platforms-hardware.md +387 -0
  123. package/skills/ctf-reverse/platforms.md +664 -0
  124. package/skills/ctf-reverse/tools-advanced-2.md +421 -0
  125. package/skills/ctf-reverse/tools-advanced.md +407 -0
  126. package/skills/ctf-reverse/tools-dynamic.md +679 -0
  127. package/skills/ctf-reverse/tools-emulation.md +319 -0
  128. package/skills/ctf-reverse/tools.md +573 -0
  129. package/skills/ctf-web/SKILL.md +153 -0
  130. package/skills/ctf-web/auth-and-access-2.md +82 -0
  131. package/skills/ctf-web/auth-and-access.md +783 -0
  132. package/skills/ctf-web/auth-infra.md +321 -0
  133. package/skills/ctf-web/auth-jwt.md +186 -0
  134. package/skills/ctf-web/client-side-advanced.md +739 -0
  135. package/skills/ctf-web/client-side.md +529 -0
  136. package/skills/ctf-web/cves.md +373 -0
  137. package/skills/ctf-web/field-notes.md +482 -0
  138. package/skills/ctf-web/node-and-prototype.md +200 -0
  139. package/skills/ctf-web/server-side-2.md +337 -0
  140. package/skills/ctf-web/server-side-advanced-2.md +559 -0
  141. package/skills/ctf-web/server-side-advanced-3.md +125 -0
  142. package/skills/ctf-web/server-side-advanced-4.md +480 -0
  143. package/skills/ctf-web/server-side-advanced.md +378 -0
  144. package/skills/ctf-web/server-side-deser.md +443 -0
  145. package/skills/ctf-web/server-side-exec-2.md +799 -0
  146. package/skills/ctf-web/server-side-exec.md +457 -0
  147. package/skills/ctf-web/server-side.md +629 -0
  148. package/skills/ctf-web/sql-injection.md +790 -0
  149. package/skills/ctf-web/web3.md +374 -0
  150. package/skills/ctf-writeup/SKILL.md +90 -0
  151. package/skills/solve-challenge/SKILL.md +269 -0
  152. package/skills.json +16 -0
@@ -0,0 +1,566 @@
1
+ # CTF Intelligence, Events & Challenge Artifact Analysis Guide (v2.0)
2
+ ## Operational Architecture for Event Monitoring, CTF Intelligence, Challenge Triage, Platform Automation, and Artifact Verification
3
+
4
+ > **Scope**: This reference handbook is strictly designed for authorized CTF competitions, educational security labs, controlled challenge infrastructure, and permitted offensive research.
5
+
6
+ ---
7
+
8
+ ## 1. Scope & Authorization Boundaries
9
+
10
+ In competitive CTFs and controlled educational labs, maintaining clear operational boundaries is mandatory:
11
+
12
+ ```
13
+ ┌────────────────────────────────────────────────────────────────────────────────────────┐
14
+ │ OPERATIONAL BOUNDARY SEPARATION │
15
+ ├───────────────────────────────────────────┬────────────────────────────────────────────┤
16
+ │ CHALLENGE ARTIFACTS (IN-SCOPE) │ UNAUTHORIZED HARVESTING (OUT-OF-SCOPE) │
17
+ ├───────────────────────────────────────────┼────────────────────────────────────────────┤
18
+ │ - Deliberately seeded flags & tokens │ - Attacking competition CTFd server hosts │
19
+ │ - Challenge service source code & files │ - Compromising organizer cloud accounts │
20
+ │ - Target container filesystem & state │ - Sniffing unrelated platform traffic │
21
+ │ - Intentionally exposed lab metadata │ - Destructive Denial of Service (DoS) │
22
+ └───────────────────────────────────────────┴────────────────────────────────────────────┘
23
+ ```
24
+
25
+ - **Challenge Artifact Analysis**: The systematic inspection of challenge-provided files, binaries, network protocols, environment variables, and target filesystem locations intentionally structured by the challenge author.
26
+ - **Rules of Engagement (RoE)**: All actions must remain strictly bounded by the rules of the specific competition or lab platform.
27
+
28
+ ---
29
+
30
+ ## 2. Security Event Monitoring (Industry Arenas & Research Conferences)
31
+
32
+ Major CTF challenges frequently adapt attack techniques and root causes presented at elite security events and academic conferences:
33
+
34
+ ```
35
+ ┌────────────────────────────────────────────────────────────────────────────────────────┐
36
+ │ SECURITY EVENT MONITORING HIERARCHY │
37
+ ├────────────────────────────┬────────────────────────────┬──────────────────────────────┤
38
+ │ Offensive / Exploitation │ Academic Security Research │ CTF / Premier Competitions │
39
+ │ (0-Days, Mitigations, PoC) │ (Theory, Crypto, Systems) │ (Hands-on Challenge Puzzles) │
40
+ ├────────────────────────────┼────────────────────────────┼──────────────────────────────┤
41
+ │ - Pwn2Own / ZDI │ - USENIX Security │ - CTFtime │
42
+ │ - OffensiveCon (Berlin) │ - ACM CCS │ - DEF CON CTF │
43
+ │ - Black Hat Briefings │ - IEEE S&P (Oakland) │ - Real World CTF │
44
+ │ - DEF CON Presentations │ - NDSS │ - Google CTF │
45
+ │ - REcon / Zero Nights │ - WOOT / RAID │ - PlaidCTF / picoCTF │
46
+ └────────────────────────────┴────────────────────────────┴──────────────────────────────┘
47
+ ```
48
+
49
+ ### 2.1. Pwn2Own Arena (Zero Day Initiative)
50
+ - **Portal:** `https://www.zerodayinitiative.com/blog`
51
+ - **Distinguishing Fact from Community Observation**:
52
+ - **Fact**: Pwn2Own is one of the world's most prominent public vulnerability research and exploitation competitions (organized annually across Vancouver, Toronto, and Automotive editions). Targets span major enterprise operating systems (Ubuntu, Windows 11, macOS), hypervisors (VMware Workstation, Oracle VirtualBox), modern browsers (Chrome, Edge), and connected automotive platforms.
53
+ - **Community Observation**: Techniques disclosed through Pwn2Own and ZDI research can be useful references for advanced CTF challenge design and vulnerability research. Authors of elite competitions (such as Real World CTF and DEF CON Quals) often construct challenges around similar primitives following public disclosure.
54
+
55
+ ### 2.2. Offensive & Exploitation Conferences
56
+ - **OffensiveCon (Berlin) (`https://www.offensivecon.org/`)**:
57
+ - Deep technical focus on binary exploitation, modern hardware/OS mitigations (CET, MTE, PAC), hypervisors, and browser internals.
58
+ - *Current Meta (2026)*: Focus areas include GPU/kernel exploitation, modern Android exploit chains, browser site isolation internals, QSEE/Wi-Fi firmware exploitation, and complex relational engine (PostgreSQL) internals.
59
+ - **Black Hat Briefings (`https://www.blackhat.com/`)**:
60
+ - Authoritative presentation of novel applied attack techniques (e.g., HTTP request desynchronization, kernel credential corruption, hypervisor escapes). Slides and whitepapers are publicly archived post-event.
61
+ - **DEF CON Presentations & Media Server (`https://media.defcon.org/`)**:
62
+ - Canonical public archive of presentations, recordings, open-source offensive tools, and historical DEF CON CTF challenge repositories from DEF CON 1 to present.
63
+ - **REcon (`https://recon.cx/`) & Zero Nights**:
64
+ - Premier conferences dedicated to reverse engineering, hardware security, firmware extraction, and low-level software analysis.
65
+
66
+ ### 2.3. Academic Security Research Conferences
67
+ - **USENIX Security (`https://www.usenix.org/conferences`)**:
68
+ - Peer-reviewed research on applied systems security, side-channel attacks, microarchitectural vulnerabilities, and memory safety.
69
+ - *Tracking Note*: USENIX Security proceedings are fully open-access (e.g., USENIX Security '26 proceedings published in August 2026; Call for Papers for '27 actively maintained).
70
+ - **ACM CCS, IEEE Symposium on Security and Privacy (S&P / Oakland), NDSS**:
71
+ - The "Big Four" academic conferences disclosing formal cryptanalysis (Lattice/LWE attacks, zero-knowledge proofs), network protocol weaknesses, and automated vulnerability discovery.
72
+ - **WOOT (Workshop on Offensive Technologies) & RAID**:
73
+ - Specializes in unconventional offensive primitives, hardware glitches, and exploit generation methodologies.
74
+
75
+ ### 2.4. Premier CTF Competitions
76
+ - **DEF CON CTF (Quals & Finals)**: The benchmark for elite binary exploitation, zero-day research, and custom architectures.
77
+ - **Real World CTF**: Focuses exclusively on exploiting real-world open-source software, virtualization engines, and network appliances.
78
+ - **Google CTF, PlaidCTF, SekaiCTF, DiceCTF**: Known for cutting-edge web desync, novel cryptography, and sandbox breakouts.
79
+
80
+ ---
81
+
82
+ ## 3. CTF Event Intelligence (CTFtime & Competition Architectures)
83
+
84
+ CTFtime (`https://ctftime.org/`) serves as the global coordination and telemetry platform for security competitions.
85
+
86
+ ```
87
+ ┌────────────────────────────────────────────────────────────────────────────────────────┐
88
+ │ CTFTIME EVENT INTELLIGENCE TAXONOMY │
89
+ ├──────────────────────────┬──────────────────────────┬──────────────────────────────────┤
90
+ │ Lifecycle States │ Competition Formats │ Participation Constraints │
91
+ ├──────────────────────────┼──────────────────────────┼──────────────────────────────────┤
92
+ │ - Upcoming Events │ - Jeopardy │ - Open │
93
+ │ - Currently Running │ - Attack-Defense (A/D) │ - Prequalified │
94
+ │ - Archived Events │ - Hack-quest / KotH │ - Academic / High-school │
95
+ └──────────────────────────┴──────────────────────────┴──────────────────────────────────┘
96
+ ```
97
+
98
+ ### 3.1. Event Lifecycle & Format Classification
99
+ 1. **Event Lifecycle**:
100
+ - **Upcoming**: Track start times, registration URLs, and format rules.
101
+ - **Running**: Active competitions requiring real-time challenge ingestion, scoreboard tracking, and dynamic point monitoring.
102
+ - **Archived**: Historical repositories linking to writeups, challenge source repositories, and participant scoreboards.
103
+ 2. **Competition Formats**:
104
+ - **Jeopardy**: Challenges are divided into discrete categories (Web, Pwn, Crypto, Reverse, Forensics, OSINT, Misc). Teams solve puzzles independently for static or dynamic decaying points.
105
+ - **Attack-Defense (A/D)**:
106
+ - Each team receives an identical virtual machine image hosting multiple vulnerable network services.
107
+ - Games proceed in timed rounds or "ticks" (typically 2–5 minutes).
108
+ - **Offense**: Exploit opponent services and extract periodic tick flags.
109
+ - **Defense**: Patch local service vulnerabilities without breaking Service Level Agreements (SLA check scripts verify service functionality).
110
+ - **Telemetry**: Teams analyze live network traffic (PCAP) to steal and adapt opponents' attack payloads.
111
+ - **Hack-quest / King of the Hill (KotH)**: Sequential penetration testing labs or competitive persistent control over shared target infrastructure.
112
+
113
+ ### 3.2. Dynamic Top Teams & Community Tracking
114
+ To maintain an up-to-date knowledge base, do not rely on static hardcoded lists. Monitor teams and researchers dynamically through:
115
+ - **CTFtime Global Rankings**: Track top-performing teams across seasons.
116
+ - **Event Scoreboards**: Identify specialized teams consistently dominating specific categories (e.g., dedicated pwn or crypto researchers).
117
+ - **Public Writeup Repositories & Team GitHub Orgs**: Follow active research publications from leading teams.
118
+
119
+ ---
120
+
121
+ ## 4. Threat & Vulnerability Intelligence (Disaggregated)
122
+
123
+ Do not conflate general threat reporting with vulnerability intelligence or CTF intelligence:
124
+
125
+ ```
126
+ ┌────────────────────────────────────────────────────────────────────────────────────────┐
127
+ │ INTELLIGENCE TAXONOMY COMPARISON │
128
+ ├─────────────────────────┬─────────────────────────────┬────────────────────────────────┤
129
+ │ Threat Intelligence │ CVE / Exploit Intelligence │ CTF Intelligence │
130
+ ├─────────────────────────┼─────────────────────────────┼────────────────────────────────┤
131
+ │ Focus: Threat actors, │ Focus: Vulnerability IDs, │ Focus: Challenge design, │
132
+ │ campaigns, botnets, │ CVSS, patch diffs, KEV, │ author intent, primitives, │
133
+ │ malware hashes, wild C2 │ EPSS, public PoC exploits │ hints, writeups, flags │
134
+ └─────────────────────────┴─────────────────────────────┴────────────────────────────────┘
135
+ ```
136
+
137
+ ### 4.1. Priority Intelligence & Technical Disclosures
138
+ - **Priority Intelligence — CISA KEV (`cisa.gov/known-exploited-vulnerabilities-catalog`)**:
139
+ - Mandatory catalog of confirmed, actively exploited vulnerabilities in the wild. If a challenge or lab replicates a CVE listed in KEV, reliable weaponized exploit techniques exist.
140
+ - **Technical Disclosures — Openwall oss-security (`openwall.com/lists/oss-security/`)**:
141
+ - High-signal technical mailing list where Linux kernel, glibc, systemd, and OpenSSH maintainers discuss coordinated vulnerability disclosures and root-cause analyses.
142
+ - **Network Threat Telemetry — SANS Internet Storm Center (ISC) (`isc.sans.edu/`)**:
143
+ - Global honeypot network telemetry, daily handler diaries, and real-world packet capture breakdowns.
144
+
145
+ ### 4.2. Security News & Secondary Reporting
146
+ - **The Hacker News (THN) (`thehackernews.com/`)**:
147
+ - Rapid secondary reporting on emerging 0-days, supply-chain incidents, and emergency patches. Useful for discovery, but always follow source links to primary advisories.
148
+ - **BleepingComputer (`bleepingcomputer.com/`)**:
149
+ - Detailed secondary reporting on ransomware attack vectors, active exploitation campaigns, and vendor advisories.
150
+
151
+ ### 4.3. Threat Research & Malware Intelligence
152
+ - **vx-underground (`vx-underground.org/`)**:
153
+ - Specialized archive of malware samples, Proof-of-Concept exploits, and technical threat research papers.
154
+ - > [!CAUTION]
155
+ > **Compliance Notice**: Access and handle material from malware repositories only where legally permitted, within properly isolated analysis sandboxes, and in full compliance with organizational security policies.
156
+
157
+ ---
158
+
159
+ ## 5. Challenge Triage & Knowledge Graph
160
+
161
+ ### 5.1. The Challenge Triage Pipeline
162
+
163
+ When ingesting a new CTF challenge, follow this systematic progression:
164
+
165
+ ```
166
+ ┌────────────────────────────────────────────────────────────────────────┐
167
+ │ 1. CHALLENGE INGESTION & HINT-FIRST SEMANTIC SCOPING │
168
+ │ Parse Title, Prompt, and Official Hints. Prune rabbit holes. │
169
+ └──────────────────────────────────┬─────────────────────────────────────┘
170
+
171
+
172
+ ┌────────────────────────────────────────────────────────────────────────┐
173
+ │ 2. ARTIFACT EXTRACTION │
174
+ │ Collect challenge files: Dockerfile, binaries, PCAPs, manifests. │
175
+ └──────────────────────────────────┬─────────────────────────────────────┘
176
+
177
+
178
+ ┌────────────────────────────────────────────────────────────────────────┐
179
+ │ 3. TECHNOLOGY & VERSION FINGERPRINTING │
180
+ │ Identify programming language, framework, dependencies, glibc. │
181
+ └──────────────────────────────────┬─────────────────────────────────────┘
182
+
183
+
184
+ ┌────────────────────────────────────────────────────────────────────────┐
185
+ │ 4. ARCHITECTURE BRANCHING │
186
+ │ ├─ Source Code Available? ──> Static Audit & Sink Tracing │
187
+ │ ├─ Known N-Day Software? ──> Query Exploit-Databases Handbook │
188
+ │ └─ Black-box / Custom? ──> Input Fuzzing & Triage Ladder │
189
+ └──────────────────────────────────┬─────────────────────────────────────┘
190
+
191
+
192
+ ┌────────────────────────────────────────────────────────────────────────┐
193
+ │ 5. PRIOR WRITEUP & VARIANT ANALYSIS │
194
+ │ Search CTFtime writeups and GitHub for identical/forked problems. │
195
+ └──────────────────────────────────┬─────────────────────────────────────┘
196
+
197
+
198
+ ┌────────────────────────────────────────────────────────────────────────┐
199
+ │ 6. HYPOTHESIS FORMULATION, REPRODUCTION & FLAG EXTRACTION │
200
+ │ Reproduce locally in Docker -> Trigger remote -> Validate Flag. │
201
+ └────────────────────────────────────────────────────────────────────────┘
202
+ ```
203
+
204
+ ### 5.2. The Challenge Intelligence Graph
205
+ Structure competition knowledge as an interconnected graph rather than disconnected text files:
206
+
207
+ ```
208
+ ┌──────────────┐
209
+ │ Event │
210
+ └───┬──────┬───┘
211
+ │ │
212
+ ┌───────┘ └────────┐
213
+ ▼ ▼
214
+ ┌──────────────┐ ┌──────────────┐
215
+ │ Organizer │ │ Challenge │
216
+ └──────────────┘ └───┬──────┬───┘
217
+ │ │
218
+ ┌───────────────┘ └──────────────┐
219
+ ▼ ▼
220
+ ┌──────────────────────┐ ┌──────────────────────┐
221
+ │ Technology / Stack │ │ Intended Primitive │
222
+ │ (e.g., glibc 2.39) │ │ (e.g., FSOP Apple 2) │
223
+ └──────────┬───────────┘ └──────────┬───────────┘
224
+ │ │
225
+ ▼ ▼
226
+ ┌──────────────────────┐ ┌──────────────────────┐
227
+ │ Associated CVE/GHSA │ │ Public Writeups / │
228
+ │ (Exploit Handbook) │ │ Researcher GitHub │
229
+ └──────────────────────┘ └──────────────────────┘
230
+ ```
231
+
232
+ **Common Knowledge Graph Queries for CTF Agents**:
233
+ - `CVE -> CTF Challenge`: Which past challenges featured this specific vulnerability?
234
+ - `Technology -> Primitives`: What are the standard bypasses for this framework version?
235
+ - `Researcher -> Writeups`: How did top researchers solve similar challenges?
236
+
237
+ ---
238
+
239
+ ## 6. CTFd Platform API Automation & Integration
240
+
241
+ When participating in competitions hosted on CTFd, automated interaction eliminates manual web clicking and accelerates telemetry collection.
242
+
243
+ ### 6.1. Authentication Standard
244
+ - CTFd API tokens are generated via `Settings` $\rightarrow$ `Access Tokens`.
245
+ - Send tokens in the HTTP Authorization header:
246
+ ```http
247
+ Authorization: Token <access_token>
248
+ ```
249
+ *(Do not assume a mandatory `ctfd_` prefix; store the full token verbatim).*
250
+
251
+ ### 6.2. Core CTFd REST API Endpoints
252
+ The CTFd API disaggregates challenge metadata, downloadable attachments, and hints:
253
+
254
+ | Method | Endpoint | Description |
255
+ | :--- | :--- | :--- |
256
+ | `GET` | `/api/v1/challenges` | List all challenges (id, name, category, value, state). |
257
+ | `GET` | `/api/v1/challenges/{id}` | Retrieve detailed challenge description and connection host/port. |
258
+ | `GET` | `/api/v1/challenges/{id}/files` | **Downloadable challenge file URLs and hashes.** |
259
+ | `GET` | `/api/v1/challenges/{id}/hints` | List available or unlocked hints. |
260
+ | `GET` | `/api/v1/challenges/{id}/tags` | Metadata tags (e.g., `web`, `pwn`, `sandbox`). |
261
+ | `GET` | `/api/v1/challenges/{id}/topics` | Academic or technical topics. |
262
+ | `POST` | `/api/v1/challenges/attempt` | Submit a flag candidate: `{"challenge_id": 1, "submission": "flag{...}"}`. |
263
+ | `GET` | `/api/v1/scoreboard` | Real-time team standings and point progression. |
264
+
265
+ ### 6.3. API Discovery, Pagination & Robustness
266
+ - **Pagination**: Large competitions paginate `/api/v1/challenges?page=2`. Scripts must iterate through all pages until `data` is empty or `meta.pagination.pages` is reached.
267
+ - **Rate Limiting**: Handle HTTP `429 Too Many Requests` by honoring the `Retry-After` header or applying exponential backoff.
268
+ - **Error Handling**: Gracefully handle locked challenges (`403 Forbidden`) and platform pauses.
269
+
270
+ ---
271
+
272
+ ## 7. Flag Candidate Extraction & Validation Pipeline
273
+
274
+ ### 7.1. Limitations of Naive Regex Matching
275
+ Simple regular expressions like `re.findall(r'flag\{[^\}]+\}', text, re.I)` produce severe failure modes:
276
+ 1. **Format Variations**: Flags frequently omit curly braces (e.g., `FLAG-4a7b-8c9d`, `CTF:secret_token_123`, `token=abc123xyz`).
277
+ 2. **Unicode & Character Sets**: Modern challenges include extended ASCII, UTF-8 byte sequences, or base64 strings.
278
+ 3. **Case Sensitivity & False Positives**: `re.IGNORECASE` matches error messages, HTML comments, or debugging strings like `flag{example_flag}`.
279
+ 4. **Context Blindness**: A regex match does not verify whether the string originated from the challenge output or unrelated system logs.
280
+
281
+ ### 7.2. Multi-Stage Flag Validation Pipeline
282
+
283
+ ```
284
+ ┌────────────────────────────────────────────────────────────────────────┐
285
+ │ STAGE 1: CANDIDATE EXTRACTION │
286
+ │ Extract candidate strings from stdout, HTTP response, files, memory. │
287
+ └──────────────────────────────────┬─────────────────────────────────────┘
288
+
289
+
290
+ ┌────────────────────────────────────────────────────────────────────────┐
291
+ │ STAGE 2: NORMALIZATION & DEDUPLICATION │
292
+ │ Strip trailing whitespace, unescape quotes, decode URL/hex encodings. │
293
+ └──────────────────────────────────┬─────────────────────────────────────┘
294
+
295
+
296
+ ┌────────────────────────────────────────────────────────────────────────┐
297
+ │ STAGE 3: FORMAT & REGEX VALIDATION │
298
+ │ Verify against competition flag pattern (or fall back to heuristics). │
299
+ └──────────────────────────────────┬─────────────────────────────────────┘
300
+
301
+
302
+ ┌────────────────────────────────────────────────────────────────────────┐
303
+ │ STAGE 4: CONTEXT & CONFIDENCE SCORING │
304
+ │ Score candidate: source reliability, keyword proximity, entropy. │
305
+ └──────────────────────────────────┬─────────────────────────────────────┘
306
+
307
+
308
+ ┌────────────────────────────────────────────────────────────────────────┐
309
+ │ STAGE 5: SUBMISSION & CONFIRMATION │
310
+ │ Submit via CTFd API. Record 1.00 confidence only upon server accept. │
311
+ └────────────────────────────────────────────────────────────────────────┘
312
+ ```
313
+
314
+ ### 7.3. FlagCandidate Data Model & Confidence Scoring
315
+
316
+ ```python
317
+ from dataclasses import dataclass
318
+ from typing import Optional
319
+
320
+ @dataclass
321
+ class FlagCandidate:
322
+ value: str
323
+ source: str # e.g., 'terminal_output', 'http_body', 'memory_carve', 'file'
324
+ location: Optional[str] # e.g., '/flag.txt', 'Header:X-Flag', 'PID:1337'
325
+ confidence: float # Numeric score between 0.0 and 1.0
326
+ ```
327
+
328
+ **Confidence Scoring Rubric**:
329
+ - **0.30 (Weak Candidate)**: Matched generic token or high-entropy hex string without definitive challenge flag prefix.
330
+ - **0.60 (Probable Candidate)**: Matches known competition format prefix (`flag{...}`), but extracted from unverified or broad application logs.
331
+ - **0.90 (Strong Candidate)**: Matches flag format and was directly exfiltrated from the primary exploit trigger (e.g., output of `/bin/sh -c cat /flag*` or decrypted cipher output).
332
+ - **1.00 (Confirmed Flag)**: Accepted by the CTFd competition platform API with a successful solve response (`status: correct`).
333
+
334
+ ---
335
+
336
+ ## 8. Authorized Challenge Instance Artifact Analysis
337
+
338
+ When operating inside an authorized target container or remote instance following RCE or Arbitrary File Read, inspect artifacts systematically across five distinct architectural levels:
339
+
340
+ ```
341
+ ┌────────────────────────────────────────────────────────────────────────┐
342
+ │ LEVEL 1: FILESYSTEM ARTIFACTS │
343
+ │ - Root & application directories: /flag, /flag.txt, /flag.sh │
344
+ │ - Web server roots: /app/flag.txt, /var/www/html/flag* │
345
+ │ - User & temporary storage: /home/*/flag*, /root/flag*, /tmp/flag* │
346
+ └──────────────────────────────────┬─────────────────────────────────────┘
347
+
348
+
349
+ ┌────────────────────────────────────────────────────────────────────────┐
350
+ │ LEVEL 2: ENVIRONMENT ARTIFACTS │
351
+ │ - Current process environment: /proc/self/environ, `env`, `export` │
352
+ │ - Container init environment: /proc/1/environ (Docker -e FLAG=...) │
353
+ └──────────────────────────────────┬─────────────────────────────────────┘
354
+
355
+
356
+ ┌────────────────────────────────────────────────────────────────────────┐
357
+ │ LEVEL 3: APPLICATION STATE ARTIFACTS │
358
+ │ - SQLite databases, session files, cached tokens, redis instances │
359
+ └──────────────────────────────────┬─────────────────────────────────────┘
360
+
361
+
362
+ ┌────────────────────────────────────────────────────────────────────────┐
363
+ │ LEVEL 4: PROCESS INSPECTION │
364
+ │ - Command line arguments: /proc/<pid>/cmdline │
365
+ │ - Open file descriptors: /proc/<pid>/fd/ │
366
+ │ - Process working directories: /proc/<pid>/cwd │
367
+ └──────────────────────────────────┬─────────────────────────────────────┘
368
+
369
+
370
+ ┌────────────────────────────────────────────────────────────────────────┐
371
+ │ LEVEL 5: ADVANCED PROCESS MEMORY ANALYSIS (RESEARCH PRIMITIVE) │
372
+ │ - Inspecting virtual memory: /proc/<pid>/mem, /proc/<pid>/maps, GDB │
373
+ └────────────────────────────────────────────────────────────────────────┘
374
+ ```
375
+
376
+ ### Level 5 Caveats (Process Memory Inspection):
377
+ Reading `/proc/<pid>/mem` or attaching debuggers is governed by strict OS security controls:
378
+ - **User ID Matching**: You cannot read memory of processes owned by another user without root privileges.
379
+ - **Linux Yama LSM (`kernel.yama.ptrace_scope`)**: A `ptrace_scope` of 1 or 2 blocks non-child process memory inspection even for the same UID.
380
+ - **Container Privileges**: Standard Docker containers drop `CAP_SYS_PTRACE`. Memory inspection fails unless the container was spawned with `--cap-add=SYS_PTRACE` or `--privileged`.
381
+
382
+ ---
383
+
384
+ ## 9. Cloud & Container Challenge Artifacts
385
+
386
+ In specialized cloud security CTFs (e.g., Cloud Village, HTB Cloud Labs):
387
+
388
+ > [!IMPORTANT]
389
+ > **Strict Authorization Scope**: Only inspect metadata endpoints, service-account material, or mounted container secrets when:
390
+ > 1. The challenge explicitly includes a cloud/container environment;
391
+ > 2. The target infrastructure is owned or authorized for testing;
392
+ > 3. Access is strictly within the challenge scope.
393
+
394
+ ### Standard Cloud & Container Artifact Locations:
395
+ 1. **Kubernetes Service Account Tokens**:
396
+ - Path: `/var/run/secrets/kubernetes.io/serviceaccount/token`
397
+ - Namespace: `/var/run/secrets/kubernetes.io/serviceaccount/namespace`
398
+ 2. **Container Secret Mounts**:
399
+ - Path: `/run/secrets/`
400
+ 3. **Instance Metadata Services (IMDS)**:
401
+ - AWS IMDSv1: `http://169.254.169.254/latest/meta-data/`
402
+ - AWS IMDSv2: Requires `X-aws-ec2-metadata-token` retrieved via `PUT /latest/api/token`.
403
+ - GCP Metadata: `http://metadata.google.internal/computeMetadata/v1/` (requires `Metadata-Flavor: Google` header).
404
+
405
+ ---
406
+
407
+ ## 10. Writeup Intelligence & Knowledge Retrieval
408
+
409
+ Upon solving a challenge, extract and structure operational intelligence to benefit future engagements:
410
+ - **Challenge Taxonomy Tagging**: Categorize by framework (e.g., Next.js, glibc 2.39, Flask), vulnerability class (e.g., Prototype Pollution, FSOP), and difficulty.
411
+ - **Searchable Writeup Archive**: Maintain writeups following the `skills/ctf-writeup/SKILL.md` standard.
412
+ - **Correlating External Writeups**: When blocked during training, search CTFtime and GitHub using exact error strings and function names to analyze approaches taken by top teams.
413
+
414
+ ---
415
+
416
+ ## 11. Production-Ready Python Automation Utilities
417
+
418
+ ### 11.1. Robust Flag Candidate Extraction Engine
419
+ Save as `scripts/extract_flags.py`:
420
+
421
+ ```python
422
+ #!/usr/bin/env python3
423
+ """
424
+ Flag Candidate Extraction Engine (v2.0)
425
+ Extracts, normalizes, deduplicates, and scores flag candidates from raw text.
426
+ """
427
+
428
+ import re
429
+ from dataclasses import dataclass
430
+ from typing import List, Optional
431
+
432
+ @dataclass
433
+ class FlagCandidate:
434
+ value: str
435
+ source: str
436
+ location: Optional[str]
437
+ confidence: float
438
+
439
+ # Common competition flag patterns
440
+ FLAG_PATTERNS = [
441
+ (r'flag\{[a-zA-Z0-9_\-\.\!\?@#\$%\^&\*\+=]+\}', 0.90),
442
+ (r'CTF\{[a-zA-Z0-9_\-\.\!\?@#\$%\^&\*\+=]+\}', 0.90),
443
+ (r'picoCTF\{[^\}]+\}', 0.90),
444
+ (r'Dice\{[^\}]+\}', 0.90),
445
+ (r'SEKAI\{[^\}]+\}', 0.90),
446
+ (r'HTB\{[^\}]+\}', 0.90),
447
+ (r'flagyard\{[^\}]+\}', 0.90),
448
+ (r'FLAG-[A-Za-z0-9]{16,64}', 0.80),
449
+ (r'[0-9a-fA-F]{32}', 0.30), # Raw MD5-like candidate (weak)
450
+ ]
451
+
452
+ def extract_flag_candidates(raw_text: str, source: str = "terminal", location: Optional[str] = None) -> List[FlagCandidate]:
453
+ candidates = []
454
+ seen = set()
455
+
456
+ for pattern, base_conf in FLAG_PATTERNS:
457
+ matches = re.findall(pattern, raw_text)
458
+ for m in matches:
459
+ cleaned = m.strip()
460
+ if cleaned not in seen:
461
+ seen.add(cleaned)
462
+ # Boost confidence if extracted from primary target locations
463
+ conf = base_conf
464
+ if location and any(k in location for k in ("flag.txt", "/flag", "environ")):
465
+ conf = min(1.0, conf + 0.10)
466
+ candidates.append(FlagCandidate(value=cleaned, source=source, location=location, confidence=conf))
467
+
468
+ return sorted(candidates, key=lambda c: c.confidence, reverse=True)
469
+ ```
470
+
471
+ ### 11.2. Complete CTFd Platform API Client
472
+ Save as `scripts/ctfd_client.py`:
473
+
474
+ ```python
475
+ #!/usr/bin/env python3
476
+ """
477
+ CTFd Platform Automation Client (v2.0)
478
+ Handles authentication, pagination, challenge files, hints, and flag submission.
479
+ """
480
+
481
+ import os
482
+ import json
483
+ import time
484
+ import urllib.request
485
+ import urllib.error
486
+ from typing import Optional, Dict, Any, List
487
+
488
+ class CTFdClient:
489
+ def __init__(self, base_url: str, api_token: str):
490
+ self.base_url = base_url.rstrip("/")
491
+ self.headers = {
492
+ "Authorization": f"Token {api_token}",
493
+ "Content-Type": "application/json",
494
+ "User-Agent": "CTF-Agent-PlatformClient/2.0"
495
+ }
496
+
497
+ def _request(self, method: str, endpoint: str, data: Optional[Dict[str, Any]] = None) -> Optional[Dict[str, Any]]:
498
+ url = f"{self.base_url}/api/v1/{endpoint.lstrip('/')}"
499
+ payload = json.dumps(data).encode("utf-8") if data else None
500
+ req = urllib.request.Request(url, data=payload, headers=self.headers, method=method)
501
+
502
+ for attempt in range(3):
503
+ try:
504
+ with urllib.request.urlopen(req, timeout=10) as resp:
505
+ return json.loads(resp.read().decode("utf-8"))
506
+ except urllib.error.HTTPError as e:
507
+ if e.code == 429:
508
+ time.sleep(2 ** attempt)
509
+ continue
510
+ return None
511
+ except Exception:
512
+ return None
513
+ return None
514
+
515
+ def get_challenges(self) -> List[Dict[str, Any]]:
516
+ """Retrieve all challenges across all paginated pages."""
517
+ all_challenges = []
518
+ page = 1
519
+ while True:
520
+ res = self._request("GET", f"challenges?page={page}")
521
+ if not res or not res.get("success") or not res.get("data"):
522
+ break
523
+ all_challenges.extend(res["data"])
524
+ pagination = res.get("meta", {}).get("pagination", {})
525
+ if page >= pagination.get("pages", 1):
526
+ break
527
+ page += 1
528
+ return all_challenges
529
+
530
+ def get_challenge_details(self, challenge_id: int) -> Optional[Dict[str, Any]]:
531
+ res = self._request("GET", f"challenges/{challenge_id}")
532
+ return res.get("data") if res else None
533
+
534
+ def get_challenge_files(self, challenge_id: int) -> List[str]:
535
+ """Fetch distinct attachment URLs for a challenge."""
536
+ res = self._request("GET", f"challenges/{challenge_id}/files")
537
+ if res and res.get("success"):
538
+ return [f.get("location") for f in res.get("data", [])]
539
+ return []
540
+
541
+ def get_challenge_hints(self, challenge_id: int) -> List[Dict[str, Any]]:
542
+ res = self._request("GET", f"challenges/{challenge_id}/hints")
543
+ return res.get("data", []) if res else []
544
+
545
+ def submit_flag(self, challenge_id: int, flag: str) -> Dict[str, Any]:
546
+ data = {"challenge_id": challenge_id, "submission": flag}
547
+ res = self._request("POST", "challenges/attempt", data=data)
548
+ if res and res.get("success"):
549
+ status = res.get("data", {}).get("status", "incorrect")
550
+ return {"status": status, "message": res.get("data", {}).get("message", "")}
551
+ return {"status": "error", "message": "Failed to communicate with CTFd"}
552
+ ```
553
+
554
+ ---
555
+
556
+ ## 12. Verification Checklist & Operational Pre-Flight Standards
557
+
558
+ Before concluding work on any CTF challenge or security research task:
559
+
560
+ - [ ] **1. Scoping Check**: Verify all actions were performed strictly within challenge scope and target infrastructure.
561
+ - [ ] **2. Hint & Metadata Documentation**: Document all hints, official descriptions, and title clues analyzed.
562
+ - [ ] **3. Artifact Triage Completed**: Download and categorize all challenge files (source, Dockerfile, PCAPs) into `resources/`.
563
+ - [ ] **4. Root Cause Identified**: State the precise underlying vulnerability or logic flaw.
564
+ - [ ] **5. Flag Candidate Verification**: Confirm candidate flag achieved a 1.00 score via platform API or authoritative challenge verification.
565
+ - [ ] **6. Reproducible Solve Script**: Deliver a standalone `solve.py` script capable of running end-to-end.
566
+ - [ ] **7. Writeup Standard**: Complete `writeup.md` compliant with repository standards.
@@ -0,0 +1,59 @@
1
+ # Version-Aware Exploitation & Compatibility Matrix
2
+ ## Era-Aware Reconnaissance for CTF Competitions & Security Labs
3
+
4
+ Applying modern techniques to legacy environments—or legacy techniques to modern mitigated environments—results in guaranteed failure. Always fingerprint target versions before choosing an attack vector.
5
+
6
+ ---
7
+
8
+ ## 1. Binary Exploitation: GNU C Library (glibc) Matrix
9
+
10
+ Fingerprint the glibc version:
11
+ ```bash
12
+ strings libc.so.6 | grep -i "GNU C Library" | head -1
13
+ ```
14
+
15
+ ### Era Breakdown & Usable Heap Primitives:
16
+
17
+ | Glibc Version | Era | Security Features & Changes | Usable Attack Primitives |
18
+ |:---|:---|:---|:---|
19
+ | **< 2.26** | 2012–2017 | No tcache. Fastbins, unsorted bins, largebins. | Fastbin dup, unsafe unlink, classic House of Orange, House of Force, `__free_hook` / `__malloc_hook`. |
20
+ | **2.26 – 2.30** | 2018–2020 | **Tcache introduced** (max 7 chunks per bin). Low integrity checks. | Direct tcache poisoning (single write corrupts fd), tcache double-free (2.26–2.28), tcache stashing unlink. |
21
+ | **2.31 – 2.33** | 2020–2021 | Double-free mitigation in tcache (key field). **Safe-linking introduced in 2.32** (`(addr >> 12) ^ ptr`). | Must leak heap base address to de-mangle pointers. `__free_hook` still exists and is writable. |
22
+ | **>= 2.34** | 2021–2026+ | **`__free_hook` AND `__malloc_hook` COMPLETELY REMOVED!** Writing to hooks causes crash. | 1. **House of Apple 2** (`_IO_wfile_overflow`).<br>2. TLS destructor overwrite (`__call_tls_dtors` / `__run_exit_handlers`).<br>3. Stack leak via `environ` followed by ROP. |
23
+
24
+ ---
25
+
26
+ ## 2. Web Backend Version Matrix
27
+
28
+ ### PHP Version Nuances
29
+ - **PHP 5.x / 7.x**:
30
+ - **Loose string-to-number comparisons**: `"0e12345" == "0e67890"` evaluates to `true` (magic hash flaw).
31
+ - Numeric type juggling: `0 == "admin"` evaluates to `true`.
32
+ - **PHP 8.x**:
33
+ - **Breaking change**: String-to-number comparisons are now strict. `"0e123" == "0e456"` is `false`. `0 == "admin"` is `false`.
34
+ - **Rule**: Do NOT attempt numeric type juggling or magic hash attacks against PHP 8 targets!
35
+ - Focus on filter chains (`php://filter`), unserialize gadgets, or fastcgi/fpm injection.
36
+
37
+ ### Python Version & Bytecode Decompilation
38
+ - **Python 2.7**:
39
+ - `input()` performs direct `eval()` on user input.
40
+ - `uncompyle6` decompiles `.pyc` files cleanly.
41
+ - **Python 3.8 – 3.10**:
42
+ - Standard PyJail breakout via `__subclasses__()`, `builtins`, `sys.modules`.
43
+ - Bytecode formats are standard; decompilation via `uncompyle6` or `decompyle++` (`pycdc`).
44
+ - **Python 3.11 – 3.12+**:
45
+ - **PEP 709**: Inlined comprehensions, modified frame object structures, optimized bytecode opcodes.
46
+ - `uncompyle6` fails on Python >= 3.11 bytecode!
47
+ - **Rule**: Always use `pycdc` (C++ decompiler) or disassembler `python3 -m dis <file.pyc>` for Python >= 3.11.
48
+
49
+ ---
50
+
51
+ ## 3. Linux Kernel Mitigation Matrix
52
+
53
+ | Feature | Introduced | Bypass Technique |
54
+ |:---|:---|:---|
55
+ | **SMEP** (Supervisor Mode Execution Prevention) | Linux 3.0 | ROP inside kernel space (cannot jump directly to userland shellcode). |
56
+ | **SMAP** (Supervisor Mode Access Prevention) | Linux 3.7 | Pivot stack to kernel space; cannot read/write userland stack directly. |
57
+ | **KASLR** | Linux 3.14 | Memory leak of kernel text address (`_text`, `commit_creds`). |
58
+ | **FG-KASLR** | Linux 5.x | Fine-grained randomization; ROP must use gadgets within leaked function sections. |
59
+ | **SLUB Freelist Hardening** | Linux 4.14+ | Freelist pointers XORed with random cookie. Requires heap base leak. |