summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sploit/rev/__init__.py4
-rw-r--r--sploit/rev/gadget.py36
2 files changed, 38 insertions, 2 deletions
diff --git a/sploit/rev/__init__.py b/sploit/rev/__init__.py
index 43cee7b..0d0dc9b 100644
--- a/sploit/rev/__init__.py
+++ b/sploit/rev/__init__.py
@@ -1,6 +1,6 @@
from . import (
+ elf,
+ gadget,
ldd,
r2,
- elf,
)
-
diff --git a/sploit/rev/gadget.py b/sploit/rev/gadget.py
new file mode 100644
index 0000000..a2564c0
--- /dev/null
+++ b/sploit/rev/gadget.py
@@ -0,0 +1,36 @@
+from dataclasses import dataclass, field
+
+@dataclass
+class Gadget:
+ """
+ Basic gadget description object
+
+ offset (int): The location this gadget is found at. What `offset` is
+ relative to depends on context.
+
+ asm (list[re.Match]): A list of assembly instructions matched by the gadget
+ search query.
+ """
+
+ offset: 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)
+ if len(self.asm) > 0:
+ asm = "; ".join([ m.string for m in self.asm ])
+ s += f", '{asm}'"
+ return f"Gadget({s})"