summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authordusoleil <howcansocksbereal@gmail.com>2022-03-12 18:40:53 -0500
committerdusoleil <howcansocksbereal@gmail.com>2022-03-12 18:40:53 -0500
commitd3f8148b0fd3e55f1839336ff555ef5418cbaf5e (patch)
treed4924dd1967286b271b2144505cbda5cf8595e55 /tools
parentb8b16e8e94e555c3a735079cbe1ba92813c85685 (diff)
downloadlib-des-gnux-d3f8148b0fd3e55f1839336ff555ef5418cbaf5e.tar.gz
lib-des-gnux-d3f8148b0fd3e55f1839336ff555ef5418cbaf5e.zip
sploit: code reuse for mem string methods
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/sploit/sploit/mem.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/tools/sploit/sploit/mem.py b/tools/sploit/sploit/mem.py
index f0b93fd..cf138b3 100644
--- a/tools/sploit/sploit/mem.py
+++ b/tools/sploit/sploit/mem.py
@@ -17,12 +17,7 @@ class Symtbl:
return hi-lo
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
+ return __str__(self,self.__dict__)
class Memmap:
def __init__(self, tbl, sym, addr):
@@ -43,11 +38,18 @@ class Memmap:
return len(self.__tbl__)
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)
+ s = __str__(self,self.__tbl__.__dict__)
+ pos = -1
+ for i in range(3):
+ pos = s.find('\n',pos+1)
+ s = s[:pos] + __tbl_format__.format(hex(self.base),'base') + s[pos:]
return s
+__tbl_format__ = '\n{:<20} {:<20}'
+def __str__(self,tbl):
+ s = 'symbols: ' + str(len(tbl))
+ s += '\nlength: ' + str(len(self))
+ 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)
+ return s