From d3d2322da9c3f0e0b014dc0460c239ef9026cf05 Mon Sep 17 00:00:00 2001 From: Bernhard Mueller Date: Fri, 27 Oct 2017 15:47:31 +0700 Subject: [PATCH] Correctly process multiple input files --- myth | 3 ++- mythril/ether/ethcontract.py | 9 +++++---- tests/ethcontract_test.py | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/myth b/myth index 8741e1a8..088a9483 100755 --- a/myth +++ b/myth @@ -121,7 +121,7 @@ if (args.address or args.infiles): except Exception as e: exitWithError("Error establishing RPC connection: " + str(e)) -# Load code +# Load contract(s) code contracts = [] @@ -145,6 +145,7 @@ else: exitWithError("No input bytecode. Please provide EVM code via -c BYTECODE, -a ADDRESS, or -i SOLIDITY_FILES") logging.info("Loaded " + str(len(contracts)) + " contracts") +print(contracts) # Process commands diff --git a/mythril/ether/ethcontract.py b/mythril/ether/ethcontract.py index f8aa372f..a2f2a83c 100644 --- a/mythril/ether/ethcontract.py +++ b/mythril/ether/ethcontract.py @@ -1,4 +1,5 @@ -from mythril.ether import asm, util +from mythril.ether import util +from mythril.disassembler.disassembly import Disassembly import re import persistent from ethereum import utils @@ -14,7 +15,7 @@ class ETHContract(persistent.Persistent): def get_xrefs(self): - instruction_list = asm.disassemble(util.safe_decode(self.code)) + instruction_list = Disassembly(self.code).instruction_list xrefs = [] @@ -32,12 +33,12 @@ class ETHContract(persistent.Persistent): def get_disassembly(self): - return asm.disassemble(util.safe_decode(self.code)) + return Disassembly(self.code) def get_easm(self): - return asm.instruction_list_to_easm(asm.disassemble(util.safe_decode(self.code))) + return Disassembly(self.code).get_easm() def matches_expression(self, expression): diff --git a/tests/ethcontract_test.py b/tests/ethcontract_test.py index faf3bd25..b34923b7 100644 --- a/tests/ethcontract_test.py +++ b/tests/ethcontract_test.py @@ -14,9 +14,9 @@ class Getinstruction_listTestCase(ETHContractTestCase): contract = ETHContract(self.code, self.creation_code) - instruction_list = contract.get_disassembly() + disassembly = contract.get_disassembly() - self.assertEqual(len(instruction_list), 71, 'Error disassembling code using ETHContract.get_instruction_list()') + self.assertEqual(len(disassembly.instruction_list), 71, 'Error disassembling code using ETHContract.get_instruction_list()') class GetEASMTestCase(ETHContractTestCase):