Update README

pull/2/head
Bernhard Mueller 7 years ago
parent 3e0630af14
commit ede936d811
  1. 14
      README.md
  2. 10
      mythril.py

@ -49,6 +49,18 @@ $ ./mythril.py -a code.easm
The virtual machine language is described in the [Ethereum Yellowpaper](http://gavwood.com/paper.pdf). The virtual machine language is described in the [Ethereum Yellowpaper](http://gavwood.com/paper.pdf).
### Tracing EVM execution
You can run a piece of bytecode in the [PyEthereum](https://github.com/ethereum/pyethereum) VM and trace its execution using the `-t` flag. This will output the instructions executed as well as the state of the stack for every execution step.
```bash
$ ./mythril.py -t -c "0x606060405050"
vm address=b'\x01#Eg\x89\xab\xcd\xef\x01#Eg\x89\xab\xcd\xef\x01#Eg' gas=b'1000000' storage={'storage': {}, 'balance': '0', 'nonce': '0', 'code': '0x'} steps=0 depth=0 pushvalue=96 stack=[] pc=b'0' op=PUSH1 inst=96
vm gas=b'999997' steps=1 depth=0 pushvalue=64 stack=[b'96'] pc=b'2' op=PUSH1 inst=96
vm gas=b'999994' steps=2 depth=0 stack=[b'96', b'64'] pc=b'4' op=POP inst=80
vm gas=b'999992' steps=3 depth=0 stack=[b'96'] pc=b'5' op=POP inst=80
```
### Disassembling a contract from the Ethereum blockchain ### Disassembling a contract from the Ethereum blockchain
You can also load code from an existing contract in the Ethereum blockchain. For this, you need to have a full node running, and the RPC debug interface must be activated. For example, when running `geth` you can do this as follows: You can also load code from an existing contract in the Ethereum blockchain. For this, you need to have a full node running, and the RPC debug interface must be activated. For example, when running `geth` you can do this as follows:
@ -60,7 +72,7 @@ $ geth --syncmode full --rpc --rpcapi eth,debug
To load contract code from your node, pass the TxID of the transaction that created the contract: To load contract code from your node, pass the TxID of the transaction that created the contract:
```bash ```bash
$ ./mythril.py -d -t 0x23112645da9ae684270de843faaeb44918c79a09e019d3a6cf8b87041020340e -o some_contract.easm $ ./mythril.py -d --txid 0x23112645da9ae684270de843faaeb44918c79a09e019d3a6cf8b87041020340e -o some_contract.easm
``` ```
Note: If you want to get code from the Ethereum mainnet, it is easier to download it from [Etherscan](https://etherscan.io). Note: If you want to get code from the Ethereum mainnet, it is easier to download it from [Etherscan](https://etherscan.io).

@ -18,12 +18,12 @@ def exitWithError(message):
parser = argparse.ArgumentParser(description='Ethereum VM bytecode assembler/ disassembler') parser = argparse.ArgumentParser(description='Ethereum VM bytecode assembler/ disassembler')
parser.add_argument('-d', '--disassemble', action='store_true', help='disassemble, use with -c or --transaction_hash') parser.add_argument('-d', '--disassemble', action='store_true', help='disassemble, use with -c or --txid')
parser.add_argument('-a', '--assemble', help='produce bytecode from easm input file', metavar='INPUT FILE') parser.add_argument('-a', '--assemble', help='produce bytecode from easm input file', metavar='INPUT FILE')
parser.add_argument('-t', '--trace', action='store_true', help='trace bytecode provided via the -c argument') parser.add_argument('-t', '--trace', action='store_true', help='trace bytecode provided via the -c argument')
parser.add_argument('-c', '--code', help='bytecode string ("6060604052...")', metavar='BYTECODE') parser.add_argument('-c', '--code', help='bytecode string ("6060604052...")', metavar='BYTECODE')
parser.add_argument('-o', '--outfile') parser.add_argument('-o', '--outfile')
parser.add_argument('--transaction_hash', help='id of contract creation transaction') parser.add_argument('--txid', help='id of contract creation transaction')
parser.add_argument('--rpchost', default='127.0.0.1', help='RPC host') parser.add_argument('--rpchost', default='127.0.0.1', help='RPC host')
parser.add_argument('--rpcport', type=int, default=8545, help='RPC port') parser.add_argument('--rpcport', type=int, default=8545, help='RPC port')
@ -34,17 +34,17 @@ if (args.disassemble):
if (args.code): if (args.code):
encoded_bytecode = args.code encoded_bytecode = args.code
elif (args.transaction_hash): elif (args.txid):
try: try:
encoded_bytecode = util.bytecode_from_blockchain(args.transaction_hash, args.rpchost, args.rpcport) encoded_bytecode = util.bytecode_from_blockchain(args.txid, args.rpchost, args.rpcport)
except Exception as e: except Exception as e:
exitWithError("Exception loading bytecode via RPC" + str(e.message)) exitWithError("Exception loading bytecode via RPC" + str(e.message))
else: else:
exitWithError("Disassembler: Provide the input bytecode via the -c or --transaction_hash arguments") exitWithError("Disassembler: Provide the input bytecode via the -c or --txid arguments")
disassembly = asm.disassemble(util.safe_decode(encoded_bytecode)) disassembly = asm.disassemble(util.safe_decode(encoded_bytecode))

Loading…
Cancel
Save