And use address for comparison in taint analysis

pull/375/head^2
Joran Honig 6 years ago
parent 7c839b9825
commit b7c67962d8
  1. 18
      mythril/laser/ethereum/state.py
  2. 2
      mythril/laser/ethereum/taint_analysis.py

@ -38,13 +38,14 @@ class Account:
def add_balance(self, balance): def add_balance(self, balance):
self.balance += balance self.balance += balance
def get_storage(self, index): # def get_storage(self, index):
if index in self.storage.keys(): # return BitVec("storage_" + str(index), 256)
return self.storage[index] # if index in self.storage.keys():
else: # return self.storage[index]
symbol = BitVec("storage_" + str(index), 256) # else:
self.storage[index] = symbol # symbol = BitVec("storage_" + str(index), 256)
return symbol # self.storage[index] = symbol
# return symbol
@property @property
def as_dict(self): def as_dict(self):
@ -83,6 +84,7 @@ class Environment:
def __str__(self): def __str__(self):
return str(self.as_dict) return str(self.as_dict)
@property @property
def as_dict(self): def as_dict(self):
return dict(active_account=self.active_account, sender=self.sender, calldata=self.calldata, return dict(active_account=self.active_account, sender=self.sender, calldata=self.calldata,
@ -150,7 +152,7 @@ class GlobalState:
def __copy__(self): def __copy__(self):
accounts = self.accounts accounts = copy(self.accounts)
environment = copy(self.environment) environment = copy(self.environment)
mstate = deepcopy(self.mstate) mstate = deepcopy(self.mstate)
call_stack = copy(self.call_stack) call_stack = copy(self.call_stack)

@ -118,7 +118,7 @@ class TaintRunner:
direct_children = [statespace.nodes[edge.node_to] for edge in statespace.edges if edge.node_from == node.uid] direct_children = [statespace.nodes[edge.node_to] for edge in statespace.edges if edge.node_from == node.uid]
children = [] children = []
for child in direct_children: for child in direct_children:
if child.states[0].environment.active_account == environment.active_account: if child.states[0].environment.active_account.address == environment.active_account.address:
children.append(child) children.append(child)
else: else:
children += TaintRunner.children(child, statespace, environment) children += TaintRunner.children(child, statespace, environment)

Loading…
Cancel
Save