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,498 @@
1
+ ---
2
+ name: ctf-misc
3
+ description: Provides miscellaneous CTF challenge techniques for problems that do not cleanly fit the main categories. Use for encoding puzzles, restricted Python/Bash environments (pyjails), RF/SDR signal analysis, DNS oddities, unicode tricks, esoteric languages, QR/audio puzzles, constraint solving, game theory, and sandbox boundary puzzles. Prefer a more specific skill first when the challenge is mainly web, pwn, reverse, forensics, malware, OSINT, or crypto.
4
+ license: MIT
5
+ compatibility: Requires filesystem-based agent (Claude Code or similar) with bash, Python 3, and internet access for tool installation.
6
+ allowed-tools: Bash Read Write Edit Glob Grep Task WebFetch WebSearch Skill
7
+ metadata:
8
+ user-invocable: "false"
9
+ ---
10
+
11
+ # CTF Miscellaneous
12
+
13
+ Quick reference for miscellaneous CTF challenges. Each technique has a one-liner here; see supporting files for full details.
14
+
15
+ ## Prerequisites & Tooling
16
+
17
+ Pre-installed via [scripts/install_ctf_tools.sh](../../scripts/install_ctf_tools.sh):
18
+ - **Python packages**: `z3-solver`, `pwntools`, `Pillow`, `numpy`, `requests`, `dnslib` (in `~/.ctf-tools/venv`)
19
+ - **System binaries**: `ffmpeg`, `qrencode`
20
+ - **Manual tools**: `SageMath`
21
+
22
+ ## Execution Environment & Tool Invocation
23
+
24
+ - **On Windows (WSL Kali Linux)**:
25
+ - Run PyJail exploits, QR decoders, constraint solvers, and sandbox scripts inside WSL:
26
+ ```bash
27
+ wsl -d kali-linux bash -c "source ~/.ctf-tools/venv/bin/activate && python3 solve_pyjail.py"
28
+ wsl -d kali-linux bash -c "qrencode -o qr.png 'data'"
29
+ ```
30
+ - **On Native Linux / WSL**:
31
+ - Activate the CTF virtualenv:
32
+ ```bash
33
+ source ~/.ctf-tools/venv/bin/activate
34
+ ```
35
+ - Use `z3`, `pwntools`, `qrencode`, `ffmpeg`, and `dnslib` directly.
36
+
37
+ ## Additional Resources
38
+
39
+ - [pyjails.md](pyjails.md) - Python jail/sandbox escape techniques, quine context detection, restricted character repunit decomposition, func_globals module chain traversal, restricted charset number generation, class attribute persistence, f-string config injection via stored eval
40
+ - [bashjails.md](bashjails.md) - Bash jail/restricted shell escape techniques, HISTFILE file read trick, bash -v verbose mode, ctypes.sh direct C library calls
41
+ - [encodings.md](encodings.md) - Encodings, QR codes, esolangs, UTF-16 tricks, BCD encoding, multi-layer auto-decoding, indexed directory QR reassembly, multi-stage URL encoding chains
42
+ - [encodings-advanced.md](encodings-advanced.md) - Verilog/HDL, Gray code cyclic encoding, RTF custom tag extraction, SMS PDU decoding, multi-encoding sequential solvers, UTF-9, pixel binary encoding, hexadecimal Sudoku + QR assembly, TOPKEK, MaxiCode
43
+ - [rf-sdr.md](rf-sdr.md) - RF/SDR/IQ signal processing (QAM-16, carrier recovery, timing sync)
44
+ - [dns.md](dns.md) - DNS exploitation (ECS spoofing, NSEC walking, IXFR, rebinding, tunneling)
45
+ - [games-and-vms.md](games-and-vms.md) - WASM patching, Roblox place file reversing, PyInstaller, marshal analysis, Python env RCE, Z3 (including boolean logic gate network SAT solving), K8s RBAC, floating-point precision exploitation, custom assembly language sandbox escape via Python MRO chain
46
+ - [games-and-vms-2.md](games-and-vms-2.md) - Cookie checkpoint game brute-forcing, Flask cookie game state leakage, WebSocket game manipulation, server time-only validation bypass, De Bruijn sequence, Brainfuck instrumentation, WASM linear memory manipulation
47
+ - [games-and-vms-3.md](games-and-vms-3.md) - memfd_create packed binaries, multi-phase crypto games with HMAC commitment-reveal and GF(256) Nim, emulator ROM-switching state preservation, Python marshal code injection, Benford's Law bypass, parallel connection oracle relay, nonogram solver pipelines, 100 prisoners problem, C code jail escape via emoji identifiers, BuildKit daemon build secret exploitation, Docker container escape, Levenshtein distance oracle attack, taint analysis bypass via type coercion, shredded document pixel-edge reassembly
48
+ - [games-and-vms-4.md](games-and-vms-4.md) - Part 4 (2018-era): XSLT as Turing-complete VM, JavaScript MAX_SAFE_INTEGER successor equality, binary search oracle in comparison-only DSL, blind SQLi via script-engine timeout error, OEIS sequence lookup automation, QR code reassembly from format-string constraints, matrix exponentiation for Fibonacci recurrence, Tribonacci for frog-jump counting, Selenium + Tesseract dynamic CAPTCHA, Brainfuck→Piet multi-layer polyglot, bytebeat synth code recognition
49
+ - [linux-privesc.md](linux-privesc.md) - Sudo wildcard parameter injection (fnmatch), crafted pcap for sudoers.d, monit confcheck process injection, Apache -d override, backup cronjob SUID, PostgreSQL COPY TO PROGRAM RCE, PostgreSQL backup credential extraction, NFS share exploitation, SSH Unix socket tunneling, PaperCut Print Deploy privesc, Squid proxy pivoting, Zabbix admin password reset via MySQL, WinSSHTerm credential decryption
50
+ - [ctfd-navigation.md](ctfd-navigation.md) - CTFd platform API navigation without browser: detection, token auth, challenge listing, file download, flag submission, scoreboard, hints, notifications, Python client class
51
+
52
+ ---
53
+
54
+ ## When to Pivot
55
+
56
+ - If the puzzle is actually centered on cryptography or number theory, switch to `/ctf-crypto`.
57
+ - If the challenge is a real binary exploit instead of a jail, toy VM, or encoding problem, switch to `/ctf-pwn` or `/ctf-reverse`.
58
+ - If the input is mostly files, images, audio, or packet captures that need recovery work first, switch to `/ctf-forensics`.
59
+ - For ML/AI techniques (model attacks, adversarial examples, LLM jailbreaking), see `/ctf-ai-ml`.
60
+
61
+ ## Quick Start Commands
62
+
63
+ ```bash
64
+ # File identification
65
+ file mystery_file
66
+ xxd mystery_file | head -5
67
+ python3 -c "import magic; print(magic.from_file('mystery_file'))"
68
+
69
+ # Encoding detection
70
+ python3 -c "import base64; print(base64.b64decode('<data>'))"
71
+ echo '<data>' | base64 -d
72
+ echo '<hex>' | xxd -r -p
73
+
74
+ # QR code
75
+ zbarimg qr.png
76
+ python3 -c "from pyzbar.pyzbar import decode; from PIL import Image; print(decode(Image.open('qr.png')))"
77
+
78
+ # Z3 constraint solving
79
+ python3 -c "from z3 import *; x=BitVec('x',32); s=Solver(); s.add(x^0xdead==0xbeef); s.check(); print(s.model())"
80
+
81
+ # Python jail test
82
+ python3 -c "__import__('os').system('id')"
83
+ ```
84
+
85
+ ## General Tips
86
+
87
+ - Read all provided files carefully
88
+ - Check file metadata, hidden content, encoding
89
+ - Power Automate scripts may hide API calls
90
+ - Use binary search when guessing multiple answers
91
+
92
+ ## Common Encodings
93
+
94
+ ```bash
95
+ # Base64
96
+ echo "encoded" | base64 -d
97
+
98
+ # Base32 (A-Z2-7=)
99
+ echo "OBUWG32D..." | base32 -d
100
+
101
+ # Hex
102
+ echo "68656c6c6f" | xxd -r -p
103
+
104
+ # ROT13
105
+ echo "uryyb" | tr 'a-zA-Z' 'n-za-mN-ZA-M'
106
+ ```
107
+
108
+ **Identify by charset:**
109
+ - Base64: `A-Za-z0-9+/=`
110
+ - Base32: `A-Z2-7=` (no lowercase)
111
+ - Hex: `0-9a-fA-F`
112
+
113
+ See [encodings.md](encodings.md) for Caesar brute force, URL encoding, and full details.
114
+
115
+ ## IEEE-754 Float Encoding (Data Hiding)
116
+
117
+ **Pattern (Floating):** Numbers are float32 values hiding raw bytes.
118
+
119
+ **Key insight:** A 32-bit float is just 4 bytes interpreted as a number. Reinterpret as raw bytes -> ASCII.
120
+
121
+ ```python
122
+ import struct
123
+ floats = [1.234e5, -3.456e-7, ...] # Whatever the challenge gives
124
+ flag = b''
125
+ for f in floats:
126
+ flag += struct.pack('>f', f)
127
+ print(flag.decode())
128
+ ```
129
+
130
+ **Variations:** Double `'>d'`, little-endian `'<f'`, mixed. See [encodings.md](encodings.md) for CyberChef recipe.
131
+
132
+ ## USB Mouse PCAP Reconstruction
133
+
134
+ **Pattern (Hunt and Peck):** USB HID mouse traffic captures on-screen keyboard typing. Use USB-Mouse-Pcap-Visualizer, extract click coordinates (falling edges), cumsum relative deltas for absolute positions, overlay on OSK image.
135
+
136
+ ## File Type Detection
137
+
138
+ ```bash
139
+ file unknown_file
140
+ xxd unknown_file | head
141
+ binwalk unknown_file
142
+ ```
143
+
144
+ ## Archive Extraction
145
+
146
+ ```bash
147
+ 7z x archive.7z # Universal
148
+ tar -xzf archive.tar.gz # Gzip
149
+ tar -xjf archive.tar.bz2 # Bzip2
150
+ tar -xJf archive.tar.xz # XZ
151
+ ```
152
+
153
+ ### Nested Archive Script
154
+ ```bash
155
+ while f=$(ls *.tar* *.gz *.bz2 *.xz *.zip *.7z 2>/dev/null|head -1) && [ -n "$f" ]; do
156
+ 7z x -y "$f" && rm "$f"
157
+ done
158
+ ```
159
+
160
+ ## QR Codes
161
+
162
+ ```bash
163
+ zbarimg qrcode.png # Decode
164
+ qrencode -o out.png "data"
165
+ ```
166
+
167
+ **MaxiCode barcode:** Hexagonal 2D barcode with bullseye center; decode with `zxing` (Java) since standard QR decoders fail. See [encodings-advanced.md](encodings-advanced.md#maxicode-2d-barcode-decoding-csaw-ctf-2016).
168
+
169
+ **TOPKEK encoding:** CTF-specific binary encoding where `KEK=0`, `TOP=1`, `!` suffix = repeat count. See [encodings-advanced.md](encodings-advanced.md#topkek-binary-encoding-hack-the-vote-2016).
170
+
171
+ See [encodings.md](encodings.md) for QR structure, repair techniques, chunk reassembly (structural and indexed-directory variants), and multi-stage URL encoding chains.
172
+
173
+ ## Audio Challenges
174
+
175
+ ```bash
176
+ sox audio.wav -n spectrogram # Visual data
177
+ qsstv # SSTV decoder
178
+ ```
179
+
180
+ ## RF / SDR / IQ Signal Processing
181
+
182
+ See [rf-sdr.md](rf-sdr.md) for full details (IQ formats, QAM-16 demod, carrier/timing recovery).
183
+
184
+ **Quick reference:**
185
+ - **cf32**: `np.fromfile(path, dtype=np.complex64)` | **cs16**: int16 reshape(-1,2) | **cu8**: RTL-SDR raw
186
+ - Circles in constellation = constant frequency offset; Spirals = drifting frequency + gain instability
187
+ - 4-fold ambiguity in DD carrier recovery - try 0/90/180/270 rotation
188
+
189
+ ## pwntools Interaction
190
+
191
+ ```python
192
+ from pwn import *
193
+
194
+ r = remote('host', port)
195
+ r.recvuntil(b'prompt: ')
196
+ r.sendline(b'answer')
197
+ r.interactive()
198
+ ```
199
+
200
+ ## Python Jail Quick Reference
201
+
202
+ - **Oracle pattern:** `L()` = length, `Q(i,x)` = compare, `S(guess)` = submit. Linear or binary search.
203
+ - **Walrus bypass:** `(abcdef := "new_chars")` reassigns constraint vars
204
+ - **Decorator bypass:** `@__import__` + `@func.__class__.__dict__[__name__.__name__].__get__` for no-call, no-quotes escape
205
+ - **String join:** `open(''.join(['fl','ag.txt'])).read()` when `+` is blocked
206
+
207
+ See [pyjails.md](pyjails.md) for full techniques.
208
+
209
+ ## Z3 / Constraint Solving
210
+
211
+ ```python
212
+ from z3 import *
213
+ flag = [BitVec(f'f{i}', 8) for i in range(FLAG_LEN)]
214
+ s = Solver()
215
+ # Add constraints, check sat, extract model
216
+ ```
217
+
218
+ See [games-and-vms.md](games-and-vms.md) for YARA rules, type systems as constraints, boolean logic gate network SAT solving.
219
+
220
+ ## Hash Identification
221
+
222
+ MD5: `0x67452301` | SHA-256: `0x6a09e667` | MurmurHash64A: `0xC6A4A7935BD1E995`
223
+
224
+ ## SHA-256 Length Extension Attack
225
+
226
+ MAC = `SHA-256(SECRET || msg)` with known msg/hash -> forge valid MAC via `hlextend`. Vulnerable: SHA-256, MD5, SHA-1. NOT: HMAC, SHA-3.
227
+
228
+ ```python
229
+ import hlextend
230
+ sha = hlextend.new('sha256')
231
+ new_data = sha.extend(b'extension', b'original_message', len_secret, known_hash_hex)
232
+ ```
233
+
234
+ ## Technique Quick References
235
+
236
+ - **PyInstaller:** `pyinstxtractor.py packed.exe`. See [games-and-vms.md](games-and-vms.md) for opcode remapping.
237
+ - **Marshal:** `marshal.load(f)` then `dis.dis(code)`. See [games-and-vms.md](games-and-vms.md).
238
+ - **Python env RCE:** `PYTHONWARNINGS=ignore::antigravity.Foo::0` + `BROWSER="cmd"`. See [games-and-vms.md](games-and-vms.md).
239
+ - **WASM patching:** `wasm2wat` -> flip minimax -> `wat2wasm`. See [games-and-vms.md](games-and-vms.md).
240
+ - **Float precision:** Large multipliers amplify FP errors into exploitable fractions. See [games-and-vms.md](games-and-vms.md).
241
+ - **K8s RBAC bypass:** SA token -> impersonate -> hostPath mount -> read secrets. See [games-and-vms.md](games-and-vms.md).
242
+ - **Cookie checkpoint:** Save session cookies before guesses, restore on failure to brute-force without reset. See [games-and-vms-2.md](games-and-vms-2.md).
243
+ - **Flask cookie game state:** `flask-unsign -d -c '<cookie>'` decodes unsigned Flask sessions, leaking game answers. See [games-and-vms-2.md](games-and-vms-2.md).
244
+ - **WebSocket teleport:** Modify `player.x`/`player.y` in console, call verification function. See [games-and-vms-2.md](games-and-vms-2.md).
245
+ - **Time-only validation:** Start session, `time.sleep(required_seconds)`, submit win. See [games-and-vms-2.md](games-and-vms-2.md).
246
+ - **Quine context detection:** Dual-purpose quine that prints itself (passes validation) and runs payload only in server process via globals gate. See [pyjails.md](pyjails.md).
247
+ - **Repunit decomposition:** Decompose target integer into sum of repunits (1, 11, 111, ...) using only 2 characters (`1` and `+`) for restricted eval. See [pyjails.md](pyjails.md).
248
+ - **De Bruijn sequence:** B(k, n) contains all k^n possible n-length strings as substrings; linearize by appending first n-1 chars. See [games-and-vms-2.md](games-and-vms-2.md).
249
+ - **Brainfuck instrumentation:** Instrument BF interpreter to track tape cells, brute-force flag character-by-character via validation cell. See [games-and-vms-2.md](games-and-vms-2.md).
250
+ - **WASM memory manipulation:** Patch WASM linear memory at runtime to set game state variables directly, bypassing game logic. See [games-and-vms-2.md](games-and-vms-2.md).
251
+ - **Lua sandbox escape:** Bypass `load()`/`os.execute()` filters via `os["execute"]` table indexing or `loadstring` alias. See [games-and-vms.md](games-and-vms.md#lua-sandbox-escape-via-function-name-injection-csaw-ctf-2016).
252
+ - **C code jail via emoji + gadget embedding:** When only emoji and punctuation are allowed in C, use `(emoji_var==emoji_var)` as constant 1, build integers, embed gadgets in `add eax, imm32` constants, jump to offset+1 for shellcode primitives. See [games-and-vms-3.md](games-and-vms-3.md#c-code-jail-escape-via-emoji-identifiers-and-gadget-embedding-midnight-flag-2026).
253
+ - **Emulator ROM-switching:** `/load` replaces ROM but preserves CPU state (registers, RAM, PC). Switch ROMs at specific PCs to combine INIT from one ROM with display instructions from another → read protected memory. See [games-and-vms-3.md](games-and-vms-3.md#emulator-rom-switching-state-preservation-bsidessf-2026).
254
+ - **BuildKit daemon exploitation:** Exposed BuildKit gRPC allows nested `buildctl build` with `--mount=type=secret` to read build secrets. Two-stage Dockerfile: install buildctl → submit nested build mounting flag secret. See [games-and-vms-3.md](games-and-vms-3.md#buildkit-daemon-exploitation-for-build-secrets-bsidessf-2026).
255
+ - **Docker container escape:** Privileged breakout via host device mount, docker.sock socket escape, CAP_SYS_ADMIN cgroup release_agent, container info leakage via /proc and overlayfs. See [games-and-vms-3.md](games-and-vms-3.md#docker-container-escape-techniques).
256
+ - **Taint analysis bypass via type coercion:** In custom ML-like languages with secrecy/taint systems, if-expression secrecy depends on return type not condition — coerce side-effecting functions to private type to leak private data through public mutable refs. See [games-and-vms-3.md](games-and-vms-3.md#taint-analysis-bypass-in-custom-language-via-type-coercion-plaidctf-2018).
257
+ - **Shredded document pixel-edge reassembly:** Encode each strip's left/right edge as binary bitmask (dark=1), use XOR + popcount Hamming distance to greedily place strips by minimum edge distance for sub-second reassembly. See [games-and-vms-3.md](games-and-vms-3.md#shredded-document-pixel-edge-reassembly-under-time-pressure-nuit-du-hack-ctf-2018).
258
+ - **f-string config injection via stored eval:** Store payload as config value, create key named `eval(stored_key)` — f-string rendering evaluates the key name expression, triggering RCE. See [pyjails.md](pyjails.md#python-f-string-config-injection-via-stored-eval-inshack-2018).
259
+ - **Hexadecimal Sudoku + QR assembly:** 4 QR codes encode 16x16 hex Sudoku quadrants; solve grid, read diagonal as hex pairs → ASCII flag. See [encodings-advanced.md](encodings-advanced.md#hexadecimal-sudoku--qr-assembly-bsidessf-2026).
260
+ - **Z3 boolean gate network SAT solving:** Product key validation as 250 boolean gates (AND/OR/XOR/NOT) over 125 input bits. Model each gate as Z3 constraint, require all outputs True, solve in milliseconds. See [games-and-vms.md](games-and-vms.md#z3-sat-solving-for-boolean-logic-gate-networks-bsidessf-2026).
261
+
262
+ ## 3D Printer Video Nozzle Tracking (LACTF 2026)
263
+
264
+ **Pattern (flag-irl):** Video of 3D printer fabricating nameplate. Flag is the printed text.
265
+
266
+ **Technique:** Track nozzle X/Y positions from video frames, filter for print moves (top/text layer only), plot 2D histogram to reveal letter shapes:
267
+ ```python
268
+ # 1. Identify text layer frames (e.g., frames 26100-28350)
269
+ # 2. Track print head X position (physical X-axis)
270
+ # 3. Track bed X position (physical Y-axis from camera angle)
271
+ # 4. Filter for moves with extrusion (head moving while printing)
272
+ # 5. Plot as 2D scatter/histogram -> letters appear
273
+ ```
274
+
275
+ ## Discord API Enumeration (0xFun 2026)
276
+
277
+ Flags hidden in Discord metadata (roles, animated emoji, embeds). Invoke `/ctf-osint` for Discord API enumeration technique and code (see social-media.md in ctf-osint).
278
+
279
+ ---
280
+
281
+ ## SUID Binary Exploitation (0xFun 2026)
282
+
283
+ ```bash
284
+ # Find SUID binaries
285
+ find / -perm -4000 2>/dev/null
286
+
287
+ # Cross-reference with GTFObins
288
+ # xxd with SUID: xxd flag.txt | xxd -r
289
+ # vim with SUID: vim -c ':!cat /flag.txt'
290
+ ```
291
+
292
+ **Reference:** https://gtfobins.github.io/
293
+
294
+ ---
295
+
296
+ ## Linux Privilege Escalation Quick Checks
297
+
298
+ ```bash
299
+ # GECOS field passwords
300
+ cat /etc/passwd # Check 5th colon-separated field
301
+
302
+ # ACL permissions
303
+ getfacl /path/to/restricted/file
304
+
305
+ # Sudo permissions
306
+ sudo -l
307
+
308
+ # Docker group membership (instant root)
309
+ id | grep -q docker && docker run -v /:/mnt --rm -it alpine chroot /mnt /bin/sh
310
+ ```
311
+
312
+ ## Docker Group Privilege Escalation (H7CTF 2025)
313
+
314
+ User in the `docker` group can mount the host filesystem into a container and chroot into it for root access.
315
+
316
+ ```bash
317
+ # Check group membership
318
+ id # Look for "docker" in groups
319
+
320
+ # Mount host root filesystem and chroot
321
+ docker run -v /:/mnt --rm -it alpine chroot /mnt /bin/sh
322
+
323
+ # Now running as root on the host filesystem
324
+ cat /root/flag.txt
325
+ ```
326
+
327
+ **Key insight:** Docker group membership is equivalent to root access. The `docker` CLI socket (`/var/run/docker.sock`) allows creating privileged containers that mount the entire host filesystem.
328
+
329
+ **Reference:** https://gtfobins.github.io/gtfobins/docker/
330
+
331
+ ## Sudo Wildcard Parameter Injection (Dump HTB)
332
+
333
+ Sudo's `fnmatch()` matches `*` across argument boundaries. Inject extra flags (`-Z root`, `-r`, second `-w`) into locked-down commands. Craft pcap with embedded valid sudoers entries — sudo's parser recovers from binary junk, unlike cron's strict parser. See [linux-privesc.md](linux-privesc.md#sudo-wildcard-parameter-injection-via-fnmatch-dump-htb).
334
+
335
+ ## Monit Process Command-Line Injection (Zero HTB)
336
+
337
+ Root monit script uses `pgrep -lfa` to extract process command lines, then executes a modified version. Create fake process via `perl -e '$0 = "..."'` with injected flags. Apache `-d` last-wins overrides ServerRoot; `-E` captures error output. `Include /root/flag` causes a parse error that reveals the file content. See [linux-privesc.md](linux-privesc.md#monit-confcheck-process-command-line-injection-zero-htb).
338
+
339
+ ## PostgreSQL RCE and File Read (Slonik HTB)
340
+
341
+ `COPY (SELECT '') TO PROGRAM 'cmd'` executes OS commands as postgres. `pg_read_file('/path')` reads files. Extract credentials from `pg_basebackup` archives (`global/1260` = `pg_authid`). SSH tunnel to Unix sockets: `ssh -fNL 25432:/var/run/postgresql/.s.PGSQL.5432`. See [linux-privesc.md](linux-privesc.md#postgresql-copy-to-program-rce-slonik-htb).
342
+
343
+ ## Backup Cronjob SUID Abuse (Slonik HTB)
344
+
345
+ Root cronjob copying directories preserves SUID bit but changes ownership to root. Place SUID bash in source directory → backup copies it as root-owned SUID. Execute with `bash -p`. See [linux-privesc.md](linux-privesc.md#backup-cronjob-suid-abuse-slonik-htb).
346
+
347
+ ## PaperCut Print Deploy Privesc (Bamboo HTB)
348
+
349
+ Root process runs scripts from user-owned directory. Modify `server-command`, trigger via Mobility Print API refresh. See [linux-privesc.md](linux-privesc.md#papercut-print-deploy-privilege-escalation-bamboo-htb).
350
+
351
+ ---
352
+
353
+ ## CTFd Platform Navigation (No Browser)
354
+
355
+ Detect CTFd (`curl -s "$CTF_URL/api/v1/" | head -5`) and interact via API. **Ask the user for their API token** (CTFd Settings > Access Tokens) — it is not provided by default. Then use `Authorization: Token $CTF_TOKEN` header for all requests.
356
+
357
+ ```bash
358
+ export CTF_URL="https://ctf.example.com" CTF_TOKEN="ctfd_your_token_here"
359
+ curl -s -H "Authorization: Token $CTF_TOKEN" "$CTF_URL/api/v1/challenges" | jq -r '.data[] | "\(.id)\t\(.value)pts\t\(.category)\t\(.name)"'
360
+ curl -s -X POST -H "Authorization: Token $CTF_TOKEN" -H "Content-Type: application/json" "$CTF_URL/api/v1/challenges/attempt" -d "{\"challenge_id\": $CID, \"submission\": \"flag{...}\"}"
361
+ ```
362
+
363
+ See [ctfd-navigation.md](ctfd-navigation.md) for full workflow, Python client class, session login, hints, notifications, file download, and troubleshooting.
364
+
365
+ ---
366
+
367
+ ## Useful One-Liners
368
+
369
+ ```bash
370
+ grep -rn "flag{" .
371
+ strings file | grep -i flag
372
+ python3 -c "print(int('deadbeef', 16))"
373
+ ```
374
+
375
+ ## Keyboard Shift Cipher
376
+
377
+ **Pattern (Frenzy):** Characters shifted left/right on QWERTY keyboard layout.
378
+
379
+ **Identification:** dCode Cipher Identifier suggests "Keyboard Shift Cipher"
380
+
381
+ **Decoding:** Use [dCode Keyboard Shift Cipher](https://www.dcode.fr/keyboard-shift-cipher) with automatic mode.
382
+
383
+ ## Pigpen / Masonic Cipher
384
+
385
+ **Pattern (Working For Peanuts):** Geometric symbols representing letters based on grid positions.
386
+
387
+ **Identification:** Angular/geometric symbols, challenge references "Peanuts" comic (Charlie Brown), "dusty looking crypto"
388
+
389
+ **Decoding:** Map symbols to Pigpen grid positions, or use online decoder.
390
+
391
+ ## ASCII in Numeric Data Columns
392
+
393
+ **Pattern (Cooked Books):** CSV/spreadsheet numeric values (48-126) are ASCII character codes.
394
+
395
+ ```python
396
+ import csv
397
+ with open('data.csv') as f:
398
+ reader = csv.DictReader(f)
399
+ flag = ''.join(chr(int(row['Times Borrowed'])) for row in reader)
400
+ print(flag)
401
+ ```
402
+
403
+ **CyberChef:** "From Decimal" recipe with line feed delimiter.
404
+
405
+ ## Backdoor Detection in Source Code
406
+
407
+ **Pattern (Rear Hatch):** Hidden command prefix triggers `system()` call.
408
+
409
+ **Common patterns:**
410
+ - `strncmp(input, "exec:", 5)` -> runs `system(input + 5)`
411
+ - Hex-encoded comparison strings: `\x65\x78\x65\x63\x3a` = "exec:"
412
+ - Hidden conditions in maintenance/admin functions
413
+
414
+ ## DNS Exploitation Techniques
415
+
416
+ See [dns.md](dns.md) for full details (ECS spoofing, NSEC walking, IXFR, rebinding, tunneling).
417
+
418
+ **Quick reference:**
419
+ - **ECS spoofing**: `dig @server flag.example.com TXT +subnet=10.13.37.1/24` - try leet-speak IPs (1337)
420
+ - **NSEC walking**: Follow NSEC chain to enumerate DNSSEC zones
421
+ - **IXFR**: `dig @server domain IXFR=0` when AXFR is blocked
422
+ - **DNS rebinding**: Low-TTL alternating resolution to bypass same-origin
423
+ - **DNS tunneling**: Data exfiltrated via subdomain queries or TXT responses
424
+
425
+ ## Unicode Steganography
426
+
427
+ ### Variation Selectors Supplement (U+E0100-U+E01EF)
428
+ **Patterns (Seen & emoji, Nullcon 2026):** Invisible Variation Selector Supplement characters encode ASCII via codepoint offset.
429
+
430
+ ```python
431
+ # Extract hidden data from variation selectors after visible character
432
+ data = open('README.md', 'r').read().strip()
433
+ hidden = data[1:] # Skip visible emoji character
434
+ flag = ''.join(chr((ord(c) - 0xE0100) + 16) for c in hidden)
435
+ ```
436
+
437
+ **Detection:** Characters appear invisible but have non-zero length. Check with `[hex(ord(c)) for c in text]` -- look for codepoints in `0xE0100-0xE01EF` or `0xFE00-0xFE0F` range.
438
+
439
+ ### Unicode Tags Block (U+E0000-U+E007F) (UTCTF 2026)
440
+
441
+ **Pattern (Hidden in Plain Sight):** Invisible Unicode Tag characters embedded in URLs, filenames, or text. Each tag codepoint maps directly to an ASCII character by subtracting `0xE0000`. URL-encoded as 4-byte UTF-8 sequences (`%F3%A0%81%...`).
442
+
443
+ ```python
444
+ import urllib.parse
445
+
446
+ url = "https://example.com/page#Title%20%F3%A0%81%B5%F3%A0%81%B4...Visible%20Text"
447
+ decoded = urllib.parse.unquote(urllib.parse.urlparse(url).fragment)
448
+
449
+ flag = ''.join(
450
+ chr(ord(ch) - 0xE0000)
451
+ for ch in decoded
452
+ if 0xE0000 <= ord(ch) <= 0xE007F
453
+ )
454
+ print(flag)
455
+ ```
456
+
457
+ **Key insight:** Unicode Tags (U+E0001-U+E007F) mirror ASCII 1:1 — subtract `0xE0000` to recover the original character. They render as zero-width invisible glyphs in most fonts. Unlike Variation Selectors (U+E0100+), these have a simpler offset calculation and appear in URL fragments, challenge titles, or filenames where the text looks normal but has suspiciously long byte length.
458
+
459
+ **Detection:** Text or URL is longer than expected in bytes. Percent-encoded sequences starting with `%F3%A0%80` or `%F3%A0%81`. Python: `any(0xE0000 <= ord(c) <= 0xE007F for c in text)`.
460
+
461
+ ## UTF-16 Endianness Reversal
462
+
463
+ **Pattern (endians):** Text "turned to Japanese" -- mojibake from UTF-16 endianness mismatch.
464
+
465
+ ```python
466
+ # If encoded as UTF-16-LE but decoded as UTF-16-BE:
467
+ fixed = mojibake.encode('utf-16-be').decode('utf-16-le')
468
+ ```
469
+
470
+ **Identification:** CJK characters, challenge mentions "translation" or "endian". See [encodings.md](encodings.md) for details.
471
+
472
+ ## Cipher Identification Workflow
473
+
474
+ 1. **ROT13** - Challenge mentions "ROT", text looks like garbled English
475
+ 2. **Base64** - `A-Za-z0-9+/=`, title hints "64"
476
+ 3. **Base32** - `A-Z2-7=` uppercase only
477
+ 4. **Atbash** - Title hints (Abash/Atbash), preserves spaces, 1:1 substitution
478
+ 5. **Pigpen** - Geometric symbols on grid
479
+ 6. **Keyboard Shift** - Text looks like adjacent keys pressed
480
+ 7. **Substitution** - Frequency analysis applicable
481
+
482
+ **Auto-identify:** [dCode Cipher Identifier](https://www.dcode.fr/cipher-identifier)
483
+
484
+ ## HISTFILE Trick for Restricted Shell File Reads (BCTF 2016)
485
+
486
+ Read files without cat/less/head: `HISTFILE=/flag /bin/bash && history`, or `bash -v flag.txt` (verbose mode prints lines), or `ctypes.sh` `dlcall` for direct C library calls. See [bashjails.md](bashjails.md#histfile-trick-for-restricted-shell-file-reads-bctf-2016).
487
+
488
+ ## Levenshtein Distance Oracle Attack (SunshineCTF 2016)
489
+
490
+ Oracle returns edit distance between guess and secret. Determine length from empty string, identify present chars from single-char repeats, binary search for positions. O(n log n) queries. See [games-and-vms-3.md](games-and-vms-3.md#levenshtein-distance-oracle-attack-sunshinectf-2016).
491
+
492
+ ## SECCOMP High-Bit File Descriptor Bypass (33C3 CTF 2016)
493
+
494
+ `close(0x8000000000000002)` passes 64-bit SECCOMP check (≠ 2) but kernel truncates to 32-bit (== 2), closing fd 2. Next `open()` returns fd 2 for arbitrary file. Type-width mismatch between BPF filter and kernel. See [games-and-vms-3.md](games-and-vms-3.md#seccomp-bypass-via-high-bit-file-descriptor-trick-33c3-ctf-2016).
495
+
496
+ ## rvim Jail Escape via Python3 (BKP 2017)
497
+
498
+ `rvim` blocks `:!` but `:python3 import os; os.system("cmd")` executes arbitrary commands. Check `:version` for `+python3`/`+lua`/`+ruby`. See [games-and-vms-3.md](games-and-vms-3.md#rvim-jail-escape-via-custom-vimrc-with-python3-execution-bkp-2017).