diff options
author | dusoleil <howcansocksbereal@gmail.com> | 2022-03-12 20:36:30 -0500 |
---|---|---|
committer | dusoleil <howcansocksbereal@gmail.com> | 2022-03-13 23:27:30 -0400 |
commit | 3ddf898a5e664ed84d1b30dbfdd34bb977f15ce4 (patch) | |
tree | fde2e46dbbe2a50ce5ed5ecbffa73323b181f6d4 | |
parent | bb5575987ff7237af8011928304ed2db2a457720 (diff) | |
download | lib-des-gnux-3ddf898a5e664ed84d1b30dbfdd34bb977f15ce4.tar.gz lib-des-gnux-3ddf898a5e664ed84d1b30dbfdd34bb977f15ce4.zip |
sploit: lazy load libs for ELF
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
-rw-r--r-- | tools/sploit/sploit/rev/elf.py | 20 | ||||
-rw-r--r-- | tools/sploit/sploit/util.py | 2 |
2 files changed, 16 insertions, 6 deletions
diff --git a/tools/sploit/sploit/rev/elf.py b/tools/sploit/sploit/rev/elf.py index 1957c15..acfe73b 100644 --- a/tools/sploit/sploit/rev/elf.py +++ b/tools/sploit/sploit/rev/elf.py @@ -5,7 +5,7 @@ class ELF: 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} + self.libs = self.__LIBS__(libs) self.locals = self.__LOCALS__(self) def __str__(self): @@ -18,12 +18,24 @@ class ELF: s += '\n------------' s += '\nLibararies' s += '\n------------' - for name,lib in self.libs.items(): - s += '\n' + str(name) + ' => ' + str(lib.path) + s += str(self.libs) return s + class __LIBS__(dict): + def __init__(self, libs): + super().__init__({lib.name:lib.path for lib in libs.values() if lib.path}) + def __getitem__(self, lib): + get = super().__getitem__ + if(type(get(lib))==str):self[lib] = ELF(get(lib)) + return get(lib) + def __str__(self): + s = '' + for name,lib in self.items(): + s += '\n' + str(name) + ' => ' + lib if(type(lib)==str) else str(lib.path) + return s + class __LOCALS__: - def __init__(self,elf): + def __init__(self, elf): self.elf = elf def __getattribute__(self, sym): if(sym=='elf'):return object.__getattribute__(self,sym) diff --git a/tools/sploit/sploit/util.py b/tools/sploit/sploit/util.py index b0572a0..610ab31 100644 --- a/tools/sploit/sploit/util.py +++ b/tools/sploit/sploit/util.py @@ -7,10 +7,8 @@ __RUN_CACHE__ = {} def run_cmd_cached(cmd): key = ''.join(cmd) if key in __RUN_CACHE__: - print('cache hit') return __RUN_CACHE__[key] else: - print('cache miss') result = run_cmd(cmd) __RUN_CACHE__[key] = result return result |