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
commit2340245d685ec19e6517f95c1ff8dc8b9249e873 (patch)
tree96010c1b8c050289451fe671a639d9fd54b2e71a
parentf239dd6d622a6c2a18cfee07aa2e2e120eef2deb (diff)
downloadlib-des-gnux-2340245d685ec19e6517f95c1ff8dc8b9249e873.tar.gz
lib-des-gnux-2340245d685ec19e6517f95c1ff8dc8b9249e873.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--tools/sploit/sploit/rev/r2.py21
1 files 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 '