fix(ghidra): handle PIE base address when opening the r2pipe

If we are trying to decompile a running binary which is a PIE, we need
to make sure to pass the appropriate base address to radare2 to be used
when loading a new binary.

Furthermore set io.cache to fix relocations in disassembly and avoid a
warning from the r2pipe.
pull/901/head
anthraxx 5 years ago committed by Disconnect3d
parent 71ca7213e2
commit 44770fd71f

@ -1,3 +1,5 @@
import pwndbg.elf
radare2 = {}
@ -6,7 +8,10 @@ def r2pipe(filename):
if r2:
return r2
import r2pipe
r2 = r2pipe.open(filename)
flags = ['-e', 'io.cache=true']
if pwndbg.elf.get_elf_info(filename).is_pie and pwndbg.elf.exe():
flags.extend(['-B', hex(pwndbg.elf.exe().address)])
r2 = r2pipe.open(filename, flags=flags)
radare2[filename] = r2
r2.cmd("aaaa")
return r2

Loading…
Cancel
Save