Files
manticore/examples/evm/coverage.py
feliam db80685758 Better EVM workspace output (#641)
* Fixes symbolic reentrancy example

* Fix coverage Issue# 527

* Remove  debug unused code

* New solidity biased API and reporting

* Updated examples to new api WIP

* simple_mapping FIXED. new api

* Simple transaction example added. msg.value can be symbolic now

* Reentrancy symbolic now updated to new API + bugfixes

* Doc and cleanups in evm assembler

* EVMInstruction -> Instruction

* cleanups

* typo

* deepcopy in Constant

* Better EVM-asm api and doc

* some docs

* More evm asm docs

* Initial seth in place refactor

* Fix import *

* typo

* newline between text and param

* similar phrasing to all the other flags

* typo

* typo

* fix function name in comment

* sphinx newline

* documentation fixes

* documentation fixes

* refactors

* EVMAssembler to EVMAsm

* Fix evm @hook signature

* EVMAsm

* WIP seth doc

* WIP move seth

* seth moved to manticore module

* Fixed DUP and typo

* Slightly better evm reporting

* review

* review

* Removed unfinished refactor

* Various refactors. Auxiliar for calculating % coverage

* Change report in examples

* Detailed transactions and reporting accessible to the user2

* Fix on Expression Array

* Some documentation

* Get full ABI from solc compiler

* evm/examples -> bugfixes

* Clarify try/except blocks

* Code review

* Code review

* Code review

* Code review

* Code review

* Initial detector plugin. integer overflow and unitialized mem

* Better metadata handling and new events for detectors

* detectors wip

* Better name for internal findings context

* Explicit detector register

* review

* New workspace output

* Fix examples

* wrog merge fix

* Fix examples/new api

* Fix examples/new api/output

* More output

* More doc

* Broken examples deleted

* Debug code removed

* Wrong docstring

* Update evm __main__

* Update evm __main__

* Update evm __main__

* Update evm __main__

* Update evm __main__

* Fix TODO
2017-12-15 02:17:41 -03:00

39 lines
1.1 KiB
Python

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),
)
print "[+] There are %d reverted states now"% len(m.final_state_ids)
print "[+] There are %d alive states now"% len(m.running_state_ids)
for state_id in m.running_state_ids:
print m.report(state_id)
print "[+] Global coverage: %x"% contract_account
print m.coverage(contract_account)