Simple Buffer Overflow - 0x00
tags: CTF PWN
Original Code
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main()
{
char buf[0x10];
read(0, buf, 0x30); // It'll read the value that you input and store in buf with length=0x30
system("pause");
return 0;
}
- Note that you can check this page to know more about
readfunction
Dynamic Analysis - x32dbg
-
This is the original entry point of this program.

-
0x00404185is thereadfunction that will catch the input string we entered. So, we step into this function and continued executing until0x7655BFE5.
-
The most important part
In order to trigger buffer overflow, we must enter the string that size is over 16 to overlap
ebpandeipregister.
-
If we enter a normal length string such as
aaaaaaaaaaaaaaaa, theeipregister will store0x0040148Aand finish the program normally.
- How about we enter 32
acharacters? Theebpandeipregister will be overlapped by0x61616161(aaaaaaaaa) so that we can control the program flow by overlapping a specific address.