Merge pull request #378 from b-mueller/master

Fix function signature search
pull/396/head
Bernhard Mueller 6 years ago committed by GitHub
commit bdf2d788a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      mythril/ether/ethcontract.py
  2. 2
      mythril/leveldb/client.py

@ -38,15 +38,6 @@ class ETHContract(persistent.Persistent):
str_eval = '' str_eval = ''
easm_code = None 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)) tokens = filter(None, re.split("(and|or|not)", expression.replace(" ", ""), re.IGNORECASE))
for token in tokens: for token in tokens:
@ -65,10 +56,13 @@ class ETHContract(persistent.Persistent):
str_eval += "\"" + code + "\" in easm_code" str_eval += "\"" + code + "\" in easm_code"
continue continue
m = re.match(r'^func#([a-fA-F0-9]+)#$', token) m = re.match(r'^func#([a-zA-Z0-9\s_,(\\)\[\]]+)#$', token)
if (m): if (m):
str_eval += "\"" + m.group(1) + "\" in self.disassembly.func_hashes"
sign_hash = "0x" + utils.sha3(m.group(1))[:4].hex()
str_eval += "\"" + sign_hash + "\" in self.disassembly.func_hashes"
continue continue

@ -203,7 +203,7 @@ class EthLevelDB(object):
cnt += 1 cnt += 1
if not cnt % 10: if not cnt % 1000:
logging.info("Searched %d contracts" % cnt) logging.info("Searched %d contracts" % cnt)
def contract_hash_to_address(self, hash): def contract_hash_to_address(self, hash):

Loading…
Cancel
Save