summaryrefslogtreecommitdiffstats
path: root/sploit/payload/payload_entry.py
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2025-01-02 19:17:34 -0500
committerMalfurious <m@lfurio.us>2025-01-04 23:54:51 -0500
commit0f00627964a4b2e515108401fa2cfe94600ad648 (patch)
tree56da2ccaf393a1124220cc187a7225a4efcfbcba /sploit/payload/payload_entry.py
parent640726aa11369d328c1cdfe00b4344b6a925729c (diff)
downloadnsploit-0f00627964a4b2e515108401fa2cfe94600ad648.tar.gz
nsploit-0f00627964a4b2e515108401fa2cfe94600ad648.zip
Rename sploit package to nsploit
Rename all affected files, references to file paths, and module imports within the code. Since this line of development represents a fork from the original sploit, a name change is seen as necessary to distinguish the projects, as well as allow them to be installed side by side. What does the "n" mean? Great question! You can think of it as meaning "new sploit" if you want, though that's not quite intended. The name is simply distinct and easy to pronounce. I had originally settled on "msploit" (something along the lines of "Malf's sploit"), but this name is too close to "metasploit" for me - and N is right next to it on the keyboard. Signed-off-by: Malfurious <m@lfurio.us>
Diffstat (limited to 'sploit/payload/payload_entry.py')
-rw-r--r--sploit/payload/payload_entry.py113
1 files changed, 0 insertions, 113 deletions
diff --git a/sploit/payload/payload_entry.py b/sploit/payload/payload_entry.py
deleted file mode 100644
index 2f8dbdd..0000000
--- a/sploit/payload/payload_entry.py
+++ /dev/null
@@ -1,113 +0,0 @@
-from sploit.arch import arch, itob
-from sploit.types.index_entry import IndexEntry
-
-_PLACEHOLDER_MAGIC = b"\xef"
-
-class PayloadEntry(IndexEntry):
- """Base class for dynamic Payload entries"""
-
- def __repr__(self):
- """Return human-readable entry description."""
- return f"{self.__class__.__name__}{self.__dict__}"
-
- def payload_insert(self, payload):
- """
- Called on insert into a payload object.
-
- Override this method to perform any initialization which requires a
- reference to the payload object. self.base is set to the insertion
- location.
- """
- pass
-
- def payload_len(self, payload):
- """
- Called to compute size of this entry.
-
- Implement this method to calculate the length of this dynamic payload
- entry. self.base is set to the current entry address or offset.
- """
- raise NotImplementedError
-
- def payload_bytes(self, payload):
- """
- Called to generate bytes for this entry.
-
- Implement this method to generate the binary output for this dynamic
- payload entry. self.base is set to the current entry address or offset.
- """
- raise NotImplementedError
-
-# Concrete payload entry definitions
-
-class pointer(PayloadEntry):
- """Generate an integer which tracks the address of another payload field."""
-
- def __init__(self, target=None, math=None):
- self.target = target
- self.math = math
-
- def payload_len(self, payload):
- return arch.wordsize
-
- def payload_bytes(self, payload):
- if self.target is None:
- addr = self.base
- else:
- addr = payload[self.target]
- if callable(self.math):
- addr = self.math(addr)
- return itob(addr)
-
-class padlen(PayloadEntry):
- """Generate padding to reach a target payload length."""
-
- def __init__(self, size, data=None):
- self.size = size
- self.data = data
-
- def payload_len(self, payload):
- return self.size - (self.base - payload.base)
-
- def payload_bytes(self, payload):
- size = self.payload_len(payload)
- data = self.data or arch.nopcode
- if size < 0:
- raise ValueError("padding: Available space is negative")
- if (size := size / len(data)) != int(size):
- raise ValueError("padding: Element does not divide the space evenly")
- return data * int(size)
-
-class padabs(padlen):
- """Generate padding to reach a target absolute address."""
-
- def payload_len(self, payload):
- return self.size - self.base
-
-class padrel(padlen):
- """Generate a fixed length of padding (aka: length relative to self)."""
-
- def payload_len(self, payload):
- return self.size
-
-class padalign(padlen):
- """Generate padding to reach next aligned address."""
-
- def __init__(self, size=None, data=None, reference=0):
- self.size = size
- self.data = data
- self.reference = reference
-
- def payload_len(self, payload):
- size = self.size or arch.alignment
- return (self.reference - self.base) % size
-
-class placeholder(padlen):
- """Generate fixed length of magic bytes, one word length by default."""
-
- def __init__(self, size=None):
- self.size = size
- self.data = _PLACEHOLDER_MAGIC
-
- def payload_len(self, payload):
- return self.size or arch.wordsize