From 5b84c859396574795f4f5beb296e23f4f6458059 Mon Sep 17 00:00:00 2001 From: dusoleil Date: Sun, 13 Mar 2022 23:15:42 -0400 Subject: sploit: Filter all magic python members by default in mem module In the various __getattribute__() overloads in the mem module, we should filter all of the built-in magic members to do the default object.__getattribute__() behavior. This is opposed to the earlier stance of just caring about the ones that I saw as realistically being called. Signed-off-by: dusoleil --- sploit/mem.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'sploit/mem.py') diff --git a/sploit/mem.py b/sploit/mem.py index 3ad0c50..c953fce 100644 --- a/sploit/mem.py +++ b/sploit/mem.py @@ -12,7 +12,7 @@ class Symtbl: self.off = off self.tbl = tbl def __getattribute__(self,sym): - if(sym in ['off','tbl','__class__']): + if(sym in (['off','tbl'] + __attr_filter__)): return object.__getattribute__(self,sym) addr = getattr(self.tbl,sym) if(type(addr)==int): @@ -30,7 +30,8 @@ class Symtbl: def __getattribute__(self, sym): addr = object.__getattribute__(self,sym) - if(sym == '__subs__'):return addr + if(sym in (['__subs__'] + __attr_filter__)): + return addr if(sym == 'base'):return 0 if(sym in self.__subs__): return self.__InnerTable__(addr,self.__subs__[sym]) @@ -51,7 +52,7 @@ class Memmap: self.base = addr - sym def __getattribute__(self, sym): - if(sym in ['__tbl__','base']): + if(sym in (['__tbl__','base'] + __attr_filter__)): return object.__getattribute__(self, sym) addr = getattr(self.__tbl__, sym) if(type(addr)==Symtbl.__InnerTable__): @@ -83,3 +84,5 @@ def __str__(self,tbl): else: s += __tbl_format__.format(hex(addr),sym) return s + +__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 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/mem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sploit/mem.py') diff --git a/sploit/mem.py b/sploit/mem.py index c953fce..ac2bbb1 100644 --- a/sploit/mem.py +++ b/sploit/mem.py @@ -1,3 +1,5 @@ +from sploit.util import __attr_filter__ + class Symtbl: __subs__ = {} def __init__(self, **kwargs): @@ -84,5 +86,3 @@ def __str__(self,tbl): else: s += __tbl_format__.format(hex(addr),sym) return s - -__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