diff options
author | Malfurious <m@lfurio.us> | 2023-03-15 17:12:31 -0400 |
---|---|---|
committer | dusoleil <howcansocksbereal@gmail.com> | 2023-03-15 17:49:22 -0400 |
commit | c9f5d7113c6f977fb31fd7699bd2d5a5869954ad (patch) | |
tree | 92234e1d3ec866e5e62d1da0dddebfacf360ba83 | |
parent | 88fb92aa6cfdcc35f9baa9fd9bcc7c1e7ebfc3cb (diff) | |
download | sploit-c9f5d7113c6f977fb31fd7699bd2d5a5869954ad.tar.gz sploit-c9f5d7113c6f977fb31fd7699bd2d5a5869954ad.zip |
rev: Add rop gadget description class
This new class is intended to be used to return data from gadget
searches, and is able to be nested within object Symtbls.
Signed-off-by: Malfurious <m@lfurio.us>
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
-rw-r--r-- | sploit/rev/__init__.py | 4 | ||||
-rw-r--r-- | sploit/rev/gadget.py | 36 |
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})" |