I am trying to run this piece of vulnerable C code:
#include <stdio.h>
#include <stdlib.h>
int add(int x, int y)
{
int z =10;
z = x + y;
return z;
}
main(int argc, char **argv)
{
int a = atoi(argv[1]);
int b = atoi(argv[2]);
int c;
char buffer[100];
gets(buffer);
puts(buffer);
c = add(a,b);
printf("Sum of %d+%d = %d\n",a, b, c);
exit(0);
}
I am trying to get past the segmentation fault so that I can input the integers but the segmentation fault prevents that. In the terminal I have tried: gcc -ggdb -fno-stack-protector -U_FORTIFY_SOURCE -Wa,--execstack -o SimpleDemo SimpleDemo.c
I still get a segmentation fault. I am lost as to what to try next. As you can probably tell, I am an ubuntu newb. The bash code I am using comes from here:
http://www.evanjones.ca/buffer-overflow-101.html
I have been at this for while so would really appreciate some help
Cheers
atoi(argv[1])call will seg fault (probably).