diff options
author | Malfurious <m@lfurio.us> | 2022-07-07 23:56:25 -0400 |
---|---|---|
committer | Malfurious <m@lfurio.us> | 2022-09-12 20:15:29 -0400 |
commit | 9759d731da4787ea0679ebe9700d72397ec788b2 (patch) | |
tree | 259b7e24a3f33d818193a680aa233c96b4e48df3 /tools | |
parent | d673d458922b640ca3f384288356a33a308cdc9b (diff) | |
download | lib-des-gnux-9759d731da4787ea0679ebe9700d72397ec788b2.tar.gz lib-des-gnux-9759d731da4787ea0679ebe9700d72397ec788b2.zip |
sploit: payload: Class no longer extends Symtbl
Given the current design of Symtbl, creating subclasses of it gets more
tedious the further one goes down a potential class hierarchy. As I am
planning to introduce new features in the future that explicitly extend
Payload, make this change now to minimize the impact.
Additionally, switching Payload's relationship with Symtbl from "is-a"
to "has-a" makes it more consistent with rev.ELF, the other major user
of Symtbl. (And in both cases, the member is named 'sym')
Signed-off-by: Malfurious <m@lfurio.us>
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/sploit/sploit/payload.py | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/tools/sploit/sploit/payload.py b/tools/sploit/sploit/payload.py index 43f58c6..0bbf463 100644 --- a/tools/sploit/sploit/payload.py +++ b/tools/sploit/sploit/payload.py @@ -1,41 +1,38 @@ from sploit.arch import arch, itob from sploit.mem import Symtbl -class Payload(Symtbl): +class Payload: MAGIC = b'\xef' def __init__(self, **kwargs): - super().__init__(**kwargs) - self = self._namesp self.payload = b'' + self.sym = Symtbl(**kwargs) self.ctrs = {} def __len__(self): - return len(self._namesp.payload) + return len(self.payload) def __call__(self, badbytes=b''): - self = self._namesp found = [ hex(x) for x in set(self.payload).intersection(badbytes) ] if len(found) > 0: raise Exception(f'Payload: bad bytes in content: {found}') return self.payload def __name(self, kind): - self = self._namesp try: ctr = self.ctrs[kind] except: ctr = 0 self.ctrs[kind] = ctr + 1 return f'{kind}_{ctr}' def __append(self, value, sym): - setattr(self, sym, len(self)) - self._namesp.payload += value + setattr(self.sym.map(0), sym, len(self)) + self.payload += value return self def __prepend(self, value, sym): - self.adjust(len(value)) - setattr(self, sym, 0) - self._namesp.payload = value + self._namesp.payload + 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): |