mirror of
https://github.com/trailofbits/manticore.git
synced 2026-10-12 02:23:44 +00:00
* Add black to CI tests I'd rather have blackening be an optional check, but this will work for now * Yep, messed up Travis Again, sorry about the commit spam * Bump accepted line length to 120 Going to auto-format at 100 but will allow 20% overruns * Blacken * Cap line length at 100 rip my undisciplined coding habits * update black on the fly if necessary * Ignore CC errors * Only check modified files * Only python files * Re-blacken post merge * Re-Blacken * Fix deleted files * Explicitly invoke python The +x must not have gotten commited * Forgot to blacken again Hoisted on my own petard * Re-blacken
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
from manticore.ethereum import ManticoreEVM
|
|
|
|
m = ManticoreEVM()
|
|
m.verbosity(3)
|
|
# And now make the contract account to analyze
|
|
with open("coverage.sol") as f:
|
|
source_code = f.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=m.make_symbolic_value(),
|
|
data=m.make_symbolic_buffer(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=m.make_symbolic_value(),
|
|
data=m.make_symbolic_buffer(164),
|
|
)
|
|
|
|
print(f"[+] There are {m.count_terminated_states()} reverted states now")
|
|
print(f"[+] There are {m.count_running_states()} alive states now")
|
|
# for state_id in m.running_state_ids:
|
|
# print(m.report(state_id))
|
|
|
|
print(f"[+] Global coverage: {contract_account.address:x}")
|
|
print(m.global_coverage(contract_account))
|