Update README

pull/2/head
Bernhard Mueller 7 years ago
parent 4ca1310151
commit b3981ba782
  1. 38
      README.md
  2. 8
      contractstorage.py
  3. 14
      mythril

@ -2,6 +2,10 @@
Mythril is a bug hunting tool and framework for the Ethereum blockchain.
## Be responsible!
## Installation and setup
Install from Pypi:
@ -26,10 +30,10 @@ $ geth --rpc --rpcapi eth,admin,debug --syncmode fast
### Database initialization
Mythril builds its own contract database to enable quick search for opcode sequences, function calls, et cetera. The initial sync is done over RPC. Unfortunately, this process is slow - however, you don't need to sync the whole blockchain to start working. If you abort the syncing process with `ctrl+c`, it will auto-resume the next time you run the `--init-db` command.
Mythril builds its own contract database using RPC sync. Unfortunately, this process is slow - however, you don't need to sync the whole blockchain to start working. If you abort the syncing process with `ctrl+c`, it will auto-resume the next time you run the `--init-db` command.
```bash
$ ./mythril --init-db
$ mythril --init-db
Starting synchronization from latest block: 4323706
Processing block 4323000, 3 individual contracts in database
(...)
@ -39,9 +43,35 @@ The default behavior is to only sync contracts with a non-zero balance. You can
## Command line usage
-- TODO --
The `mythril` command line tool allows you to easily access most of Mythril's functionality.
### Searching the database
The search feature allows you to find contract instances that contain specific function calls and opcode sequences. It supports simple boolean expressions, such as:
```bash
$ mythril --search "func[changeMultisig(address)]"
$ mythril --search "code[PUSH1 0x50,POP]"
$ mythril --search "func[changeMultisig(address)] and code[PUSH1 0x50,POP]"
```
### Tracing code in the EVM
```
$ ./mythril -d -a "0x3665f2bf19ee5e207645f3e635bf0f4961d661c0"
PUSH1 0x60
PUSH1 0x40
MSTORE
CALLDATASIZE
ISZERO
PUSH2 0x00ac
JUMPI
(...)
```
I'm currently rewriting the whole thing and the docs need to be updated.
## Custom scripts
-- TODO --
## Credit

@ -16,7 +16,7 @@ class ContractStorage(persistent.Persistent):
self.instance_lists= BTree()
self.last_block = 0
def initialize(self, rpchost, rpcport):
def initialize(self, rpchost, rpcport, sync_all):
eth = EthJsonRpc(rpchost, rpcport)
@ -46,8 +46,8 @@ class ContractStorage(persistent.Persistent):
contract_code = eth.eth_getCode(contract_address)
contract_balance = eth.eth_getBalance(contract_address)
if not contract_balance:
# skip contracts with zero balance.
if not contract_balance or sync_all:
# skip contracts with zero balance (disable with --sync-all)
continue
code = ETHCode(contract_code)
@ -94,4 +94,4 @@ class ContractStorage(persistent.Persistent):
m = self.instance_lists[contract_hash]
callback_func(self.contracts[k].code, m.addresses)
callback_func(contract_hash.hex(), self.contracts[k].code, m.addresses, m.balances)

@ -15,9 +15,12 @@ from ZODB import FileStorage
import os
def searchCallback(code, addresses):
print("MATCHED CONTRACT DEPLOYED AT: ")
print("\n".join(addresses))
def searchCallback(code_hash, code, addresses, balances):
print("Matched contract with code hash " + code_hash )
for i in range(0, len(addresses)):
print("Address: " + addresses[i] + ", balance: " + str(balances[i]))
def exitWithError(message):
print(message)
@ -35,6 +38,7 @@ parser.add_argument('--data', help='message call input data for tracing')
parser.add_argument('--search', help='search the contract database')
parser.add_argument('--hash', help='calculate function signature hash', metavar='SIGNATURE')
parser.add_argument('--init-db', action='store_true', help='Initialize the contract database')
parser.add_argument('--sync-all', action='store_true', help='Also sync contracts with zero balance')
parser.add_argument('--rpchost', default='127.0.0.1', help='RPC host')
parser.add_argument('--rpcport', type=int, default=8545, help='RPC port')
@ -67,8 +71,6 @@ if (args.disassemble):
elif (args.address):
try:
# encoded_bytecode = storage.get_contract_code_by_address(args.id)
eth = EthJsonRpc(args.rpchost, args.rpcport)
encoded_bytecode = eth.eth_getCode(args.address)
@ -123,7 +125,7 @@ elif (args.search):
contract_storage.search(args.search, searchCallback)
elif (args.init_db):
contract_storage.initialize(args.rpchost, args.rpcport)
contract_storage.initialize(args.rpchost, args.rpcport, args.sync_all)
elif (args.hash):
print(utils.sha3(args.hash)[:4].hex())

Loading…
Cancel
Save