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/util.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 sploit/util.py (limited to 'sploit/util.py') diff --git a/sploit/util.py b/sploit/util.py new file mode 100644 index 0000000..b0572a0 --- /dev/null +++ b/sploit/util.py @@ -0,0 +1,18 @@ +from subprocess import run + +def run_cmd(cmd): + return run(cmd,capture_output=True).stdout.decode('utf-8').split('\n')[:-1] + +__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 + + -- cgit v1.2.3 From 8897faa7387f8103df9dfdb54149d59bfde0e681 Mon Sep 17 00:00:00 2001 From: dusoleil Date: Sat, 12 Mar 2022 20:36:30 -0500 Subject: sploit: lazy load libs for ELF Signed-off-by: dusoleil --- sploit/util.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'sploit/util.py') 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 -- cgit v1.2.3 From c493a8f8073702bcdccdbc40bf09931e201c9013 Mon Sep 17 00:00:00 2001 From: dusoleil Date: Sun, 13 Mar 2022 23:34:23 -0400 Subject: sploit: Move __attr_filter__ to a general place in util Found a spot to use __attr_filter__ in the rev module, so moving it out of mem and into a shared place (util). Signed-off-by: dusoleil --- sploit/util.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sploit/util.py') diff --git a/sploit/util.py b/sploit/util.py index 610ab31..8a259c4 100644 --- a/sploit/util.py +++ b/sploit/util.py @@ -13,4 +13,10 @@ def run_cmd_cached(cmd): __RUN_CACHE__[key] = result return result +__attr_filter__ = ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', + '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', + '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', + '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', + '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', + '__weakref__'] -- cgit v1.2.3