summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordusoleil <howcansocksbereal@gmail.com>2022-03-10 19:24:31 -0500
committerdusoleil <howcansocksbereal@gmail.com>2022-03-10 19:24:31 -0500
commitb55d899d328c21cb0bb5994463340c8b64bf4a9f (patch)
tree3f475d852398063ead83b29dd76642c5a10fd103
parent198c658454eb88fc4805275da549ff67f2931cc2 (diff)
downloadsploit-b55d899d328c21cb0bb5994463340c8b64bf4a9f.tar.gz
sploit-b55d899d328c21cb0bb5994463340c8b64bf4a9f.zip
sploit: Split Symtbl funcionality with Memmap
Symtbl now only deals with offets. A read-only view of a symtbl can be created via the Memmap class. This view also takes an absolute address for a symbol and will return adjusted addresses based on this. This replaces the addr() method. Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
-rw-r--r--sploit/mem.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/sploit/mem.py b/sploit/mem.py
index 6de32f8..1149e99 100644
--- a/sploit/mem.py
+++ b/sploit/mem.py
@@ -1,15 +1,19 @@
class Symtbl:
- def __init__(self, base=0, **kwargs):
- self.__dict__ = {'base' : base, **kwargs}
+ def __init__(self, **kwargs):
+ self.__dict__ = {**kwargs}
- def __getattribute__(self, sym):
- a = object.__getattribute__(self, sym)
- if sym in object.__getattribute__(self,'__dict__') and sym != 'base':
- return self.base + a
- else:
- return a
- def addr(self, sym, addr):
- if sym == 'base' : self.base = addr
- else: self.base = addr - object.__getattribute__(self, sym)
+class Memmap:
+ def __init__(self, tbl, sym, addr):
+ object.__setattr__(self,'__tbl__', tbl)
+ base = addr if sym == 'base' else addr - getattr(self.__tbl__, sym)
+ object.__setattr__(self,'base', base)
+
+ def __getattribute__(self, sym):
+ if sym == '__tbl__' or sym == 'base':
+ return object.__getattribute__(self, sym)
+ a = getattr(self.__tbl__, sym)
+ return self.base + a
+ def __setattr__(self, k, v):
+ raise TypeError('Memmaps are Read-Only! Modify offsets with Symtbl instead!')