|
|
|
@ -6,6 +6,7 @@ from mythril.ether import util |
|
|
|
|
from mythril.ether.ethcontract import ETHContract |
|
|
|
|
from mythril.analysis.security import fire_lasers |
|
|
|
|
from mythril.analysis.symbolic import StateSpace |
|
|
|
|
from mythril.analysis.report import Report |
|
|
|
|
from laser.ethereum import helper |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -37,11 +38,15 @@ def analyze_truffle_project(): |
|
|
|
|
|
|
|
|
|
ethcontract= ETHContract(bytecode, name=name, address = util.get_indexed_address(0)) |
|
|
|
|
|
|
|
|
|
contracts = [ethcontract] |
|
|
|
|
states = StateSpace([ethcontract], max_depth = 10) |
|
|
|
|
issues = fire_lasers(states) |
|
|
|
|
|
|
|
|
|
states = StateSpace(contracts, max_depth = 10) |
|
|
|
|
report = fire_lasers(states) |
|
|
|
|
if not len(issues): |
|
|
|
|
print("Analysis result for " + name + ": No issues found.") |
|
|
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
|
|
report = Report() |
|
|
|
|
# augment with source code |
|
|
|
|
|
|
|
|
|
disassembly = ethcontract.get_disassembly() |
|
|
|
@ -69,7 +74,7 @@ def analyze_truffle_project(): |
|
|
|
|
|
|
|
|
|
i += 1 |
|
|
|
|
|
|
|
|
|
for key, issue in report.issues.items(): |
|
|
|
|
for issue in issues: |
|
|
|
|
|
|
|
|
|
index = helper.get_instruction_index(disassembly.instruction_list, issue.pc) |
|
|
|
|
|
|
|
|
@ -78,10 +83,6 @@ def analyze_truffle_project(): |
|
|
|
|
issue.code_length = mappings[index][1] |
|
|
|
|
issue.code = source[mappings[index][0]: mappings[index][0] + mappings[index][1]] |
|
|
|
|
|
|
|
|
|
report.append_issue(issue) |
|
|
|
|
|
|
|
|
|
if len(report.issues): |
|
|
|
|
print("Analysis result for " + name + ":\n" + report.as_text()) |
|
|
|
|
else: |
|
|
|
|
print("Analysis result for " + name + ": No issues found.") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|