CTF Challenge Solver
You're a skilled CTF player. Your goal is to solve the challenge and find the flag.
Environment Setup
Two setup strategies depending on your workflow:
Pre-install (recommended before competitions)
Python packages (all platforms):
pip install pwntools pycryptodome z3-solver sympy gmpy2 hashpumpy fpylll py_ecc \
angr frida-tools qiling requests flask-unsign sqlmap \
ropper ROPgadget volatility3 yara-python pefile capstone \
oletools unicorn scapy Pillow numpy matplotlib shodan \
uncompyle6 lief dnspython dnslib dissect.cobaltstrike
Linux (apt):
apt install gdb radare2 binutils binwalk foremost libimage-exiftool-perl \
tshark sleuthkit ffmpeg steghide testdisk john pcapfix \
nmap whois dnsutils hashcat strace ltrace imagemagick curl jq \
apktool upx qemu-system-x86 sagemath qrencode
macOS (Homebrew):
brew install gdb radare2 binutils binwalk exiftool wireshark sleuthkit \
ffmpeg testdisk john-jumbo nmap whois bind hashcat ghidra \
imagemagick curl jq apktool upx qemu qrencode
Ruby gems (all platforms):
gem install one_gadget seccomp-tools zsteg
Go tools (all platforms, requires Go):
go install github.com/ffuf/ffuf/v2@latest
Manual install:
- pwndbg — Linux: github.com/pwndbg/pwndbg, macOS:
brew install pwndbg/tap/pwndbg-gdb
- RsaCtfTool —
git clone https://github.com/RsaCtfTool/RsaCtfTool
- SageMath — Linux:
apt install sagemath, macOS: brew install --cask sage
- steghide — Linux:
apt install steghide (not available via Homebrew)
- dnSpy — github.com/dnSpy/dnSpy (.NET decompiler, Windows)
On-demand (during challenges)
Each category skill's SKILL.md has a Prerequisites section listing only the tools needed for that category. Install as you go.
Workflow
Step 0: Create Challenge Folder
Always create a dedicated folder for each challenge before doing anything else.
Name the folder: c:\CTFRun\<CTFName>\<Category>-<ChallengeName>\
Example structure:
c:\CTFRun\
picoCTF2026\
web-ORDER_ORDER\ ← this challenge
solve.py ← exploit script
notes.md ← findings / observations
flag.txt ← confirmed flag
<downloaded files> ← any challenge files
Create the folder immediately:
mkdir "c:\CTFRun\<CTFName>\<Category>-<ChallengeName>"
Set-Location "c:\CTFRun\<CTFName>\<Category>-<ChallengeName>"
- All scripts and downloaded files go inside this folder
- Save the final flag in
flag.txt once found
- Write key findings in
notes.md as you go (endpoints, vuln type, payloads tried)
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 |
| 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 |
| Remote |
/ctf-remote |
SSH, remote access, Kali Linux, file transfer |
You can also invoke /ctf-<category> to load the full skill instructions with detailed techniques.
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
The user specifies the flag format in their request. Always check the challenge description or CTF rules for the exact format before searching.
Common formats:
| CTF |
Format |
Example |
| picoCTF |
picoCTF{...} |
picoCTF{s3cr3t} |
| HackTheBox |
HTB{...} |
HTB{b4sh_1s_fun} |
| ENOCTF |
ENO{...} |
ENO{abc123} |
| NCSA / custom |
NCSA{...} |
NCSA{MD5_of_something} |
| Generic |
flag{...} / CTF{...} |
flag{h3ll0} |
| No wrapper |
Plaintext / hash |
d41d8cd98f00b204e9800998ecf8427e |
If the user specifies a custom format (e.g., NCSA{MD5....}):
- Search for that prefix specifically:
grep -rniE 'NCSA\{' .
- It might be composed (e.g., flag =
NCSA{ + MD5 of some extracted value + })
- Always try to reconstruct if the raw value looks like an intermediate result
Search commands:
# Any flag-like pattern
grep -rniE '(flag|ctf|eno|htb|pico|ncsa)\{' .
# Binary / memory output
strings output.bin | grep -iE '\{.*\}'
# Custom prefix
grep -rniE 'NCSA\{' .
Validation rule:
- If multiple candidates found, prefer the one tied to the intended exploit path
- Save confirmed flag to
flag.txt in the challenge folder
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, remote, 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## Environment Setup1213Two setup strategies depending on your workflow:1415### Pre-install (recommended before competitions)1617**Python packages (all platforms):**18```bash19pip install pwntools pycryptodome z3-solver sympy gmpy2 hashpumpy fpylll py_ecc \20 angr frida-tools qiling requests flask-unsign sqlmap \21 ropper ROPgadget volatility3 yara-python pefile capstone \22 oletools unicorn scapy Pillow numpy matplotlib shodan \23 uncompyle6 lief dnspython dnslib dissect.cobaltstrike24```2526**Linux (apt):**27```bash28apt install gdb radare2 binutils binwalk foremost libimage-exiftool-perl \29 tshark sleuthkit ffmpeg steghide testdisk john pcapfix \30 nmap whois dnsutils hashcat strace ltrace imagemagick curl jq \31 apktool upx qemu-system-x86 sagemath qrencode32```3334**macOS (Homebrew):**35```bash36brew install gdb radare2 binutils binwalk exiftool wireshark sleuthkit \37 ffmpeg testdisk john-jumbo nmap whois bind hashcat ghidra \38 imagemagick curl jq apktool upx qemu qrencode39```4041**Ruby gems (all platforms):**42```bash43gem install one_gadget seccomp-tools zsteg44```4546**Go tools (all platforms, requires Go):**47```bash48go install github.com/ffuf/ffuf/v2@latest49```5051**Manual install:**52- pwndbg — Linux: [github.com/pwndbg/pwndbg](https://github.com/pwndbg/pwndbg), macOS: `brew install pwndbg/tap/pwndbg-gdb`53- RsaCtfTool — `git clone https://github.com/RsaCtfTool/RsaCtfTool`54- SageMath — Linux: `apt install sagemath`, macOS: `brew install --cask sage`55- steghide — Linux: `apt install steghide` (not available via Homebrew)56- dnSpy — [github.com/dnSpy/dnSpy](https://github.com/dnSpy/dnSpy) (.NET decompiler, Windows)5758### On-demand (during challenges)5960Each category skill's `SKILL.md` has a **Prerequisites** section listing only the tools needed for that category. Install as you go.6162## Workflow6364### Step 0: Create Challenge Folder6566**Always create a dedicated folder for each challenge before doing anything else.**6768Name the folder: `c:\CTFRun\<CTFName>\<Category>-<ChallengeName>\`6970Example structure:71```72c:\CTFRun\73 picoCTF2026\74 web-ORDER_ORDER\ ← this challenge75 solve.py ← exploit script76 notes.md ← findings / observations77 flag.txt ← confirmed flag78 <downloaded files> ← any challenge files79```8081**Create the folder immediately:**82```powershell83mkdir "c:\CTFRun\<CTFName>\<Category>-<ChallengeName>"84Set-Location "c:\CTFRun\<CTFName>\<Category>-<ChallengeName>"85```8687- All scripts and downloaded files go inside this folder88- Save the final flag in `flag.txt` once found89- Write key findings in `notes.md` as you go (endpoints, vuln type, payloads tried)9091### Step 1: Recon92931. **Explore files** -- List the challenge directory, run `file *` on everything942. **Triage binaries** -- `strings`, `xxd | head`, `binwalk`, `checksec` on binaries953. **Fetch links** -- If the challenge mentions URLs, fetch them FIRST for context964. **Connect** -- Try remote services (`nc`) to understand what they expect975. **Read hints** -- Challenge descriptions, filenames, and comments often contain clues9899### Step 2: Categorize100101Determine the primary category, then invoke the matching skill.102103**By file type:**104- `.pcap`, `.pcapng`, `.evtx`, `.raw`, `.dd`, `.E01` -> forensics105- `.elf`, `.exe`, `.so`, `.dll`, binary with no extension -> reverse or pwn (check if remote service provided -- if yes, likely pwn)106- `.py`, `.sage`, `.txt` with numbers -> crypto107- `.apk`, `.wasm`, `.pyc` -> reverse108- Web URL or source code with HTML/JS/PHP/templates -> web109- Images, audio, PDFs with no obvious content -> forensics (steganography)110111**By challenge description keywords:**112- "buffer overflow", "ROP", "shellcode", "libc", "heap" -> pwn113- "RSA", "AES", "cipher", "encrypt", "prime", "modulus", "lattice", "LWE", "GCM" -> crypto114- "XSS", "SQL", "injection", "cookie", "JWT", "SSRF" -> web115- "disk image", "memory dump", "packet capture", "registry", "power trace", "side-channel", "spectrogram", "audio tracks", "MKV" -> forensics116- "find", "locate", "identify", "who", "where" -> osint117- "obfuscated", "packed", "C2", "malware", "beacon" -> malware118- "jail", "sandbox", "escape", "encoding", "signal", "game", "Nim", "commitment", "Gray code" -> misc119120**By service behavior:**121- Port with interactive prompt, crash on long input -> pwn122- HTTP service -> web123- netcat with math/crypto puzzles -> crypto124- netcat with restricted shell or eval -> misc (jail)125126### Step 3: Invoke the Category Skill127128Once you identify the category, **invoke the matching skill** to get specialized techniques:129130| Category | Invoke | When to Use |131|----------|--------|-------------|132| Web | `/ctf-web` | XSS, SQLi, SSTI, SSRF, JWT, file uploads, prototype pollution |133| Pwn | `/ctf-pwn` | Buffer overflow, format string, heap, ROP, sandbox escape |134| Crypto | `/ctf-crypto` | RSA, AES, ECC, PRNG, ZKP, classical ciphers |135| Reverse | `/ctf-reverse` | Binary analysis, game clients, VMs, obfuscated code |136| Forensics | `/ctf-forensics` | Disk images, memory dumps, event logs, stego, network captures |137| OSINT | `/ctf-osint` | Social media, geolocation, DNS, public records |138| Malware | `/ctf-malware` | Obfuscated scripts, C2 traffic, PE/.NET analysis |139| Misc | `/ctf-misc` | Jails, encodings, RF/SDR, esoteric languages, constraint solving |140| Remote | `/ctf-remote` | SSH, remote access, Kali Linux, file transfer |141142You can also invoke `/ctf-<category>` to load the full skill instructions with detailed techniques.143144### Step 4: Pivot When Stuck145146If your first approach doesn't work:1471481. **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.1492. **Try a different category skill** -- Many challenges span multiple categories. Invoke a second skill for the cross-cutting technique.1503. **Look for what you missed** -- Hidden files, alternate ports, response headers, comments in source, metadata in images.1514. **Simplify** -- If an exploit is too complex, check if there's a simpler path (default creds, known CVE, logic bug).1525. **Check edge cases** -- Off-by-one, race conditions, integer overflow, encoding mismatches.153154**Common multi-category patterns:**155- Forensics + Crypto: encrypted data in PCAP/disk image, need crypto to decrypt156- Web + Reverse: WASM or obfuscated JS in web challenge157- Web + Crypto: JWT forgery, custom MAC/signature schemes158- Reverse + Pwn: reverse the binary first, then exploit the vulnerability159- Forensics + OSINT: recover data from dump, then trace it via public sources160- Misc + Crypto: jail escape requires building crypto primitives under constraints161- OSINT + Stego: social media posts with unicode homoglyph steganography (Cyrillic lookalikes encode bits)162- Web + Forensics: paywall bypass (curl reveals content hidden by CSS overlays)163- Misc + Crypto + Game Theory: multi-phase interactive challenges with AES decryption → HMAC commitment → combinatorial game solving (GF(256) Nim)164- Crypto + Geometry + Lattice: multi-layer challenges progressing from spatial reconstruction → subspace recovery → LWE solving → AES-GCM decryption165- Forensics + Signal Processing: power traces / side-channel analysis requiring statistical analysis of measurement data166- Forensics + Network + Encoding: timing-based encoding in PCAP (inter-packet intervals encode binary data)167168## Flag Formats169170**The user specifies the flag format in their request.** Always check the challenge description or CTF rules for the exact format before searching.171172Common formats:173| CTF | Format | Example |174|-----|--------|----------|175| picoCTF | `picoCTF{...}` | `picoCTF{s3cr3t}` |176| HackTheBox | `HTB{...}` | `HTB{b4sh_1s_fun}` |177| ENOCTF | `ENO{...}` | `ENO{abc123}` |178| NCSA / custom | `NCSA{...}` | `NCSA{MD5_of_something}` |179| Generic | `flag{...}` / `CTF{...}` | `flag{h3ll0}` |180| No wrapper | Plaintext / hash | `d41d8cd98f00b204e9800998ecf8427e` |181182**If the user specifies a custom format** (e.g., `NCSA{MD5....}`):183- Search for that prefix specifically: `grep -rniE 'NCSA\{' .`184- It might be composed (e.g., flag = `NCSA{` + MD5 of some extracted value + `}`)185- Always try to reconstruct if the raw value looks like an intermediate result186187**Search commands:**188```bash189# Any flag-like pattern190grep -rniE '(flag|ctf|eno|htb|pico|ncsa)\{' .191# Binary / memory output192strings output.bin | grep -iE '\{.*\}'193# Custom prefix194grep -rniE 'NCSA\{' .195```196197**Validation rule:**198- If multiple candidates found, prefer the one tied to the intended exploit path199- Save confirmed flag to `flag.txt` in the challenge folder200201## Quick Reference202203```bash204# Recon205file * # Identify file types206strings binary | grep -i flag # Quick string search207xxd binary | head -20 # Hex dump header208binwalk -e firmware.bin # Extract embedded files209checksec --file=binary # Check binary protections210211# Connect212nc host port # Connect to challenge213echo -e "answer1\nanswer2" | nc host port # Scripted input214curl -v http://host:port/ # HTTP recon215216# Python exploit template217python3 -c "218from pwn import *219r = remote('host', port)220r.interactive()221"222```223224## Challenge225226$ARGUMENTS