Example #1
0
source_code = '''
pragma solidity ^0.4.13;
contract NoDistpatcher {
    event Log(string);

    function() payable {
        if (msg.data[0] == 'A') {
            Log("Got an A");
        }
        else{
            Log("Got something else");
        }
    } 
}
'''
init_bytecode = m.compile(source_code)

user_account = m.create_account(balance=1000)
print "[+] Creating a user account", user_account

print "[+] Init bytecode:", init_bytecode.encode('hex')
print "[+] EVM init assembler:"
for instr in evm.EVMAsm.disassemble_all(init_bytecode[:-44]):
    print hex(instr.offset), instr

contract_account = m.create_contract(owner=user_account, init=init_bytecode)
print "[+] Creating a contract account", contract_account

print "[+] Now the symbolic values"
symbolic_data = m.make_symbolic_buffer(320)
symbolic_value = None
Example #2
0
#!/usr/bin/python

from manticore.ethereum import ManticoreEVM, ABI
from manticore.core.smtlib import Operators, solver

###### Initialization ######
m = ManticoreEVM()

with open('test4.sol') as f:
    source_code = f.read()

bytecode = m.compile(source_code,
                     # contract_name="GuessTheNumberChallenge"
                     )

# Add hacker's address
hacker_account = m.create_account(balance=1000 * 10**18, address=42)
# bytecode = bytecode + bytes.fromhex("000000000000000000000000000000000000002a")

# Create one user account
# And deploy the contract
user_account = m.create_account(balance=1000 * 10**18)

contract_account = m.create_contract(init=bytecode,
                                     owner=user_account,
                                     balance=10**18)

###### Exploration ######

symbolic_data = m.make_symbolic_buffer(36)
m.transaction(caller=hacker_account,