Week 6 - Buffer Overflow Exercise Card
I already have the full content from earlier — no need to re-read the whole thing. Here's the condensed Week 6 card:
Build the vulnerable binary (Exercise 1)
gcc -m32 -fno-stack-protector -z execstack -no-pie -o vuln vuln.c
echo 0 | sudo tee /proc/sys/kernel/randomize_va_space # disable ASLR
checksec --file=./vuln| Flag | Turns off |
|---|---|
-m32 | (32-bit build, ESP/EBP/EIP names) |
-fno-stack-protector | Stack canary |
-z execstack | NX (stack becomes executable) |
-no-pie | ASLR of the binary itself |
Want to see: No canary found, NX disabled, No PIE
Crash it & find the offset (Exercise 2)
./vuln $(python3 -c 'print("A"*200)') # baseline crash — EIP = 0x41414141
edb --run ./vuln $(python3 -c 'from pwn import *;print(cyclic(200).decode())')- In EDB: crash → read EIP's 4-byte value →
python3 -c 'from pwn import *; print(cyclic_find(0x61616174))' # → your offset- Prove it:
"A"*offset + "B"*4→ EIP should read exactly0x42424242
⚠️ Why cyclic pattern > guessing from buffer size: compiler may add padding/alignment you can't see from source — always read the offset off the tool, don't assume.
Reason about next steps (Exercise 3 — no commands, conceptual)
| Attack step | Mitigation that stops it |
|---|---|
| Overwriting RET undetected | Stack canary (checked before ret) |
| Knowing where to jump | ASLR/PIE (randomizes addresses) |
| Running injected shellcode | DEP/NX (marks stack non-executable) |
No image needed for commands — but if you want one visual, the EIP register showing 0x42424242 is the single "aha" moment screenshot worth keeping in your head (not your cheat sheet) since it's literally what you're proving happened.