From 57e5d92be7e82f28adcb3212c73bb06b0b8d7fe8 Mon Sep 17 00:00:00 2001 From: dusoleil Date: Fri, 11 Mar 2022 09:04:32 -0500 Subject: sploit: add ldd ability to rev module add helper function to invoke ldd to get a list of libraries that will be linked to a given ELF Signed-off-by: dusoleil --- sploit/rev/ldd.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 sploit/rev/ldd.py (limited to 'sploit/rev/ldd.py') diff --git a/sploit/rev/ldd.py b/sploit/rev/ldd.py new file mode 100644 index 0000000..60306f1 --- /dev/null +++ b/sploit/rev/ldd.py @@ -0,0 +1,10 @@ +import re +from subprocess import run +from collections import namedtuple as nt + +def get_libraries(elf): + out = run(['ldd',elf],capture_output=True).stdout.decode('utf-8').split('\n')[:-1] + out = [re.split(r'\s+',lib)[1:] for lib in out] + Lib = nt("Lib", "name path addr") + out = {l[0]:Lib(l[0],l[0] if l[0][0]=='/' else l[2] if l[1]=='=>' else None,l[-1]) for l in out} + return out -- cgit v1.2.3 From 509a8cfcadcca94d336fe08be897f62a721079d2 Mon Sep 17 00:00:00 2001 From: dusoleil Date: Sat, 12 Mar 2022 19:18:28 -0500 Subject: sploit: cache results of external commands rather than cacheing ELF instantiations, just cache the results of external commands Signed-off-by: dusoleil --- sploit/rev/ldd.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sploit/rev/ldd.py') diff --git a/sploit/rev/ldd.py b/sploit/rev/ldd.py index 60306f1..d162207 100644 --- a/sploit/rev/ldd.py +++ b/sploit/rev/ldd.py @@ -1,9 +1,10 @@ +from sploit.util import run_cmd_cached + import re -from subprocess import run from collections import namedtuple as nt def get_libraries(elf): - out = run(['ldd',elf],capture_output=True).stdout.decode('utf-8').split('\n')[:-1] + out = run_cmd_cached(['ldd',elf]) out = [re.split(r'\s+',lib)[1:] for lib in out] Lib = nt("Lib", "name path addr") out = {l[0]:Lib(l[0],l[0] if l[0][0]=='/' else l[2] if l[1]=='=>' else None,l[-1]) for l in out} -- cgit v1.2.3 From 6bc9c69c534447ecec79ae551d8f6b3e50c71eba Mon Sep 17 00:00:00 2001 From: dusoleil Date: Sat, 12 Mar 2022 21:22:36 -0500 Subject: sploit: add status logging to rev module Signed-off-by: dusoleil --- sploit/rev/ldd.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sploit/rev/ldd.py') diff --git a/sploit/rev/ldd.py b/sploit/rev/ldd.py index d162207..1a28c7c 100644 --- a/sploit/rev/ldd.py +++ b/sploit/rev/ldd.py @@ -1,9 +1,11 @@ from sploit.util import run_cmd_cached +from sploit.log import ilog import re from collections import namedtuple as nt def get_libraries(elf): + ilog(f'Retrieving linked libraries of {elf} with ldd...') out = run_cmd_cached(['ldd',elf]) out = [re.split(r'\s+',lib)[1:] for lib in out] Lib = nt("Lib", "name path addr") -- cgit v1.2.3