From b8b16e8e94e555c3a735079cbe1ba92813c85685 Mon Sep 17 00:00:00 2001 From: dusoleil Date: Sat, 12 Mar 2022 18:39:53 -0500 Subject: sploit: add len func to mem len() will calculate the length of the symtbl in bytes rather than the number of symbols Signed-off-by: dusoleil --- tools/sploit/sploit/mem.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/sploit/sploit/mem.py b/tools/sploit/sploit/mem.py index 0392fa9..f0b93fd 100644 --- a/tools/sploit/sploit/mem.py +++ b/tools/sploit/sploit/mem.py @@ -8,6 +8,14 @@ class Symtbl: def rebase(self, sym): self.adjust(-sym) + def __len__(self): + vals = self.__dict__.values() + if len(vals)<1: + return 0 + hi = max(max(vals),0) + lo = min(min(vals),0) + return hi-lo + def __str__(self): tbl_format = '\n{:<20} {:<20}' s = 'len: ' + str(len(self.__dict__)) @@ -31,6 +39,9 @@ class Memmap: def __setattr__(self, k, v): raise TypeError('Memmaps are Read-Only! Modify offsets with Symtbl instead!') + def __len__(self): + return len(self.__tbl__) + def __str__(self): tbl_format = '\n{:<20} {:<20}' s = 'len: ' + str(len(self.__tbl__.__dict__)+1) -- cgit v1.2.3