Add workaround to prevent crash when dynamic contract address is encountered in bytecode

pull/53/head
Bernhard Mueller 7 years ago
parent af23333239
commit f1d88ff818
  1. 3
      mythril/analysis/modules/integer_underflow.py
  2. 9
      mythril/ether/ethcontract.py
  3. 1
      mythril/ether/util.py

@ -38,7 +38,8 @@ def execute(statespace):
continue
if (re.search(r'calldatasize_', str(op0))) \
or (re.search(r'256\*.*If\(1', str(op0), re.DOTALL) or re.search(r'256\*.*If\(1', str(op1), re.DOTALL)):
or (re.search(r'256\*.*If\(1', str(op0), re.DOTALL) or re.search(r'256\*.*If\(1', str(op1), re.DOTALL)) \
or (re.search(r'32 \+.*calldata', str(op0), re.DOTALL) or re.search(r'32 \+.*calldata', str(op1), re.DOTALL)):
# Filter for patterns that contain possible (but apparently non-exploitable) Integer underflows.

@ -8,11 +8,18 @@ class ETHContract(persistent.Persistent):
def __init__(self, code, creation_code="", name="", address=""):
self.code = code
self.creation_code = creation_code
self.name = name
self.address = address
# Workaround: We currently do not support compile-time linking.
# Dynamic contract addresses of the format __[contract-name]_____________ are replaced with a generic address
code = re.sub(r'(_+[A-Za-z0-9]+_+)', 'aa' * 20, code)
self.code = code
def as_dict(self):
return {

@ -9,6 +9,7 @@ import re
def safe_decode(hex_encoded_string):
if (hex_encoded_string.startswith("0x")):
return bytes.fromhex(hex_encoded_string[2:])
else:

Loading…
Cancel
Save