From 352fe42c6e5e4f5996289bc0d9479c1be19c1117 Mon Sep 17 00:00:00 2001 From: dusoleil Date: Fri, 11 Mar 2022 10:15:35 -0500 Subject: sploit: add ELF helper class to rev Create a class which encapsulates some basic information about an ELF file and provides a convenient interface for basic reverse engineering. In particular, ELF automatically loads the symbol table of the given elf file and recursively creates ELF objects for any linked libraries. Signed-off-by: dusoleil --- tools/sploit/sploit/rev/__init__.py | 1 + tools/sploit/sploit/rev/elf.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tools/sploit/sploit/rev/elf.py (limited to 'tools') diff --git a/tools/sploit/sploit/rev/__init__.py b/tools/sploit/sploit/rev/__init__.py index b6a73a2..43cee7b 100644 --- a/tools/sploit/sploit/rev/__init__.py +++ b/tools/sploit/sploit/rev/__init__.py @@ -1,5 +1,6 @@ from . import ( ldd, r2, + elf, ) diff --git a/tools/sploit/sploit/rev/elf.py b/tools/sploit/sploit/rev/elf.py new file mode 100644 index 0000000..a748f10 --- /dev/null +++ b/tools/sploit/sploit/rev/elf.py @@ -0,0 +1,22 @@ +from sploit.rev import ldd, r2 + +class ELF: + def __init__(self, path): + self.path = path + self.sym = r2.get_elf_symbols(self.path) + libs = ldd.get_libraries(self.path) + self.libs = {lib.name:ELF(lib.path) for lib in libs.values() if lib.path} + + def __str__(self): + s = 'ELF: ' + s += self.path + s += '\nSymbol Table' + s += '\n------------' + s += '\n' + s += str(self.sym) + s += '\n------------' + s += '\nLibararies' + s += '\n------------' + for name,lib in self.libs.items(): + s += '\n' + str(name) + ' => ' + str(lib.path) + return s -- cgit v1.2.3