Vulnerability Research & Fuzzing for CTF
What is Fuzzing?
Fuzzing is a coverage‑guided technique that feeds random or malformed inputs into a target to trigger crashes that reveal memory‑corruption bugs. In CTF, fuzzing a challenge binary often uncovers a buffer overflow or format‑string vulnerability that yields a flag.
Setting Up a Fuzzer
- AFL (American Fuzzy Lop): Compile target with
AFL_USE_ASAN=1 afl-gcc. - libFuzzer: Link target with
-fsanitize=address,fuzzerand compile as a library. - Peach: Define Pit XML files for file‑format fuzzing.
Fuzzing Workflow
- Identify input vector: network service (e.g., custom HTTP server), file parser (PNG, PDF), or CLI tool.
- Instrument: Use AFL’s
afl-clang-fastfor LLVM‑based coverage. - Seed corpus: Provide valid samples to guide mutation.
- Run: Launch
afl-fuzz -i seeds -o findings -- ./target @@. - Triage crashes: Analyze with GDB or pwndbg to determine if the crash is exploitable.
Crash Analysis in CTF
- Stack trace: Use
btin GDB to locate vulnerable function. - Control‑flow hijack: Check if instruction pointer (
RIP) can be redirected. - Pattern generation: Generate cyclic pattern with
msf-pattern_createto calculate offset.
Pakistani Application Example
- NADRA ID parser: A CTF may involve a binary that reads citizen data from a file; fuzz it to discover a heap‑overflow that leaks the flag stored in memory.
- Mobile app binary: Use Frida to hook native library and feed fuzzer‑generated inputs via IPC.
Do / Don't
- Do run fuzzers on isolated VMs with snapshot backups.
- Don’t fuzz binaries on production systems or networks you don’t own.
Takeaway
Integrate AFL into your CTF workflow: instrument a target, run a fuzzing campaign, triage crashes, and develop a working exploit to capture the flag.
