summaryrefslogtreecommitdiffstats
path: root/sploit/payload/gadhint.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/gadhint.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/gadhint.py')
-rw-r--r--sploit/payload/gadhint.py98
1 files changed, 0 insertions, 98 deletions
diff --git a/sploit/payload/gadhint.py b/sploit/payload/gadhint.py
deleted file mode 100644
index 1bef9f0..0000000
--- a/sploit/payload/gadhint.py
+++ /dev/null
@@ -1,98 +0,0 @@
-import copy
-from dataclasses import dataclass, field
-
-from sploit.rev.gadget import Gadget
-from sploit.types.index_entry import IndexEntry
-
-@dataclass
-class GadHint(IndexEntry):
- """
- User-annotated gadget description object
-
- base (Gadget|int): The gadget being annotated. May be a Gadget object or
- an offset as an int.
-
- pops (list[str]): The registers popped by this gadget, in order of
- occurrence.
-
- movs (dict{str:str}): The register-to-register moves made by this gadget.
- Keys are destination register names, values are source register names. The
- order given is insignificant.
-
- imms (dict{str:int}): The immediate-to-register loads made by this gadget.
- Keys are destination register names, values are immediate values. The order
- given is insignificant.
-
- writes (dict{str:str}): The register-to-memory stores made by this gadget.
- Keys are the destination register names (which hold memory addresses),
- values are source register names (which hold values to-be-stored). The
- order given is insignificant.
-
- requirements (dict{str:int}): The register state that is required before
- this gadget should be executed. Keys are register names, values are the
- required register values.
-
- stack (list[int]): A list of words to append to the stack following this
- gadget. The first element given is nearest to the top of the stack and the
- rest follow in order.
-
- align (bool): If True, this gadget expects the stack to be aligned prior
- to entry.
-
- syscall (bool): If True, this gadget contains a syscall instruction.
-
- spm (int): "Stack pointer move" - The amount the stack pointer is adjusted
- by this gadget. The effect of executing a terminating "return" instruction
- should not be accounted for. A value of zero is taken as "unspecified".
- """
-
- base: int = 0
- pops: list = field(default_factory=list)
- movs: dict = field(default_factory=dict)
- imms: dict = field(default_factory=dict)
- writes: dict = field(default_factory=dict)
- requirements: dict = field(default_factory=dict)
- stack: list = field(default_factory=list)
- align: bool = False
- syscall: bool = False
- spm: int = 0
-
- @property
- def offset(self):
- """Return gadget offset as an integer."""
- return int(self.base)
-
- def with_requirements(self, reqs):
- """Return new object with additional requirements."""
- for k, v in reqs.items():
- if self.requirements.get(k, v) != v:
- raise ValueError(
- f"GadHint: Conflicting gadget requirements: "
- f"{self.requirements}, {reqs}")
-
- new = copy.deepcopy(self)
- new.requirements |= reqs
- return new
-
- def __repr__(self):
- """Return human-readable GadHint."""
- def fmt(name, prop):
- if len(prop) > 0:
- return f", {name}={prop}"
- return ""
-
- s = hex(self.base)
- s = f"Gadget({s})" if isinstance(self.base, Gadget) else s
- s += fmt("pops", self.pops)
- s += fmt("movs", self.movs)
- s += fmt("imms", self.imms)
- s += fmt("writes", self.writes)
- s += fmt("requirements", self.requirements)
- s += fmt("stack", self.stack)
- if self.align:
- s += ", align"
- if self.syscall:
- s += ", syscall"
- if self.spm > 0:
- s += f", spm={self.spm}"
- return f"GadHint({s})"