diff options
-rw-r--r-- | tools/sploit/sploit/payload.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/tools/sploit/sploit/payload.py b/tools/sploit/sploit/payload.py index 0bbf463..0e32975 100644 --- a/tools/sploit/sploit/payload.py +++ b/tools/sploit/sploit/payload.py @@ -18,7 +18,8 @@ class Payload: raise Exception(f'Payload: bad bytes in content: {found}') return self.payload - def __name(self, kind): + 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 @@ -36,32 +37,32 @@ class Payload: return self def bin(self, *values, sym=None): - return self.__append(b''.join(values), sym or self.__name('bin')) + 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=(sym or self.__name('str'))) + 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=(sym or self.__name('int'))) + return self.bin(*values, sym=self.__name('int', sym)) def ret(self, *values, sym=None): - return self.int(*values, sym=(sym or self.__name('ret'))) + 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 or self.__name('sbp')) - return self.int(*values, sym=(sym or self.__name('sbp'))) + 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=(sym or self.__name('rep'))) + 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=(sym or self.__name('pad'))) + 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 or self.__name('pad')) + return self.__prepend(self.__pad_helper(size, value), sym=self.__name('pad', sym)) def __rep_helper(self, value, size, *, explain=''): if size < 0: |