Jul 12, 2015 10:16 AM
(This post was last modified: Jul 12, 2015 10:17 AM by Saegon.)
so i have the following code
and the goal is to execute bar();
i supplied the following input
to get the following output
So all i need to do is append the address of bar in reverse to the string that i supplied right?
I tried this, but it didnt work.
Please help I dont know how to do this.
Code
#include <string.h>
#include <stdio.h>
void foo(const char* input)
{
char buf[10];
printf("My stack looks like:\n%p\n%p\n%p\n%p\n%p\n% p\n\n");
strcpy(buf, input);
printf("%s\n", buf);
printf("Now the stack looks like:\n%p\n%p\n%p\n%p\n%p\n%p\n\n");
}
void bar(void)
{
printf("Augh! I've been hacked!\n");
}
int main(int argc, char* argv[])
{
//Blatant cheating to make life easier on myself
printf("Address of foo = %p\n", foo);
printf("Address of bar = %p\n", bar);
if (argc != 2)
{
printf("Please supply a string as an argument!\n");
return -1;
}
foo(argv[1]);
return 0;
}and the goal is to execute bar();
i supplied the following input
Code
./overflow `python -c 'print "a"*16'`to get the following output
Code
foo address: 0x40059c
bar address: 0x4005e7
0x7f64ced1c000
0x7f64ceafbdf0
0x400769
0x1
0x1
0x400748
0x7fff9cd6370b
0x7f64ceb0e310
0x7f64ced211c8
0x7fff9cd623d0
aaaaaa
0x7f64ced1c000
0x7f64ceafbdf0
0x7f64ce844780
0x7f64ced1c010
0x7f64ced02700
0x400748
0x7fff9cd6370b
0x6161616161616161
0x6161616161616161
0x7fff9cd62300So all i need to do is append the address of bar in reverse to the string that i supplied right?
I tried this, but it didnt work.
Code
./overflow `python -c 'print "a"*16 + "\xe7\x05\x40"'`Please help I dont know how to do this.

