Concepts / Binary exploitation

Binary exploitation

Stack buffer overflow

Also called stack smashing, ret2win, saved return address, return address overwrite, stack canary

Writing past a fixed stack buffer until the write reaches the function's saved return address, then choosing where the function returns to.

A long input reaches the return address
A long input reaches the return address

The saved return address sits just above the buffer. A write that runs past the buffer replaces it, and the function returns where the attacker chose.

A stack buffer overflow is a write that runs past a fixed-size buffer on the stack and overwrites the function's saved return address, stored just above it. It happens when input is copied without a length check (gets, strcpy). Whoever controls that address chooses where the function returns; ret2win points it at a function already in the binary. Defences: a stack canary, ASLR/PIE, and a non-executable stack.

See it on real machines

Read next

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab