Week 6 - Buffer Overflow Exercise Card

Updated 5 Oct 2026

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
FlagTurns off
-m32(32-bit build, ESP/EBP/EIP names)
-fno-stack-protectorStack canary
-z execstackNX (stack becomes executable)
-no-pieASLR 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 exactly 0x42424242

⚠️ 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 stepMitigation that stops it
Overwriting RET undetectedStack canary (checked before ret)
Knowing where to jumpASLR/PIE (randomizes addresses)
Running injected shellcodeDEP/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.