
ESP (Top) | Buffer Space | EBP (Bottom) | EIP/Return Address
What happens is we have buffer space and this buffer space is fills up with characters then the buffer space is going to go downward. What should happen is, if you are probably sanitizing your buffer space, then if send bunch of characters at it. Say, bunch of A's We should reach EBP but then stop. The buffer should be able to contain the character that you are sending.
Now, however if you have buffer overflow attack then you actually overflow the buffer space you are using and reach over the EBP enters into something called EIP.
Now, EIP is where things get interesting. This is pointer address or return address. So, what we can do is, we can use this address to point to direction to direction that we instruct. Now, these directions are going to be malicious code that gives us a reverse shell. We are overflowing buffer space. So, we can write over the buffer space and write down all the way to EIP. You can control the stack. You can control the pointer and eventually you can have a reverse shell which will lead to root.

This Process is divided into 8 Steps: