PISA Pakistan — Community CERT

← 🚩 CTF: Getting Started

36. Vulnerability Research & Fuzzing for CTF

⏱ 9 min

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,fuzzer and compile as a library.
  • Peach: Define Pit XML files for file‑format fuzzing.

Fuzzing Workflow

  1. Identify input vector: network service (e.g., custom HTTP server), file parser (PNG, PDF), or CLI tool.
  2. Instrument: Use AFL’s afl-clang-fast for LLVM‑based coverage.
  3. Seed corpus: Provide valid samples to guide mutation.
  4. Run: Launch afl-fuzz -i seeds -o findings -- ./target @@.
  5. Triage crashes: Analyze with GDB or pwndbg to determine if the crash is exploitable.

Crash Analysis in CTF

  • Stack trace: Use bt in GDB to locate vulnerable function.
  • Control‑flow hijack: Check if instruction pointer (RIP) can be redirected.
  • Pattern generation: Generate cyclic pattern with msf-pattern_create to 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.

← PrevNext →