From 5c104e5f9b66614d0e8bf9fc3339f0e97faf627a Mon Sep 17 00:00:00 2001 From: dusoleil Date: Thu, 10 Mar 2022 19:37:36 -0500 Subject: sploit: Add string cast for Symtbl and Memmap Add string cast to mem module types so that they can be printed out in a human readable format. Signed-off-by: dusoleil --- tools/sploit/sploit/mem.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tools/sploit') diff --git a/tools/sploit/sploit/mem.py b/tools/sploit/sploit/mem.py index 1149e99..58c3d3d 100644 --- a/tools/sploit/sploit/mem.py +++ b/tools/sploit/sploit/mem.py @@ -2,6 +2,13 @@ class Symtbl: def __init__(self, **kwargs): self.__dict__ = {**kwargs} + def __str__(self): + tbl_format = '\n{:<20} {:<20}' + s = 'len: ' + str(len(self.__dict__)) + s += tbl_format.format('ADDRESS', 'SYMBOL') + for sym,addr in sorted(self.__dict__.items(),key=lambda x:x[1]): + s += tbl_format.format(hex(addr),sym) + return s class Memmap: def __init__(self, tbl, sym, addr): @@ -17,3 +24,12 @@ class Memmap: def __setattr__(self, k, v): raise TypeError('Memmaps are Read-Only! Modify offsets with Symtbl instead!') + + def __str__(self): + tbl_format = '\n{:<20} {:<20}' + s = 'len: ' + str(len(self.__tbl__.__dict__)+1) + s += tbl_format.format('ADDRESS', 'SYMBOL') + s += tbl_format.format(hex(self.base),'base') + 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 -- cgit v1.2.3