summaryrefslogtreecommitdiffstats
path: root/sploit/rev/elf.py
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2023-03-18 21:21:44 -0400
committerdusoleil <howcansocksbereal@gmail.com>2023-03-19 04:19:21 -0400
commit31ef0e9a7a67ba3c361e72d279ae84b9285fb470 (patch)
tree6e78769b81f1c2e98ae68e02415103e56d903e66 /sploit/rev/elf.py
parent205f828bd669772ee319595fa6792953f0abd327 (diff)
downloadnsploit-31ef0e9a7a67ba3c361e72d279ae84b9285fb470.tar.gz
nsploit-31ef0e9a7a67ba3c361e72d279ae84b9285fb470.zip
rev: Normalize the reported offset of found gadgets
ROP gadgets returned through search from the r2 API will now always contain a file-relative offset, even if they come from a non-pic binary using a fixed baddr. However, gadgets returned through the ELF API will be mapped according to the ELF's Symtbl. This ensures the correct offset is returned following a library leak, and allows the user to always safely insert an ELF-returned gadget into that ELF's Symtbl without issue. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
Diffstat (limited to '')
-rw-r--r--sploit/rev/elf.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/sploit/rev/elf.py b/sploit/rev/elf.py
index 990cfde..28cd08d 100644
--- a/sploit/rev/elf.py
+++ b/sploit/rev/elf.py
@@ -198,8 +198,8 @@ class ELF:
cont (bool): If true, this function will return all of the assembly past
the found gadget up to the next return point.
"""
- return r2.rop_gadgets(self.path, *regexes, cont=cont)
+ return [ self.sym[g] for g in r2.rop_gadgets(self.path, *regexes, cont=cont) ]
def gadget(self, *regexes):
"""Returns the first gadget found that matches the given regex list."""
- return r2.rop_gadget(self.path, *regexes)
+ return self.sym[r2.rop_gadget(self.path, *regexes)]