From 61971e65dd280c84e4c4e06e86f0c4ba1aed03aa Mon Sep 17 00:00:00 2001 From: dusoleil Date: Thu, 23 Mar 2023 04:07:28 -0400 Subject: r2: Don't return duplicate gadgets in gadget search Signed-off-by: dusoleil Reviewed-by: Malfurious --- sploit/rev/r2.py | 5 +++++ 1 file changed, 5 insertions(+) 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 -- cgit v1.2.3