Skip to content

Commit 937d7fb

Browse files
committed
Landing rapid7#1835 - Fix a backwards disasm bug which stomps on the depth opt
2 parents 90117c3 + df2140e commit 937d7fb

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/rex/ropbuilder/rop.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,16 @@ def color_pattern(gadget, disasm, addrs, p)
195195
end
196196

197197
def process_gadgets(rets, num)
198-
ret = {}
198+
ret = {}
199199
gadgets = []
200-
tmp = []
200+
tmp = []
201201
rets.each do |ea|
202202
insn = @disassembler.disassemble_instruction(ea)
203203
next if not insn
204204

205205
xtra = insn.bin_length
206206

207-
1.upto(num) do |x|
207+
num.downto(0) do |x|
208208
addr = ea - x
209209

210210
# get the disassembled instruction at this address
@@ -234,6 +234,7 @@ def process_gadgets(rets, num)
234234
else
235235
next
236236
end
237+
237238
# otherwise, we create a new tailchunk and add it to the list
238239
ret = {:file => @file, :address => ("0x%08x" % (ea - x)), :raw => buf, :disasm => dasm}
239240
gadgets << ret

0 commit comments

Comments
 (0)