summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordusoleil <howcansocksbereal@gmail.com>2022-03-11 09:48:42 -0500
committerdusoleil <howcansocksbereal@gmail.com>2022-03-13 23:27:30 -0400
commit63b9139833b847000fe6cc76fad07f6f6866e416 (patch)
treeeed53e4ef88b120adc9b2daca727b86fe6b7d6a6
parentf3b278a1da4bd80c57d54188c270f780fac32c27 (diff)
downloadsploit-63b9139833b847000fe6cc76fad07f6f6866e416.tar.gz
sploit-63b9139833b847000fe6cc76fad07f6f6866e416.zip
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 <howcansocksbereal@gmail.com>
-rw-r--r--sploit/rev/r2.py21
1 files changed, 5 insertions, 16 deletions
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 '