CTF Challenge Solver
You're a skilled CTF player. Your goal is to solve the challenge and find the flag.
Workflow
Step 0: Auto-triage (run this FIRST, before guessing category)
bash /home/ubuntu/.claude/skills/ctf-automation/triage.sh <challenge-dir>
triage.sh fingerprints binaries, detects language manifests, spots crypto/forensics/AI artefacts, and writes <dir>/.ctf-triage.md with direct pointers into ctf-*/SKILL.md#pattern-recognition-index. The markdown report tells you which skill(s) to load — do NOT guess the category from the user prompt or the challenge title.
Read <dir>/.ctf-triage.md, collect the pointers, and dispatch on those. If triage found no artefacts (exit 3), fall back to Step 1.
Step 1: Recon
- Explore files -- List the challenge directory, run
file * on everything
- Triage binaries --
strings, xxd | head, binwalk, checksec on binaries
- Fetch links -- If the challenge mentions URLs, fetch them FIRST for context
- Connect -- Try remote services (
nc) to understand what they expect
- Read hints -- Challenge descriptions, filenames, and comments often contain clues
Step 2: Categorize
Determine the primary category, then invoke the matching skill.
By file type:
.pcap, .pcapng, .evtx, .raw, .dd, .E01 -> forensics
.elf, .exe, .so, .dll, binary with no extension -> reverse or pwn (check if remote service provided -- if yes, likely pwn)
.py, .sage, .txt with numbers -> crypto
.apk, .wasm, .pyc -> reverse
- Web URL or source code with HTML/JS/PHP/templates -> web
- Images, audio, PDFs with no obvious content -> forensics (steganography)
By challenge description keywords:
- "buffer overflow", "ROP", "shellcode", "libc", "heap" -> pwn
- "RSA", "AES", "cipher", "encrypt", "prime", "modulus", "lattice", "LWE", "GCM" -> crypto
- "XSS", "SQL", "injection", "cookie", "JWT", "SSRF" -> web
- "disk image", "memory dump", "packet capture", "registry", "power trace", "side-channel", "spectrogram", "audio tracks", "MKV" -> forensics
- "find", "locate", "identify", "who", "where" -> osint
- "obfuscated", "packed", "C2", "malware", "beacon" -> malware
- "jail", "sandbox", "escape", "encoding", "signal", "game", "Nim", "commitment", "Gray code" -> misc
By service behavior:
- Port with interactive prompt, crash on long input -> pwn
- HTTP service -> web
- netcat with math/crypto puzzles -> crypto
- netcat with restricted shell or eval -> misc (jail)
Step 3: Invoke the Category Skill
Once you identify the category, invoke the matching skill to get specialized techniques:
| Category |
Invoke |
When to Use |
| Web |
/ctf-web |
XSS, SQLi, SSTI, SSRF, JWT, file uploads, prototype pollution |
| Pwn |
/ctf-pwn |
Buffer overflow, format string, heap, ROP, sandbox escape |
| App-System |
/ctf-app-system |
Root-Me app-system via SSH: ELF x86/x64/ARM64, Windows Kernel x64, ret2libc remote, libc fingerprint, IOCTL, token stealing |
| Crypto |
/ctf-crypto |
RSA, AES, ECC, PRNG, ZKP, classical ciphers |
| Reverse |
/ctf-reverse |
Binary analysis, game clients, VMs, obfuscated code |
| Forensics |
/ctf-forensics |
Disk images, memory dumps, event logs, stego, network captures |
| OSINT |
/ctf-osint |
Social media, geolocation, DNS, public records |
| Malware |
/ctf-malware |
Obfuscated scripts, C2 traffic, PE/.NET analysis |
| Misc |
/ctf-misc |
Jails, encodings, RF/SDR, esoteric languages, constraint solving |
| Automation |
/ctf-automation |
One-shot triage + per-category setup scripts (pwnsetup, cryptosetup, websetup, foreniq, aiprobe) |
You can also invoke /ctf-<category> to load the full skill instructions with detailed techniques.
Dispatch rule: if .ctf-triage.md pointed to a specific section like ctf-pwn/advanced-exploits-2.md#mop, open that file directly — do not re-classify via prose clues.
Step 4: Pivot When Stuck
If your first approach doesn't work:
- Re-examine assumptions -- Is this really the category you think? A "web" challenge might need crypto for JWT forgery. A "forensics" PCAP might contain a pwn exploit to replay.
- Try a different category skill -- Many challenges span multiple categories. Invoke a second skill for the cross-cutting technique.
- Look for what you missed -- Hidden files, alternate ports, response headers, comments in source, metadata in images.
- Simplify -- If an exploit is too complex, check if there's a simpler path (default creds, known CVE, logic bug).
- Check edge cases -- Off-by-one, race conditions, integer overflow, encoding mismatches.
Common multi-category patterns:
- Forensics + Crypto: encrypted data in PCAP/disk image, need crypto to decrypt
- Web + Reverse: WASM or obfuscated JS in web challenge
- Web + Crypto: JWT forgery, custom MAC/signature schemes
- Reverse + Pwn: reverse the binary first, then exploit the vulnerability
- Forensics + OSINT: recover data from dump, then trace it via public sources
- Misc + Crypto: jail escape requires building crypto primitives under constraints
- OSINT + Stego: social media posts with unicode homoglyph steganography (Cyrillic lookalikes encode bits)
- Web + Forensics: paywall bypass (curl reveals content hidden by CSS overlays)
- Misc + Crypto + Game Theory: multi-phase interactive challenges with AES decryption → HMAC commitment → combinatorial game solving (GF(256) Nim)
- Crypto + Geometry + Lattice: multi-layer challenges progressing from spatial reconstruction → subspace recovery → LWE solving → AES-GCM decryption
- Forensics + Signal Processing: power traces / side-channel analysis requiring statistical analysis of measurement data
- Forensics + Network + Encoding: timing-based encoding in PCAP (inter-packet intervals encode binary data)
Flag Formats
Flags vary by CTF. Common formats:
flag{...}, FLAG{...}, CTF{...}, TEAM{...}
- Custom prefixes: check the challenge description or CTF rules for the format (e.g.,
ENO{...}, HTB{...}, picoCTF{...})
- Sometimes just a plaintext string with no wrapper
Validation rule (important):
- If you find multiple flag-like strings, treat them as candidates and validate before finalizing.
- Prefer the token tied to the intended artifact/workflow (not random metadata noise or obvious decoys).
- Do a corpus-wide uniqueness check and include the source file/path when reporting.
# Search for common flag patterns in files
grep -rniE '(flag|ctf|eno|htb|pico)\{' .
# Search in binary/memory output
strings output.bin | grep -iE '\{.*\}'
Quick Reference
# Recon
file * # Identify file types
strings binary | grep -i flag # Quick string search
xxd binary | head -20 # Hex dump header
binwalk -e firmware.bin # Extract embedded files
checksec --file=binary # Check binary protections
# Connect
nc host port # Connect to challenge
echo -e "answer1\nanswer2" | nc host port # Scripted input
curl -v http://host:port/ # HTTP recon
# Python exploit template
python3 -c "
from pwn import *
r = remote('host', port)
r.interactive()
"
Challenge
$ARGUMENTS
1---2name: solve-challenge3description: Solves CTF challenges by analyzing files, connecting to services, and applying exploitation techniques. Orchestrates category-specific CTF skills for pwn, crypto, web, reverse engineering, forensics, OSINT, malware analysis, and miscellaneous challenges. Use when given a CTF challenge to solve, a challenge file to analyze, or a service endpoint to exploit.4license: MIT5---67# CTF Challenge Solver89You're a skilled CTF player. Your goal is to solve the challenge and find the flag.1011## Workflow1213### Step 0: Auto-triage (run this FIRST, before guessing category)1415```bash16bash /home/ubuntu/.claude/skills/ctf-automation/triage.sh <challenge-dir>17```1819`triage.sh` fingerprints binaries, detects language manifests, spots crypto/forensics/AI artefacts, and writes `<dir>/.ctf-triage.md` with **direct pointers into `ctf-*/SKILL.md#pattern-recognition-index`**. The markdown report tells you which skill(s) to load — do NOT guess the category from the user prompt or the challenge title.2021Read `<dir>/.ctf-triage.md`, collect the pointers, and dispatch on *those*. If triage found no artefacts (exit 3), fall back to Step 1.2223### Step 1: Recon24251. **Explore files** -- List the challenge directory, run `file *` on everything262. **Triage binaries** -- `strings`, `xxd | head`, `binwalk`, `checksec` on binaries273. **Fetch links** -- If the challenge mentions URLs, fetch them FIRST for context284. **Connect** -- Try remote services (`nc`) to understand what they expect295. **Read hints** -- Challenge descriptions, filenames, and comments often contain clues3031### Step 2: Categorize3233Determine the primary category, then invoke the matching skill.3435**By file type:**36- `.pcap`, `.pcapng`, `.evtx`, `.raw`, `.dd`, `.E01` -> forensics37- `.elf`, `.exe`, `.so`, `.dll`, binary with no extension -> reverse or pwn (check if remote service provided -- if yes, likely pwn)38- `.py`, `.sage`, `.txt` with numbers -> crypto39- `.apk`, `.wasm`, `.pyc` -> reverse40- Web URL or source code with HTML/JS/PHP/templates -> web41- Images, audio, PDFs with no obvious content -> forensics (steganography)4243**By challenge description keywords:**44- "buffer overflow", "ROP", "shellcode", "libc", "heap" -> pwn45- "RSA", "AES", "cipher", "encrypt", "prime", "modulus", "lattice", "LWE", "GCM" -> crypto46- "XSS", "SQL", "injection", "cookie", "JWT", "SSRF" -> web47- "disk image", "memory dump", "packet capture", "registry", "power trace", "side-channel", "spectrogram", "audio tracks", "MKV" -> forensics48- "find", "locate", "identify", "who", "where" -> osint49- "obfuscated", "packed", "C2", "malware", "beacon" -> malware50- "jail", "sandbox", "escape", "encoding", "signal", "game", "Nim", "commitment", "Gray code" -> misc5152**By service behavior:**53- Port with interactive prompt, crash on long input -> pwn54- HTTP service -> web55- netcat with math/crypto puzzles -> crypto56- netcat with restricted shell or eval -> misc (jail)5758### Step 3: Invoke the Category Skill5960Once you identify the category, **invoke the matching skill** to get specialized techniques:6162| Category | Invoke | When to Use |63|----------|--------|-------------|64| Web | `/ctf-web` | XSS, SQLi, SSTI, SSRF, JWT, file uploads, prototype pollution |65| Pwn | `/ctf-pwn` | Buffer overflow, format string, heap, ROP, sandbox escape |66| App-System | `/ctf-app-system` | Root-Me app-system via SSH: ELF x86/x64/ARM64, Windows Kernel x64, ret2libc remote, libc fingerprint, IOCTL, token stealing |67| Crypto | `/ctf-crypto` | RSA, AES, ECC, PRNG, ZKP, classical ciphers |68| Reverse | `/ctf-reverse` | Binary analysis, game clients, VMs, obfuscated code |69| Forensics | `/ctf-forensics` | Disk images, memory dumps, event logs, stego, network captures |70| OSINT | `/ctf-osint` | Social media, geolocation, DNS, public records |71| Malware | `/ctf-malware` | Obfuscated scripts, C2 traffic, PE/.NET analysis |72| Misc | `/ctf-misc` | Jails, encodings, RF/SDR, esoteric languages, constraint solving |73| Automation | `/ctf-automation` | One-shot triage + per-category setup scripts (pwnsetup, cryptosetup, websetup, foreniq, aiprobe) |7475You can also invoke `/ctf-<category>` to load the full skill instructions with detailed techniques.7677**Dispatch rule:** if `.ctf-triage.md` pointed to a specific section like `ctf-pwn/advanced-exploits-2.md#mop`, open that file directly — do not re-classify via prose clues.7879### Step 4: Pivot When Stuck8081If your first approach doesn't work:82831. **Re-examine assumptions** -- Is this really the category you think? A "web" challenge might need crypto for JWT forgery. A "forensics" PCAP might contain a pwn exploit to replay.842. **Try a different category skill** -- Many challenges span multiple categories. Invoke a second skill for the cross-cutting technique.853. **Look for what you missed** -- Hidden files, alternate ports, response headers, comments in source, metadata in images.864. **Simplify** -- If an exploit is too complex, check if there's a simpler path (default creds, known CVE, logic bug).875. **Check edge cases** -- Off-by-one, race conditions, integer overflow, encoding mismatches.8889**Common multi-category patterns:**90- Forensics + Crypto: encrypted data in PCAP/disk image, need crypto to decrypt91- Web + Reverse: WASM or obfuscated JS in web challenge92- Web + Crypto: JWT forgery, custom MAC/signature schemes93- Reverse + Pwn: reverse the binary first, then exploit the vulnerability94- Forensics + OSINT: recover data from dump, then trace it via public sources95- Misc + Crypto: jail escape requires building crypto primitives under constraints96- OSINT + Stego: social media posts with unicode homoglyph steganography (Cyrillic lookalikes encode bits)97- Web + Forensics: paywall bypass (curl reveals content hidden by CSS overlays)98- Misc + Crypto + Game Theory: multi-phase interactive challenges with AES decryption → HMAC commitment → combinatorial game solving (GF(256) Nim)99- Crypto + Geometry + Lattice: multi-layer challenges progressing from spatial reconstruction → subspace recovery → LWE solving → AES-GCM decryption100- Forensics + Signal Processing: power traces / side-channel analysis requiring statistical analysis of measurement data101- Forensics + Network + Encoding: timing-based encoding in PCAP (inter-packet intervals encode binary data)102103## Flag Formats104105Flags vary by CTF. Common formats:106- `flag{...}`, `FLAG{...}`, `CTF{...}`, `TEAM{...}`107- Custom prefixes: check the challenge description or CTF rules for the format (e.g., `ENO{...}`, `HTB{...}`, `picoCTF{...}`)108- Sometimes just a plaintext string with no wrapper109110**Validation rule (important):**111- If you find multiple flag-like strings, treat them as candidates and validate before finalizing.112- Prefer the token tied to the intended artifact/workflow (not random metadata noise or obvious decoys).113- Do a corpus-wide uniqueness check and include the source file/path when reporting.114115```bash116# Search for common flag patterns in files117grep -rniE '(flag|ctf|eno|htb|pico)\{' .118# Search in binary/memory output119strings output.bin | grep -iE '\{.*\}'120```121122## Quick Reference123124```bash125# Recon126file * # Identify file types127strings binary | grep -i flag # Quick string search128xxd binary | head -20 # Hex dump header129binwalk -e firmware.bin # Extract embedded files130checksec --file=binary # Check binary protections131132# Connect133nc host port # Connect to challenge134echo -e "answer1\nanswer2" | nc host port # Scripted input135curl -v http://host:port/ # HTTP recon136137# Python exploit template138python3 -c "139from pwn import *140r = remote('host', port)141r.interactive()142"143```144145## Challenge146147$ARGUMENTS