diff options
author | dusoleil <howcansocksbereal@gmail.com> | 2023-03-16 18:38:57 -0400 |
---|---|---|
committer | dusoleil <howcansocksbereal@gmail.com> | 2023-03-16 18:38:57 -0400 |
commit | 0bdf7d37fc2aa3cfc2fa02348f006996fa0bcce8 (patch) | |
tree | aa403058001dcdad76d20b4d5975a168ed67d0d2 | |
parent | 6e2d648cd7ffa7866a511bd27ba60188909d79cb (diff) | |
download | sploit-0bdf7d37fc2aa3cfc2fa02348f006996fa0bcce8.tar.gz sploit-0bdf7d37fc2aa3cfc2fa02348f006996fa0bcce8.zip |
r2: Use get_bin_info in get_elf_symbols
Code reuse since we were using r2 iI in get_elf_symbols to get the
baddr. This can cause get_bin_info to be called (and log that it's
being called) multiple times, so I'm also adding the @cache annotation.
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
-rw-r--r-- | sploit/rev/r2.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sploit/rev/r2.py b/sploit/rev/r2.py index bd4133e..24ab1f8 100644 --- a/sploit/rev/r2.py +++ b/sploit/rev/r2.py @@ -16,11 +16,6 @@ def get_elf_symbols(elf): ilog(f'Retrieving symbols of {elf} with r2...') out = {} - cmd_base = 'iI~baddr' - base = run_cmd(elf,cmd_base) - base = re.split(r'\s+',base[0])[1] - base = int(base,0) - cmd_syms = 'is' out_syms = run_cmd(elf,cmd_syms) out_syms = [re.split(r'\s+',sym) for sym in out_syms][4:] @@ -47,6 +42,9 @@ def get_elf_symbols(elf): out_strs = {sym[2][sym[2].rfind('.')+1:]:int(sym[0],0) for sym in out_strs} out.update(out_strs) + base = get_bin_info(elf).baddr + base = int(base,0) + return Symtbl(base=base, **out) def get_locals(binary,func): @@ -113,6 +111,7 @@ def rop_gadget(binary, *regexes): raise LookupError(f"Could not find gadget for: {'; '.join(regexes)}") return results[0] +@cache def get_call_returns(binary,xref_from,xref_to): ilog(f'Getting return addresses of calls from {hex(xref_from)} to {hex(xref_to)} in {binary} with r2...') @@ -128,6 +127,7 @@ def get_call_returns(binary,xref_from,xref_to): rets.append(CallRet(xref_from,xref_to,int(x[0],0),int(ret[0],0))) return rets +@cache def get_bin_info(binary): ilog(f'Retrieving binary and security info about {binary} with r2...') |