summaryrefslogtreecommitdiffstats
path: root/sploit/rev/gadget.py
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2024-02-01 04:45:26 -0500
committerMalfurious <m@lfurio.us>2025-01-01 07:08:49 -0500
commitf6941e9a9cd75be539714d361a6f4ceb88450515 (patch)
tree068b8951281f6b5b1cda65a1deafab5ef3fae945 /sploit/rev/gadget.py
parent3768139ffba6a3faaffe5229b1e7a8e348004399 (diff)
downloadnsploit-f6941e9a9cd75be539714d361a6f4ceb88450515.tar.gz
nsploit-f6941e9a9cd75be539714d361a6f4ceb88450515.zip
Update ROP gadget types to extend IndexEntry
This leverages some code reuse and helps these types play nicely with the new Symtbl updates. Signed-off-by: Malfurious <m@lfurio.us>
Diffstat (limited to '')
-rw-r--r--sploit/rev/gadget.py23
1 files changed, 6 insertions, 17 deletions
diff --git a/sploit/rev/gadget.py b/sploit/rev/gadget.py
index a2564c0..cc69723 100644
--- a/sploit/rev/gadget.py
+++ b/sploit/rev/gadget.py
@@ -1,35 +1,24 @@
from dataclasses import dataclass, field
+from sploit.types.index_entry import IndexEntry
@dataclass
-class Gadget:
+class Gadget(IndexEntry):
"""
Basic gadget description object
- offset (int): The location this gadget is found at. What `offset` is
- relative to depends on context.
+ base (int): The location this gadget is found at. What `base` is relative
+ to depends on context.
asm (list[re.Match]): A list of assembly instructions matched by the gadget
search query.
"""
- offset: int = 0
+ base: int = 0
asm: list = field(default_factory=list)
- def __index__(self):
- """Convert object to integer using offset value."""
- return self.offset
-
- def __add__(self, x):
- """Return new object with adjusted offset."""
- return Gadget(self.offset + x, self.asm)
-
- def __sub__(self, x):
- """Return new object with adjusted offset."""
- return self + (-x)
-
def __repr__(self):
"""Return human-readable Gadget."""
- s = hex(self.offset)
+ s = hex(self.base)
if len(self.asm) > 0:
asm = "; ".join([ m.string for m in self.asm ])
s += f", '{asm}'"