1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
// Classic buffer overflow — no canary, no PIE // Compile: gcc -fno-stack-protector -no-pie -o bof_basic bof_basic.c #include <stdio.h> #include <stdlib.h> #include <string.h> void win() { system("/bin/sh"); } void vuln() { char buf[64]; printf("Enter input: "); gets(buf); printf("You said: %s\n", buf); } int main() { vuln(); return 0; }