diff --git a/myth b/myth index 38c566dc..b3289bc8 100755 --- a/myth +++ b/myth @@ -72,7 +72,6 @@ database.add_argument('--init-db', action='store_true', help='initialize the con database.add_argument('-s', '--search', help='search the contract database', metavar='EXPRESSION') utilities = parser.add_argument_group('utilities') -utilities.add_argument('--xrefs', action='store_true', help='get xrefs from a contract') utilities.add_argument('--hash', help='calculate function signature hash', metavar='SIGNATURE') utilities.add_argument('--storage', help='read state variables from storage index, use with -a', metavar='INDEX,NUM_SLOTS,[array]') utilities.add_argument('--solv', help='specify solidity compiler version. If not present, will try to install it (Experimental)', metavar='SOLV') @@ -130,7 +129,7 @@ with open(signatures_file) as f: # Parse cmdline args -if not (args.search or args.init_db or args.hash or args.disassemble or args.graph or args.xrefs or args.fire_lasers or args.storage or args.truffle): +if not (args.search or args.init_db or args.hash or args.disassemble or args.graph or args.fire_lasers or args.storage or args.truffle): parser.print_help() sys.exit() @@ -202,12 +201,10 @@ if args.address or args.init_db: else: try: host, port = args.rpc.split(":") - rpcconfig = (host, port, args.rpctls) + rpcconfig = (host, int(port), args.rpctls) except ValueError: - exitWithError(args.outform, "Invalid RPC argument, use HOST:PORT") - - rpcconfig = (host, int(port), args.tls) + exitWithError(args.outform, "Invalid RPC argument, use 'ganache', 'infura-[network]' or 'HOST:PORT'") if (rpcconfig): @@ -352,8 +349,6 @@ elif args.disassemble: easm_text = contracts[0].get_easm() sys.stdout.write(easm_text) -elif args.xrefs: - print("\n".join(contracts[0].get_xrefs())) elif args.graph or args.fire_lasers: if not contracts: diff --git a/mythril/ether/ethcontract.py b/mythril/ether/ethcontract.py index bc5f5071..e3895609 100644 --- a/mythril/ether/ethcontract.py +++ b/mythril/ether/ethcontract.py @@ -29,23 +29,6 @@ class ETHContract(persistent.Persistent): 'disassembly': self.disassembly } - def get_xrefs(self): - - instruction_list = Disassembly(self.code).instruction_list - - xrefs = [] - - for instruction in instruction_list: - if instruction['opcode'] == "PUSH20": - if instruction['argument']: - addr = instruction['argument'] - - if (re.match(r'^0x[a-zA-Z0-9]{40}$', addr) and addr != "0xffffffffffffffffffffffffffffffffffffffff"): - if addr not in xrefs: - xrefs.append(addr) - - return xrefs - def get_easm(self): return Disassembly(self.code).get_easm() diff --git a/tests/ethcontract_test.py b/tests/ethcontract_test.py index 2ab0950f..6330b199 100644 --- a/tests/ethcontract_test.py +++ b/tests/ethcontract_test.py @@ -36,13 +36,3 @@ class MatchesExpressionTestCase(ETHContractTestCase): self.assertTrue(contract.matches_expression("code#PUSH1# or code#PUSH1#"),'Unexpected result in expression matching') self.assertFalse(contract.matches_expression("func#abcdef#"),'Unexpected result in expression matching') - -class GetXrefsTestCase(ETHContractTestCase): - - def runTest(self): - - contract = ETHContract(self.code) - - xrefs = contract.get_xrefs() - - self.assertEqual(xrefs[0], "0xc3b2ae46792547a96b9f84405e36d0e07edcd05c", 'Error getting xrefs from contract') \ No newline at end of file