summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2022-07-08 00:49:35 -0400
committerMalfurious <m@lfurio.us>2022-09-12 20:16:16 -0400
commit85320ac3a6f58483c01d52e39ee67241db6c165f (patch)
tree636962ef0559ed3100cae72c83e30ed5b0e40c11
parent51d92be1f5eb0ec188b635366d588f61f5f3bca4 (diff)
downloadlib-des-gnux-85320ac3a6f58483c01d52e39ee67241db6c165f.tar.gz
lib-des-gnux-85320ac3a6f58483c01d52e39ee67241db6c165f.zip
sploit: payload: Promote private methods to "protected" access
Lift restriction (name mangling) to Payload helper functions, as their use will be useful in Payload subclasses. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
-rw-r--r--tools/sploit/sploit/payload.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/tools/sploit/sploit/payload.py b/tools/sploit/sploit/payload.py
index 0e32975..c916514 100644
--- a/tools/sploit/sploit/payload.py
+++ b/tools/sploit/sploit/payload.py
@@ -18,58 +18,58 @@ class Payload:
raise Exception(f'Payload: bad bytes in content: {found}')
return self.payload
- def __name(self, kind, sym):
+ def _name(self, kind, sym):
if sym is not None: return sym
try: ctr = self.ctrs[kind]
except: ctr = 0
self.ctrs[kind] = ctr + 1
return f'{kind}_{ctr}'
- def __append(self, value, sym):
+ def _append(self, value, sym):
setattr(self.sym.map(0), sym, len(self))
self.payload += value
return self
- def __prepend(self, value, sym):
+ def _prepend(self, value, sym):
self.sym.adjust(len(value))
setattr(self.sym.map(0), sym, 0)
self.payload = value + self.payload
return self
def bin(self, *values, sym=None):
- return self.__append(b''.join(values), sym=self.__name('bin', sym))
+ return self._append(b''.join(values), sym=self._name('bin', sym))
def str(self, *values, sym=None):
values = [ v.encode() + b'\x00' for v in values ]
- return self.bin(*values, sym=self.__name('str', sym))
+ return self.bin(*values, sym=self._name('str', sym))
def int(self, *values, sym=None, signed=False):
values = [ itob(v, signed=signed) for v in values ]
- return self.bin(*values, sym=self.__name('int', sym))
+ return self.bin(*values, sym=self._name('int', sym))
def ret(self, *values, sym=None):
- return self.int(*values, sym=self.__name('ret', sym))
+ return self.int(*values, sym=self._name('ret', sym))
def sbp(self, *values, sym=None):
if len(values) == 0:
- return self.rep(self.MAGIC, arch.wordsize, sym=self.__name('sbp', sym))
- return self.int(*values, sym=self.__name('sbp', sym))
+ return self.rep(self.MAGIC, arch.wordsize, sym=self._name('sbp', sym))
+ return self.int(*values, sym=self._name('sbp', sym))
def rep(self, value, size, sym=None):
- return self.bin(self.__rep_helper(value, size), sym=self.__name('rep', sym))
+ return self.bin(self._rep_helper(value, size), sym=self._name('rep', sym))
def pad(self, size, value=None, sym=None):
- return self.bin(self.__pad_helper(size, value), sym=self.__name('pad', sym))
+ return self.bin(self._pad_helper(size, value), sym=self._name('pad', sym))
def pad_front(self, size, value=None, sym=None):
- return self.__prepend(self.__pad_helper(size, value), sym=self.__name('pad', sym))
+ return self._prepend(self._pad_helper(size, value), sym=self._name('pad', sym))
- def __rep_helper(self, value, size, *, explain=''):
+ def _rep_helper(self, value, size, *, explain=''):
if size < 0:
raise Exception(f'Payload: {explain}rep: available space is negative')
if (size := size / len(value)) != int(size):
raise Exception(f'Payload: {explain}rep: element does not divide the space evenly')
return value * int(size)
- def __pad_helper(self, size, value):
- return self.__rep_helper(value or arch.nopcode, size - len(self), explain='pad: ')
+ def _pad_helper(self, size, value):
+ return self._rep_helper(value or arch.nopcode, size - len(self), explain='pad: ')