Skip to content

Commit

Permalink
Ignore gadgets that contain misdissasembled instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
nurmukhametov committed Oct 28, 2019
1 parent 811b66c commit f69842b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ropgadget/gadgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,13 @@ def __gadgetsFinding(self, section, gadgets, arch, mode):
if (section["vaddr"]+ref-(i*gad[C_ALIGN])) % gad[C_ALIGN] == 0:
decodes = md.disasm(section["opcodes"][ref-(i*gad[C_ALIGN]):ref+gad[C_SIZE]], section["vaddr"]+ref)
gadget = ""
g_size = 0
for decode in decodes:
gadget += (decode.mnemonic + " " + decode.op_str + " ; ").replace(" ", " ")
g_size += decode.size
if g_size != i*gad[C_ALIGN] + gad[C_SIZE]:
# We've read less instructions than planned so something went wrong
continue
if len(gadget) > 0:
gadget = gadget[:-3]
off = self.__offset
Expand Down

0 comments on commit f69842b

Please sign in to comment.