I try to learn the buffer overflow exploit .
i have this code :
#include <stdio.h>
int read_req(FILE *p) {
char buf[16];
int i;
fgets(buf, 1024, p);
i = atoi(buf);
return i;
}
int main() {
FILE *fp = fopen("/home/assignment/shellcode", "r");
int x = read_req(fp);
printf("x = %d\n", x);
}
I want to exploit this code using this shellcode :
#include <stdio.h>
void main() {
char *name[2];
name[0] = "/bin/sh";
name[1] = NULL;
/* Launch shell */
execve(name[0],name, NULL);
}
but i dont know how to use it , also i heard that fgets dont cause the buffer overflow problem .. I'm confused
Think you