summaryrefslogtreecommitdiffstats
path: root/tools
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
commit2624c2961ec043c6a2b08f7923602a784e392c10 (patch)
tree76d867b2c0c2666b767023a8850fcf4bbbeeae0c /tools
parent882231b1af6021b4a083533005ef13d191638acb (diff)
downloadlib-des-gnux-2624c2961ec043c6a2b08f7923602a784e392c10.tar.gz
lib-des-gnux-2624c2961ec043c6a2b08f7923602a784e392c10.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>
Diffstat (limited to 'tools')
-rw-r--r--tools/sploit/sploit/mem.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/tools/sploit/sploit/mem.py b/tools/sploit/sploit/mem.py
index 6de32f8..1149e99 100644
--- a/tools/sploit/sploit/mem.py
+++ b/tools/sploit/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!')