From eca4614ed7bf14117f45da023d23eb2d67432bab Mon Sep 17 00:00:00 2001
From: Malfurious <m@lfurio.us>
Date: Tue, 15 Mar 2022 23:04:16 -0400
Subject: sploit: Clean up use of __getattribute__

__getattribute__ is the low-level magic func and will intercept every
attribute lookup, whereas __getattr__ is high-level, and is only invoked
in specific conditions (such as __getattribute__'s failure).

As such, any overload of __getattribute__ which preferentially falls
back to object.__getattribute__() before serving a request, can more
simply be replaced by a __getattr__ overload without the fallback.

Signed-off-by: Malfurious <m@lfurio.us>
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
---
 tools/sploit/sploit/rev/elf.py | 5 +----
 tools/sploit/sploit/util.py    | 8 --------
 2 files changed, 1 insertion(+), 12 deletions(-)

(limited to 'tools')

diff --git a/tools/sploit/sploit/rev/elf.py b/tools/sploit/sploit/rev/elf.py
index 7bfd31f..e099819 100644
--- a/tools/sploit/sploit/rev/elf.py
+++ b/tools/sploit/sploit/rev/elf.py
@@ -1,5 +1,4 @@
 from sploit.rev import ldd, r2
-from sploit.util import __attr_filter__
 
 class ELF:
     def __init__(self, path):
@@ -38,9 +37,7 @@ class ELF:
     class __LOCALS__:
         def __init__(self, elf):
             self.elf = elf
-        def __getattribute__(self, sym):
-            if(sym in (['elf'] + __attr_filter__)):
-                return object.__getattribute__(self,sym)
+        def __getattr__(self, sym):
             return r2.get_locals(self.elf.path, getattr(self.elf.sym, sym))
 
     def retaddr(self, caller, callee):
diff --git a/tools/sploit/sploit/util.py b/tools/sploit/sploit/util.py
index 8a259c4..c44ab78 100644
--- a/tools/sploit/sploit/util.py
+++ b/tools/sploit/sploit/util.py
@@ -12,11 +12,3 @@ def run_cmd_cached(cmd):
         result = run_cmd(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