From a7741b24e36d79adbfa64a758c729dafd2c61645 Mon Sep 17 00:00:00 2001 From: maurelian Date: Fri, 20 Oct 2017 09:10:48 -0400 Subject: [PATCH 1/2] Add tls option --- myth | 10 ++++++---- mythril/ether/contractstorage.py | 4 ++-- mythril/ether/util.py | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/myth b/myth index 6bf96377..f39c4186 100755 --- a/myth +++ b/myth @@ -51,6 +51,8 @@ parser.add_argument('--init-db', action='store_true', help='Initialize the contr 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') +parser.add_argument('--rpctls', type=bool, default=False, help='RPC port') + try: db_dir = os.environ['DB_DIR'] @@ -79,7 +81,7 @@ if (args.disassemble or args.graph or args.fire_lasers): exitWithError("Exception loading bytecode via IPC: " + str(e)) else: try: - eth = EthJsonRpc(args.rpchost, args.rpcport) + eth = EthJsonRpc(args.rpchost, args.rpcport, args.rpctls) encoded_bytecode = eth.eth_getCode(args.address) @@ -125,7 +127,7 @@ elif (args.trace): encoded_bytecode = eth.eth_getCode(args.address) else: - eth = EthJsonRpc(args.rpchost, args.rpcport) + eth = EthJsonRpc(args.rpchost, args.rpcport, args.rpctls) encoded_bytecode = eth.eth_getCode(args.address) else: @@ -165,9 +167,9 @@ elif (args.xrefs): elif (args.init_db): if args.ipc: - contract_storage.initialize(args.rpchost, args.rpcport, args.sync_all, args.ipc) + contract_storage.initialize(args.rpchost, args.rpcport, args.rpctls, args.sync_all, args.ipc) else: - contract_storage.initialize(args.rpchost, args.rpcport, args.sync_all, args.ipc) + contract_storage.initialize(args.rpchost, args.rpcport, args.rpctls, args.sync_all, args.ipc) elif (args.hash): print("0x" + utils.sha3(args.hash)[:4].hex()) diff --git a/mythril/ether/contractstorage.py b/mythril/ether/contractstorage.py index a30fd501..d0dc532a 100644 --- a/mythril/ether/contractstorage.py +++ b/mythril/ether/contractstorage.py @@ -47,11 +47,11 @@ class ContractStorage(persistent.Persistent): return self.contracts[contract_hash] - def initialize(self, rpchost, rpcport, sync_all, ipc): + def initialize(self, rpchost, rpcport, rpctls, sync_all, ipc): if ipc: eth = EthIpc() else: - eth = EthJsonRpc(rpchost, rpcport) + eth = EthJsonRpc(rpchost, rpcport, rpctls) if self.last_block: blockNum = self.last_block diff --git a/mythril/ether/util.py b/mythril/ether/util.py index 4cdc6cca..349580f8 100644 --- a/mythril/ether/util.py +++ b/mythril/ether/util.py @@ -16,14 +16,14 @@ def safe_decode(hex_encoded_string): # return codecs.decode(hex_encoded_string, 'hex_codec') -def bytecode_from_blockchain(creation_tx_hash, ipc, rpc_host='127.0.0.1', rpc_port=8545): +def bytecode_from_blockchain(creation_tx_hash, ipc, rpc_host='127.0.0.1', rpc_port=8545, rpc_tls=False): """Load bytecode from a local node via creation_tx_hash = ID of transaction that created the contract. """ if ipc: pass else: - eth = EthJsonRpc(rpc_host, rpc_port) + eth = EthJsonRpc(rpc_host, rpc_port, rpc_tls) trace = eth.traceTransaction(creation_tx_hash) From 95759928e8ef5f5bae7e9eb3388e863411835335 Mon Sep 17 00:00:00 2001 From: Bernhard Mueller Date: Fri, 20 Oct 2017 12:01:50 +0700 Subject: [PATCH 2/2] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e52952fb..e28020b2 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,8 @@ You also need a [go-ethereum](https://github.com/ethereum/go-ethereum) node that $ geth --rpc --rpcapi eth,debug --syncmode fast ``` +Ideally, the node should be fully synced before starting to work with Mythril - otherwise you won't be able to retrieve recent contracts via RPC or IPC. + ## Command line usage The Mythril command line tool (aptly named `myth`) allows you to conveniently access some of Mythril's functionality.