From a1a1c6151dc23a32d9f19da8cd721ed82495b86e Mon Sep 17 00:00:00 2001 From: dusoleil Date: Thu, 10 Mar 2022 19:52:50 -0500 Subject: Add adjust and rebase functions to mem module Add the ability to shift all Symtbl offsets by a fixed amount with adjust(). Add the ability to shift all Symtbl offsets so that a designated symbol is now at offset 0 and all other symbols maintain their relative offsets to that symbol with rebase(). Signed-off-by: dusoleil --- tools/sploit/sploit/mem.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/sploit/sploit/mem.py b/tools/sploit/sploit/mem.py index 58c3d3d..e257c03 100644 --- a/tools/sploit/sploit/mem.py +++ b/tools/sploit/sploit/mem.py @@ -33,3 +33,11 @@ class Memmap: for sym,addr in sorted(self.__tbl__.__dict__.items(),key=lambda x:x[1]): s += tbl_format.format(hex(addr+self.base),sym) return s + +def adjust(tbl, off): + tbl.__dict__ = {k:v+off for k,v in tbl.__dict__.items()} + +def rebase(tbl, sym): + off = -getattr(tbl, sym) + adjust(tbl, off) + -- cgit v1.2.3