|
|
@ -1,4 +1,5 @@ |
|
|
|
from z3 import Solver, simplify, sat, unknown, FuncInterp, UGE, Optimize |
|
|
|
from z3 import sat, unknown, FuncInterp |
|
|
|
|
|
|
|
from mythril.laser.smt import simplify, UGE, Optimize, symbol_factory |
|
|
|
from mythril.exceptions import UnsatError |
|
|
|
from mythril.exceptions import UnsatError |
|
|
|
from mythril.laser.ethereum.transaction.transaction_models import ( |
|
|
|
from mythril.laser.ethereum.transaction.transaction_models import ( |
|
|
|
ContractCreationTransaction, |
|
|
|
ContractCreationTransaction, |
|
|
@ -8,7 +9,7 @@ import logging |
|
|
|
|
|
|
|
|
|
|
|
def get_model(constraints, minimize=(), maximize=()): |
|
|
|
def get_model(constraints, minimize=(), maximize=()): |
|
|
|
s = Optimize() |
|
|
|
s = Optimize() |
|
|
|
s.set("timeout", 100000) |
|
|
|
s.set_timeout(100000) |
|
|
|
|
|
|
|
|
|
|
|
for constraint in constraints: |
|
|
|
for constraint in constraints: |
|
|
|
if type(constraint) == bool and not constraint: |
|
|
|
if type(constraint) == bool and not constraint: |
|
|
@ -82,7 +83,7 @@ def get_transaction_sequence(global_state, constraints): |
|
|
|
if not isinstance(transaction, ContractCreationTransaction): |
|
|
|
if not isinstance(transaction, ContractCreationTransaction): |
|
|
|
transactions.append(transaction) |
|
|
|
transactions.append(transaction) |
|
|
|
# Constrain calldatasize |
|
|
|
# Constrain calldatasize |
|
|
|
max_calldatasize = 5000 |
|
|
|
max_calldatasize = symbol_factory.BitVecVal(5000, 256) |
|
|
|
tx_constraints.append( |
|
|
|
tx_constraints.append( |
|
|
|
UGE(max_calldatasize, transaction.call_data.calldatasize) |
|
|
|
UGE(max_calldatasize, transaction.call_data.calldatasize) |
|
|
|
) |
|
|
|
) |
|
|
@ -114,10 +115,10 @@ def get_transaction_sequence(global_state, constraints): |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
concrete_transactions[tx_id]["call_value"] = ( |
|
|
|
concrete_transactions[tx_id]["call_value"] = ( |
|
|
|
"0x%x" % model.eval(transaction.call_value, model_completion=True).as_long() |
|
|
|
"0x%x" % model.eval(transaction.call_value.raw, model_completion=True).as_long() |
|
|
|
) |
|
|
|
) |
|
|
|
concrete_transactions[tx_id]["caller"] = "0x" + ( |
|
|
|
concrete_transactions[tx_id]["caller"] = "0x" + ( |
|
|
|
"%x" % model.eval(transaction.caller, model_completion=True).as_long() |
|
|
|
"%x" % model.eval(transaction.caller.raw, model_completion=True).as_long() |
|
|
|
).zfill(40) |
|
|
|
).zfill(40) |
|
|
|
|
|
|
|
|
|
|
|
return concrete_transactions |
|
|
|
return concrete_transactions |
|
|
|