summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordusoleil <howcansocksbereal@gmail.com>2023-03-23 04:07:28 -0400
committerdusoleil <howcansocksbereal@gmail.com>2023-03-24 03:50:55 -0400
commit61971e65dd280c84e4c4e06e86f0c4ba1aed03aa (patch)
tree28294f595fad96874fe9f6a10a660f4dba9f957c
parente313b0eb10278ddc3cfdb42baa100fa8f60aba61 (diff)
downloadsploit-61971e65dd280c84e4c4e06e86f0c4ba1aed03aa.tar.gz
sploit-61971e65dd280c84e4c4e06e86f0c4ba1aed03aa.zip
r2: Don't return duplicate gadgets in gadget search
Signed-off-by: dusoleil <howcansocksbereal@gmail.com> Reviewed-by: Malfurious <m@lfurio.us>
-rw-r--r--sploit/rev/r2.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/sploit/rev/r2.py b/sploit/rev/r2.py
index f00458e..1be731c 100644
--- a/sploit/rev/r2.py
+++ b/sploit/rev/r2.py
@@ -79,6 +79,7 @@ def rop_gadgets(binary, *regexes, cont=False):
ilog(f"Searching {binary} for {'; '.join(regexes)} gadgets with r2...")
gadgets = rop_json(binary)
results = []
+ result_offsets = []
base = get_bin_info(binary)['baddr']
for gadget in gadgets:
@@ -91,6 +92,9 @@ def rop_gadgets(binary, *regexes, cont=False):
regexes_use = (regexes + (".*",) * size) if cont else regexes
offset = opcodes[idx]['offset'] - base
+ if offset in result_offsets:
+ continue
+
matches = []
for regex in regexes_use:
@@ -102,6 +106,7 @@ def rop_gadgets(binary, *regexes, cont=False):
if len(matches) == len(regexes_use):
results.append(Gadget(offset, matches))
+ result_offsets.append(offset)
return results