from manticore.seth import ManticoreEVM m = ManticoreEVM() m.verbosity(3) #And now make the contract account to analyze source_code = file('coverage.sol').read() user_account = m.create_account(balance=1000) bytecode = m.compile(source_code) #Initialize contract contract_account = m.create_contract(owner=user_account, balance=0, init=bytecode) m.transaction( caller=user_account, address=contract_account, value=None, data=m.SByte(164), ) #Up to here we get only ~30% coverage. #We need 2 transactions to fully explore the contract m.transaction( caller=user_account, address=contract_account, value=None, data=m.SByte(164), )
from manticore.seth import ManticoreEVM ################ Script ####################### seth = ManticoreEVM() seth.verbosity(0) #The contract account to analyze contract_source_code = ''' pragma solidity ^0.4.15; contract Reentrance { mapping (address => uint) userBalance; function getBalance(address u) constant returns(uint){ return userBalance[u]; } function addToBalance() payable{ userBalance[msg.sender] += msg.value; } function withdrawBalance(){ // send userBalance[msg.sender] ethers to msg.sender // if mgs.sender is a contract, it will call its fallback function if( ! (msg.sender.call.value(userBalance[msg.sender])() ) ){ revert(); } userBalance[msg.sender] = 0; } } '''
from manticore.seth import ManticoreEVM ################ Script ####################### m = ManticoreEVM() m.verbosity(2) #And now make the contract account to analyze # cat | solc --bin source_code = ''' pragma solidity ^0.4.13; contract Test { event Log(string); mapping(address => uint) private balances; function Test() {} function target1() public {} function target2() internal {} function target3() private {} function() {} } ''' #Initialize accounts user_account = m.create_account(balance=1000) contract_account = m.solidity_create_contract(source_code, owner=user_account) symbolic_data = m.make_symbolic_buffer(4) symbolic_value = None m.transaction(caller=user_account, address=contract_account, value=symbolic_value,
from manticore.seth import ManticoreEVM ################ Script ####################### seth = ManticoreEVM() seth.verbosity(2) #And now make the contract account to analyze # cat | solc --bin source_code = ''' pragma solidity ^0.4.13; contract Test { event Log(string); mapping(address => uint) private balances; function Test(){ balances[0x1111111111111111111111111111111111111111] = 10; balances[0x2222222222222222222222222222222222222222] = 20; balances[0x3333333333333333333333333333333333333333] = 30; balances[0x4444444444444444444444444444444444444444] = 40; balances[0x5555555555555555555555555555555555555555] = 50; } function target(address key) returns (bool){ if (balances[key] > 20) Log("Balance greater than 20"); else Log("Balance less or equal than 20"); } } '''
from manticore.seth import ManticoreEVM, ABI ################ Script ####################### m = ManticoreEVM() m.verbosity(0) #The contract account to analyze contract_source_code = ''' pragma solidity ^0.4.15; contract Reentrance { mapping (address => uint) userBalance; function getBalance(address u) constant returns(uint){ return userBalance[u]; } function addToBalance() payable{ userBalance[msg.sender] += msg.value; } function withdrawBalance(){ // send userBalance[msg.sender] ethers to msg.sender // if mgs.sender is a contract, it will call its fallback function if( ! (msg.sender.call.value(userBalance[msg.sender])() ) ){ revert(); } userBalance[msg.sender] = 0; } } //Function signatures: //c0e317fb: addToBalance()
from manticore.seth import ManticoreEVM seth = ManticoreEVM() seth.verbosity(3) #And now make the contract account to analyze source_code = file('coverage.sol').read() user_account = seth.create_account(balance=1000) bytecode = seth.compile(source_code) #Initialize contract contract_account = seth.create_contract(owner=user_account, balance=0, init=bytecode) seth.transaction( caller=user_account, address=contract_account, value=None, data=seth.SByte(164), ) #Up to here we get only ~30% coverage. #We need 2 transactions to fully explore the contract seth.transaction( caller=user_account, address=contract_account, value=None, data=seth.SByte(164), )