diff options
author | dusoleil <howcansocksbereal@gmail.com> | 2023-03-23 03:45:20 -0400 |
---|---|---|
committer | dusoleil <howcansocksbereal@gmail.com> | 2023-03-23 03:45:20 -0400 |
commit | f388499a625af89e56669a8c76c65da21a7c1b1a (patch) | |
tree | 7a6dc96c090fa8abbfff00da26c7d088cd81c7c7 /sploit/rev/r2.py | |
parent | 382737c817a172a03b054bcc447437019eabcfb3 (diff) | |
download | sploit-f388499a625af89e56669a8c76c65da21a7c1b1a.tar.gz sploit-f388499a625af89e56669a8c76c65da21a7c1b1a.zip |
rev: Use json output for get_bin_info()
Grabbing the json and returning that dict directly avoids all of the
processing we were doing before. I also added in a small, temporary
band-aid for PE files until we add actual support for them. The 'relro'
key doesn't exist on PE files, so just default it to '' in ELF.
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
Diffstat (limited to 'sploit/rev/r2.py')
-rw-r--r-- | sploit/rev/r2.py | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/sploit/rev/r2.py b/sploit/rev/r2.py index f6bb43e..f239d09 100644 --- a/sploit/rev/r2.py +++ b/sploit/rev/r2.py @@ -15,8 +15,7 @@ def run_cmd(binary,cmd): def get_elf_symbols(elf): ilog(f'Retrieving symbols of {elf} with r2...') - base = get_bin_info(elf).baddr - base = int(base, 0) + base = get_bin_info(elf)['baddr'] sect = json.loads(run_cmd(elf,'iSj')[0]) sect = {s['name']:s['vaddr'] for s in sect} @@ -81,7 +80,7 @@ def rop_gadgets(binary, *regexes, cont=False): ilog(f"Searching {binary} for {'; '.join(regexes)} gadgets with r2...") gadgets = rop_json(binary) results = [] - base = int(get_bin_info(binary).baddr, 0) + base = get_bin_info(binary)['baddr'] for gadget in gadgets: opcodes = gadget['opcodes'] @@ -133,11 +132,4 @@ def get_call_returns(binary,xref_from,xref_to): def get_bin_info(binary): ilog(f'Retrieving binary and security info about {binary} with r2...') - BinInfo = nt("BinInfo", "bintype os arch bits endian baddr canary nx pic relocs relro rpath stripped") - cmd_info = 'iI' - info = run_cmd(binary, cmd_info) - info = [re.split(r'\s+',i,1) for i in info] - info = {i[0]:i[1] for i in info} - info = [info[f] for f in BinInfo._fields] - ret = BinInfo(*info) - return ret + return json.loads(run_cmd(binary,'iIj')[0]) |