Merge pull request #12 from maurelian/tlsOption

Tls option
pull/17/head
Bernhard Mueller 7 years ago committed by GitHub
commit 0005724380
  1. 10
      myth
  2. 4
      mythril/ether/contractstorage.py
  3. 4
      mythril/ether/util.py

10
myth

@ -34,7 +34,6 @@ def exitWithError(message):
parser = argparse.ArgumentParser(description='Bug hunting on the Ethereum blockchain') parser = argparse.ArgumentParser(description='Bug hunting on the Ethereum blockchain')
commands = parser.add_argument_group('commands') commands = parser.add_argument_group('commands')
commands.add_argument('-d', '--disassemble', action='store_true', help='disassemble, specify input with -c or -a') commands.add_argument('-d', '--disassemble', action='store_true', help='disassemble, specify input with -c or -a')
commands.add_argument('-t', '--trace', action='store_true', help='trace, use with -c or -a and --data (optional)') commands.add_argument('-t', '--trace', action='store_true', help='trace, use with -c or -a and --data (optional)')
@ -54,6 +53,7 @@ options = parser.add_argument_group('options')
options.add_argument('--sync-all', action='store_true', help='Also sync contracts with zero balance') options.add_argument('--sync-all', action='store_true', help='Also sync contracts with zero balance')
options.add_argument('--rpchost', default='127.0.0.1', help='RPC host') options.add_argument('--rpchost', default='127.0.0.1', help='RPC host')
options.add_argument('--rpcport', type=int, default=8545, help='RPC port') options.add_argument('--rpcport', type=int, default=8545, help='RPC port')
options.add_argument('--rpctls', type=bool, default=False, help='RPC port')
options.add_argument('--ipc', help='use IPC interface instead of RPC', action='store_true') options.add_argument('--ipc', help='use IPC interface instead of RPC', action='store_true')
options.add_argument('--enable-physics', type=bool, default=False, help='enable graph physics simulation') options.add_argument('--enable-physics', type=bool, default=False, help='enable graph physics simulation')
options.add_argument('-v', type=int, help='log level (0-2)', metavar='LOG_LEVEL') options.add_argument('-v', type=int, help='log level (0-2)', metavar='LOG_LEVEL')
@ -84,7 +84,7 @@ if (args.disassemble or args.graph or args.fire_lasers):
exitWithError("Exception loading bytecode via IPC: " + str(e)) exitWithError("Exception loading bytecode via IPC: " + str(e))
else: else:
try: try:
eth = EthJsonRpc(args.rpchost, args.rpcport) eth = EthJsonRpc(args.rpchost, args.rpcport, args.rpctls)
encoded_bytecode = eth.eth_getCode(args.address) encoded_bytecode = eth.eth_getCode(args.address)
@ -136,7 +136,7 @@ elif (args.trace):
encoded_bytecode = eth.eth_getCode(args.address) encoded_bytecode = eth.eth_getCode(args.address)
else: else:
eth = EthJsonRpc(args.rpchost, args.rpcport) eth = EthJsonRpc(args.rpchost, args.rpcport, args.rpctls)
encoded_bytecode = eth.eth_getCode(args.address) encoded_bytecode = eth.eth_getCode(args.address)
else: else:
@ -180,9 +180,9 @@ elif args.search or args.xrefs or args.init_db:
elif (args.init_db): elif (args.init_db):
if args.ipc: 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: 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): elif (args.hash):
print("0x" + utils.sha3(args.hash)[:4].hex()) print("0x" + utils.sha3(args.hash)[:4].hex())

@ -47,11 +47,11 @@ class ContractStorage(persistent.Persistent):
return self.contracts[contract_hash] return self.contracts[contract_hash]
def initialize(self, rpchost, rpcport, sync_all, ipc): def initialize(self, rpchost, rpcport, rpctls, sync_all, ipc):
if ipc: if ipc:
eth = EthIpc() eth = EthIpc()
else: else:
eth = EthJsonRpc(rpchost, rpcport) eth = EthJsonRpc(rpchost, rpcport, rpctls)
if self.last_block: if self.last_block:
blockNum = self.last_block blockNum = self.last_block

@ -16,7 +16,7 @@ def safe_decode(hex_encoded_string):
# return codecs.decode(hex_encoded_string, 'hex_codec') # 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 """Load bytecode from a local node via
creation_tx_hash = ID of transaction that created the contract. creation_tx_hash = ID of transaction that created the contract.
""" """
@ -24,7 +24,7 @@ def bytecode_from_blockchain(creation_tx_hash, ipc, rpc_host='127.0.0.1', rpc_po
eth = EthIpc() eth = EthIpc()
else: else:
eth = EthJsonRpc(rpc_host, rpc_port) eth = EthJsonRpc(rpc_host, rpc_port, rpc_tls)
trace = eth.traceTransaction(creation_tx_hash) trace = eth.traceTransaction(creation_tx_hash)

Loading…
Cancel
Save