Skip to content
This repository was archived by the owner on Feb 1, 2025. It is now read-only.

Commit a196011

Browse files
committed
Bug fixed when searching for special kind of register combinations
1 parent e528a8a commit a196011

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

easyrop/rop_generator.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import datetime
2+
13
from easyrop.knowndlls import *
24
from easyrop.binaries.binary import *
3-
import datetime
45
from easyrop.args import Args
56
from easyrop.core import Core
67

@@ -86,7 +87,6 @@ def regs_combinations(self, ops, gadgets):
8687
if gadget["op"] == op:
8788
regs = set()
8889
for gad in gadget["gadget"]:
89-
'''if jmp eax, the is no DST!!!! see core.search_operation and core.has_all_operands'''
9090
if gad["dst"] and gad["src"]:
9191
regs.add((gad["dst"], gad["src"]))
9292
elif gad["dst"]:
@@ -140,19 +140,29 @@ def clean_nonexists_operations(self, gadgets, ops, regs):
140140
if gadget["op"] == op:
141141
for gad in gadget["gadget"]:
142142
if dst not in REGISTERS and src not in REGISTERS:
143-
if gad["dst"] in regs[dst] and gad["src"] in regs[src]:
144-
dsts.add(gad["dst"])
143+
try:
144+
if gad["dst"] in regs[dst] and gad["src"] in regs[src]:
145+
dsts.add(gad["dst"])
146+
srcs.add(gad["src"])
147+
except KeyError:
145148
srcs.add(gad["src"])
149+
dsts.add(gad["dst"])
146150
elif dst in REGISTERS and src not in REGISTERS:
147151
if gad["src"] in regs[src]:
148152
srcs.add(gad["src"])
149153
elif src in REGISTERS and dst not in REGISTERS:
150154
if gad["dst"] in regs[dst]:
151155
dsts.add(gad["dst"])
152-
if dst not in REGISTERS:
153-
regs[dst] = list(dsts.intersection(regs[dst]))
154-
if src not in REGISTERS:
155-
regs[src] = list(srcs.intersection(regs[src]))
156+
try:
157+
if dst not in REGISTERS:
158+
regs[dst] = list(dsts.intersection(regs[dst]))
159+
except KeyError:
160+
regs.update({dst: dsts})
161+
try:
162+
if src not in REGISTERS:
163+
regs[src] = list(srcs.intersection(regs[src]))
164+
except KeyError:
165+
regs.update({src: srcs})
156166
return regs
157167

158168
def make_core(self, argv):

0 commit comments

Comments
 (0)