Introduction
In a software program, buffer overflow occurs when a program, while writing data to a buffer, overruns the buffer size allocated and starts overwriting data to adjacent memory locations.
A buffer can be considered a temporary area in the memory allocated to a program to store and retrieve data when needed.
Buffer overflows have been known to be exploited since long back.
When exploiting buffer overflows, our main focus is on overwriting some control information so that the flow of control of the program changes, which will allow our code to take control of the program.
Here is a diagram that will give us a basic idea of an overflow happening in a buffer:
Â
From the preceding diagram, we can assume this is what a program looks like. Since it is a stack, it starts from bottom and moves toward the top of the stack.
Seeing the preceding diagram, we also notice that the program has a fixed buffer to store 16 letters/bytes of data.
We first enter the 8 characters (1 char=1 byte); on the right...