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 | 8897faa7387f8103df9dfdb54149d59bfde0e681 (patch) | |
tree | ded486bf0a92048c225575cc2fe155dde198da37 | |
parent | 509a8cfcadcca94d336fe08be897f62a721079d2 (diff) | |
download | sploit-8897faa7387f8103df9dfdb54149d59bfde0e681.tar.gz sploit-8897faa7387f8103df9dfdb54149d59bfde0e681.zip |
sploit: lazy load libs for ELF
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
-rw-r--r-- | sploit/rev/elf.py | 20 | ||||
-rw-r--r-- | sploit/util.py | 2 |
2 files changed, 16 insertions, 6 deletions
diff --git a/sploit/rev/elf.py b/sploit/rev/elf.py index 1957c15..acfe73b 100644 --- a/sploit/rev/elf.py +++ b/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/sploit/util.py b/sploit/util.py index b0572a0..610ab31 100644 --- a/sploit/util.py +++ b/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 |