From 63b9139833b847000fe6cc76fad07f6f6866e416 Mon Sep 17 00:00:00 2001 From: dusoleil Date: Fri, 11 Mar 2022 09:48:42 -0500 Subject: sploit: consolidate r2 symbol search calls Consolidate some of the r2 calls that get combined to create the symbol list. Instead of doing multiple calls with different greps within radare2, just do a single call and search it in the python side. This gives us a slight, but noticeable performance increase. Signed-off-by: dusoleil --- sploit/rev/r2.py | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'sploit/rev/r2.py') diff --git a/sploit/rev/r2.py b/sploit/rev/r2.py index 306e026..6fde112 100644 --- a/sploit/rev/r2.py +++ b/sploit/rev/r2.py @@ -10,23 +10,12 @@ def run_cmd(binary,cmd): def get_elf_symbols(elf): out = {} - - cmd_syms = 'is~ FUNC ' - out_syms = run_cmd(elf,cmd_syms) - out_syms = [re.split(r'\s+',sym) for sym in out_syms] - out_syms = {sym[6]:int(sym[2],0) for sym in out_syms if sym[6].find('.')<0} - out.update(out_syms) - - cmd_syms = 'is~ LOOS ' + cmd_syms = 'is' out_syms = run_cmd(elf,cmd_syms) - out_syms = [re.split(r'\s+',sym) for sym in out_syms] - out_syms = {sym[6]:int(sym[2],0) for sym in out_syms if sym[6].find('.')<0} - out.update(out_syms) - - cmd_syms = 'is~ TLS ' - out_syms = run_cmd(elf,cmd_syms) - out_syms = [re.split(r'\s+',sym) for sym in out_syms] - out_syms = {sym[6]:int(sym[2],0) for sym in out_syms if sym[6].find('.')<0} + out_syms = [re.split(r'\s+',sym) for sym in out_syms][4:] + out_syms = [sym for sym in out_syms if sym[6].find('.')<0] + out_syms = [sym for sym in out_syms if sym[4]=='FUNC' or sym[4]=='LOOS' or sym[4]=='TLS'] + out_syms = {sym[6]:int(sym[2],0) for sym in out_syms} out.update(out_syms) cmd_syms = 'ii~ FUNC ' -- cgit v1.2.3