Lesson 1 of 9 · 24m
Reproducing Crashes in a Lab Before Chasing Exploits
Set up a controlled target, capture the first crash cleanly, and separate memory-corruption signal from ordinary input-validation failure.
The worst exploit developers I have trained were the fastest typists. They saw a segmentation fault, pasted a public payload, and learned nothing except how to copy a result they could not explain. The first discipline is slower and much more valuable: reproduce the crash in a lab you control, capture the exact input, and understand which part of the program actually broke.
Build a target you are allowed to break
Never learn memory corruption against a stranger's service. Use a local vulnerable binary, a deliberately vulnerable VM, or a toy program compiled for the lesson:
#include <stdio.h>
#include <string.h>
void greet(const char *input) {
char name[64];
strcpy(name, input);
printf("hello %s
", name);
}
int main(int argc, char **argv) {
if (argc != 2) return 2;
greet(argv[1]);
return 0;
}Compile it as a teaching artifact, not as a realistic hardened target:
gcc -fno-stack-protector -z execstack -no-pie -g -o /tmp/vuln-greet /tmp/vuln-greet.cThose flags deliberately remove protections. Say that out loud whenever you use them. A disabled mitigation is a microscope, not proof that the real-world target behaves the same way.
Capture the first fault, not the tenth consequence
Run the smallest input that fails, then grow it predictably:
python3 - <<'PY' >/tmp/input.txt
print('A' * 80)
PY
gdb -q /tmp/vuln-greet -ex 'run "$(cat /tmp/input.txt)"' -ex 'bt' -ex 'info registers' -ex quitDepending on the harness, you may need to pass input through a file, stdin, or a socket. Record the delivery method because parsing changes results. A crash reached through a file parser is not the same bug as a crash reached through a network daemon.
Read the fault before theorizing
Useful first-pass evidence includes the signal, faulting address, instruction pointer, top frames, input length, and exact build flags. A null dereference, assertion, stack overflow, heap corruption, and unhandled exception can all look like "it crashed"; the difference determines exploitability and remediation.
Reproducibility beats intensity
If the crash disappears, do not immediately blame the debugger. ASLR, allocator layout, compiler optimization, input truncation, and process lifetime all change behavior. Pin one variable at a time, preserve generated inputs in files, and capture a core dump with ulimit -c unlimited when interactive debugging is awkward.
Field notes
- A crash is a symptom, not a vulnerability class. Identify write primitives, read primitives, lifetime errors, or fatal input handling before theorizing.
- Do not confuse crash reproduction with exploitation; the gap between them is most of exploit development.
- Keep mitigations visible in every experiment note; changing
-fno-stack-protectorchanges the lesson. - If a target parses input as text, newline and NUL handling may truncate your test before memory corruption happens.
Was this lesson helpful?