In simple words, a buffer is a place to store any kind of data. An overflow occurs when the data in the buffer exceeds the size of the buffer itself. An attacker can then perform an overflow attack so as to get control of the program and execute malicious payloads.
Let's use an example of a simple program and see how we could exploit it. In the following screenshot, we have a simple program with three functions: vulnerable
, ShouldNotBeCalled
, and main
. The following is the program we are trying to exploit:
The ShouldNotBeCalled
function is never called during the entire runtime of the program.
The vulnerable
function simply copies the argument into a buffer named buff
that is 10 bytes in size.
Once we have finished writing the program, we could compile it using gcc
, as shown in the next command. Also, we will disable the Address Space Layout Randomization (ASLR) here, just to make the scenario a little bit simpler. ASLR is a security technique implemented by...