How a buffer overflow works: a stack frame filling with more input than it was made to hold. Much of the wing's work builds on understanding this.
0 / 88 BYTES WRITTENRET 0x00401b6a
+00a6c6cb114986a2a0
+0894f469deeca69021
+10db78ec1cb803e350
+18795f1bcfbf6b98e8
+20ded608ac6145d189
+28e56affa0805f789d
+309809c9499c8eee4d
+3874cc7be8960766e5
buf[64]A 64-byte buffer, and code that reads input without checking its length. Above the buffer sit values the program needs to return safely.
The buffer is full. Any further bytes overwrite memory that belongs to something else, and the language gives no warning.
The canary is a random value checked before the function returns. If it has changed, the program stops: a crash instead of a takeover. This check is one of the main defences.
The saved return address is now overwritten. Without the canary check, the program would jump to the wrong place when this function returns.
The last step matters most: reproduce the bug, reduce it to the smallest input that triggers it, and write it up so others can learn from it and fix it.