|
| 1 | +import datetime |
| 2 | + |
1 | 3 | from easyrop.knowndlls import *
|
2 | 4 | from easyrop.binaries.binary import *
|
3 |
| -import datetime |
4 | 5 | from easyrop.args import Args
|
5 | 6 | from easyrop.core import Core
|
6 | 7 |
|
@@ -86,7 +87,6 @@ def regs_combinations(self, ops, gadgets):
|
86 | 87 | if gadget["op"] == op:
|
87 | 88 | regs = set()
|
88 | 89 | for gad in gadget["gadget"]:
|
89 |
| - '''if jmp eax, the is no DST!!!! see core.search_operation and core.has_all_operands''' |
90 | 90 | if gad["dst"] and gad["src"]:
|
91 | 91 | regs.add((gad["dst"], gad["src"]))
|
92 | 92 | elif gad["dst"]:
|
@@ -140,19 +140,29 @@ def clean_nonexists_operations(self, gadgets, ops, regs):
|
140 | 140 | if gadget["op"] == op:
|
141 | 141 | for gad in gadget["gadget"]:
|
142 | 142 | 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: |
145 | 148 | srcs.add(gad["src"])
|
| 149 | + dsts.add(gad["dst"]) |
146 | 150 | elif dst in REGISTERS and src not in REGISTERS:
|
147 | 151 | if gad["src"] in regs[src]:
|
148 | 152 | srcs.add(gad["src"])
|
149 | 153 | elif src in REGISTERS and dst not in REGISTERS:
|
150 | 154 | if gad["dst"] in regs[dst]:
|
151 | 155 | 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}) |
156 | 166 | return regs
|
157 | 167 |
|
158 | 168 | def make_core(self, argv):
|
|
0 commit comments