def load_elf_interp(self, p): for k, f in p.bin._Elf__dynamic(None).items(): xf = cpu.ext(f, size=32) xf.stub = self.stub(xf.ref) p.state.mmap.write(k, xf) # we want to add .plt addresses as symbols as well # to improve asm block views: plt = got = None for s in p.bin.Shdr: if s.name == '.plt': plt = s elif s.name == '.got': got = s if plt and got: address = plt.sh_addr pltco = p.bin.readsection(plt) while (pltco): i = p.cpu.disassemble(pltco) #TODO update to match plt structure for sparc if i.mnemonic == 'jmpl' and i.operands[0]._is_mem: target = i.operands[0].a if target.base is p.cpu.pc: target = address + target.disp elif target.base._is_reg: target = got.sh_addr + target.disp elif target.base._is_cst: target = target.base.value + target.disp if target in p.bin.functions: p.bin.functions[address] = p.bin.functions[target] pltco = pltco[i.length:] address += i.length
def libc_start_main(m, **kargs): "tags: func_call" m[cpu.pc] = m(cpu.mem(cpu.sp + 4, 32)) m[cpu.npc] = m(cpu.pc) + 4 cpu.push(m, cpu.ext("exit", size=32))
def load_shlib(self): for k,f in self.bin._Elf32__dynamic(None).iteritems(): self.mmap.write(k,cpu.ext(f))
def load_shlib(self): for k, f in self.bin._Elf32__dynamic(None).items(): self.mmap.write(k, cpu.ext(f, size=32))