Stack buffer overflow: the basics everything rests on
Local variables live on the stack, next to the function's return address. A gets() or an unbounded strcpy() writes past the buffer and reaches that pointer.
void vuln(){ char buf[64]; gets(buf); } // no boundWith a 64-byte buffer + saved rbp, the 73rd group of bytes lands in the return address. Control it and you control where the CPU jumps at ret.
Finding the offset
cyclic 200 # De Bruijn pattern
# after the crash:
cyclic -l 0x6161... # exact offset of the return addressDefence
Stack canary (detects the overflow before ret), NX (non-executable stack), ASLR, and above all bounded functions (fgets, strncpy). Modern compilers with _FORTIFY_SOURCE catch many cases.