From 2340245d685ec19e6517f95c1ff8dc8b9249e873 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 --- tools/sploit/sploit/rev/r2.py | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/tools/sploit/sploit/rev/r2.py b/tools/sploit/sploit/rev/r2.py index 306e026..6fde112 100644 --- a/tools/sploit/sploit/rev/r2.py +++ b/tools/sploit/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