summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2022-07-07 23:56:25 -0400
committerMalfurious <m@lfurio.us>2022-09-12 20:15:29 -0400
commite2e19ae710abdb77e232e5e3eb2aec503cbaacad (patch)
tree46ddb7728a076d40fb31c8f2e3a208b1145ff10c
parent33452816a966897bf240a13a41ce5d99ed242ef9 (diff)
downloadsploit-e2e19ae710abdb77e232e5e3eb2aec503cbaacad.tar.gz
sploit-e2e19ae710abdb77e232e5e3eb2aec503cbaacad.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>
-rw-r--r--sploit/payload.py19
1 files changed, 8 insertions, 11 deletions
diff --git a/sploit/payload.py b/sploit/payload.py
index 43f58c6..0bbf463 100644
--- a/sploit/payload.py
+++ b/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):