A more complete example to initialize and explore a smart contract with manticore (#827)

* A more complete example to initialize and explore a smart contract with manticore

* Removed outdated comments
This commit is contained in:
ggrieco-tob 2018-03-22 09:40:51 -03:00 committed by GitHub
parent 9c19014e4b
commit 03af65e55f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

46
examples/evm/complete.py Normal file
View File

@ -0,0 +1,46 @@
from manticore.ethereum import ManticoreEVM
################ Script #######################
m = ManticoreEVM()
#And now make the contract account to analyze
source_code = '''
contract C {
uint n;
function C(uint x) {
n = x;
}
function f(uint x) payable returns (bool) {
if (x == n) {
return true;
}
else{
return false;
}
}
}
'''
user_account = m.create_account(balance=1000)
print "[+] Creating a user account", user_account
contract_account = m.solidity_create_contract(source_code, owner=user_account, args=[42])
print "[+] Creating a contract account", contract_account
print "[+] Source code:"
print source_code
print "[+] Now the symbolic values"
symbolic_data = m.make_symbolic_buffer(320)
symbolic_value = None
m.transaction(caller=user_account,
address=contract_account,
data=symbolic_data,
value=symbolic_value )
print "[+] Resulting balances are:"
for state in m.running_states:
balance = state.platform.get_balance(user_account)
print state.solve_one(balance)
m.finalize()
print "[+] Look for results in %s"% m.workspace