From b55d899d328c21cb0bb5994463340c8b64bf4a9f Mon Sep 17 00:00:00 2001 From: dusoleil Date: Thu, 10 Mar 2022 19:24:31 -0500 Subject: 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 --- sploit/mem.py | 26 +++++++++++++++----------- 1 file 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!') -- cgit v1.2.3