From 70d7bc0683fb9f57b57a172dbd9eaf0a5006bae5 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 24 Jul 2018 21:12:08 +0000 Subject: [PATCH] Fix processing of function name in search expression --- mythril/ether/ethcontract.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/mythril/ether/ethcontract.py b/mythril/ether/ethcontract.py index 8e19c746..c262b3c1 100644 --- a/mythril/ether/ethcontract.py +++ b/mythril/ether/ethcontract.py @@ -38,15 +38,6 @@ class ETHContract(persistent.Persistent): str_eval = '' easm_code = None - matches = re.findall(r'func#([a-zA-Z0-9\s_,(\\)\[\]]+)#', expression) - - for m in matches: - # Calculate function signature hashes - - sign_hash = utils.sha3(m)[:4].hex() - - expression = expression.replace(m, sign_hash) - tokens = filter(None, re.split("(and|or|not)", expression.replace(" ", ""), re.IGNORECASE)) for token in tokens: @@ -65,11 +56,14 @@ class ETHContract(persistent.Persistent): str_eval += "\"" + code + "\" in easm_code" continue - m = re.match(r'^func#([a-fA-F0-9]+)#$', token) + m = re.match(r'^func#([a-zA-Z0-9\s_,(\\)\[\]]+)#$', token) if (m): - str_eval += "\"" + m.group(1) + "\" in self.disassembly.func_hashes" - continue + sign_hash = "0x" + utils.sha3(m.group(1))[:4].hex() + + str_eval += "\"" + sign_hash + "\" in self.disassembly.func_hashes" + continue + return eval(str_eval.strip())