summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authordusoleil <howcansocksbereal@gmail.com>2022-03-13 17:53:23 -0400
committerdusoleil <howcansocksbereal@gmail.com>2022-03-13 17:53:23 -0400
commitc486409b4dcb0048be972013801d7624f8ff4dcb (patch)
treefe0efca549689b5e114383c984bf53628546777a /tools
parentff3b871f75013748a66d1c0a4ee8de7e311d3281 (diff)
downloadlib-des-gnux-c486409b4dcb0048be972013801d7624f8ff4dcb.tar.gz
lib-des-gnux-c486409b4dcb0048be972013801d7624f8ff4dcb.zip
sploit: Add support for nested Symtbls
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/sploit/sploit/mem.py48
1 files changed, 45 insertions, 3 deletions
diff --git a/tools/sploit/sploit/mem.py b/tools/sploit/sploit/mem.py
index 932510d..3ad0c50 100644
--- a/tools/sploit/sploit/mem.py
+++ b/tools/sploit/sploit/mem.py
@@ -1,7 +1,41 @@
class Symtbl:
+ __subs__ = {}
def __init__(self, **kwargs):
self.__dict__ = {**kwargs}
+ def subtable(self, sym, off, table):
+ setattr(self, sym, off)
+ self.__subs__[sym] = table
+
+ class __InnerTable__:
+ def __init__(self,off,tbl):
+ self.off = off
+ self.tbl = tbl
+ def __getattribute__(self,sym):
+ if(sym in ['off','tbl','__class__']):
+ return object.__getattribute__(self,sym)
+ addr = getattr(self.tbl,sym)
+ if(type(addr)==int):
+ return addr + self.off
+ if(type(addr)==self.__class__):
+ addr.off += self.off
+ return addr
+ return addr
+ def __setattr__(self,sym,off):
+ if(sym in ['off','tbl']):
+ return object.__setattr__(self,sym,off)
+ return setattr(self.tbl,sym,off-self.off)
+ def __str__(self):
+ return str(self.tbl)
+
+ def __getattribute__(self, sym):
+ addr = object.__getattribute__(self,sym)
+ if(sym == '__subs__'):return addr
+ if(sym == 'base'):return 0
+ if(sym in self.__subs__):
+ return self.__InnerTable__(addr,self.__subs__[sym])
+ return addr
+
def adjust(self, off):
self.__dict__ = {k:v+off for k,v in self.__dict__.items()}
@@ -19,12 +53,16 @@ class Memmap:
def __getattribute__(self, sym):
if(sym in ['__tbl__','base']):
return object.__getattribute__(self, sym)
- a = getattr(self.__tbl__, sym)
- return self.base + a
+ addr = getattr(self.__tbl__, sym)
+ if(type(addr)==Symtbl.__InnerTable__):
+ addr.off += self.base
+ return addr
+ return self.base + addr
def __setattr__(self, sym, addr):
if(sym in ['__tbl__','base']):
return object.__setattr__(self,sym,addr)
+ return setattr(self.__tbl__,sym,addr-self.base)
def __str__(self):
s = __str__(self,self.__tbl__.__dict__)
@@ -39,5 +77,9 @@ def __str__(self,tbl):
s = 'symbols: ' + str(len(tbl))
s += __tbl_format__.format('ADDRESS', 'SYMBOL')
for sym,off in sorted(tbl.items(),key=lambda x:x[1]):
- s += __tbl_format__.format(hex(getattr(self,sym)),sym)
+ addr = getattr(self,sym)
+ if(type(addr)==Symtbl.__InnerTable__):
+ s += __tbl_format__.format(hex(addr.off),f'[{sym}]')
+ else:
+ s += __tbl_format__.format(hex(addr),sym)
return s