mirror of https://github.com/ConsenSys/mythril
blockchainethereumsmart-contractssoliditysecurityprogram-analysissecurity-analysissymbolic-execution
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
2.5 KiB
47 lines
2.5 KiB
6 years ago
|
from mythril.disassembler.disassembly import Disassembly
|
||
|
from mythril.laser.ethereum import svm
|
||
6 years ago
|
from mythril.laser.ethereum.state.account import Account
|
||
6 years ago
|
from mythril.laser.ethereum.state.world_state import WorldState
|
||
2 years ago
|
from mythril.support.support_args import args
|
||
6 years ago
|
|
||
6 years ago
|
import mythril.laser.ethereum.cfg as cfg
|
||
6 years ago
|
|
||
|
|
||
|
def test_intercontract_call():
|
||
|
# Arrange
|
||
6 years ago
|
caller_code = Disassembly(
|
||
|
"6080604052348015600f57600080fd5b5073deadbeefdeadbeefdeadbeefdeadbeefdeadbeef73ffffffffffffffffffffffffffffffffffffffff166389627e13336040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15801560be57600080fd5b505af115801560d1573d6000803e3d6000fd5b505050506040513d602081101560e657600080fd5b8101908080519060200190929190505050500000a165627a7a72305820fdb1e90f0d9775c94820e516970e0d41380a94624fa963c556145e8fb645d4c90029"
|
||
|
)
|
||
6 years ago
|
caller_address = "0xaffeaffeaffeaffeaffeaffeaffeaffeaffeaffe"
|
||
|
|
||
6 years ago
|
callee_code = Disassembly(
|
||
|
"608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806389627e13146044575b600080fd5b348015604f57600080fd5b506082600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506084565b005b8073ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f1935050505015801560e0573d6000803e3d6000fd5b50505600a165627a7a72305820a6b1335d6f994632bc9a7092d0eaa425de3dea05e015af8a94ad70b3969e117a0029"
|
||
|
)
|
||
6 years ago
|
callee_address = "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
|
||
|
|
||
6 years ago
|
world_state = WorldState()
|
||
|
|
||
6 years ago
|
caller_account = Account(caller_address, caller_code, contract_name="Caller")
|
||
|
callee_account = Account(callee_address, callee_code, contract_name="Callee")
|
||
6 years ago
|
world_state.put_account(callee_account)
|
||
|
world_state.put_account(caller_account)
|
||
2 years ago
|
args.pruning_factor = 1
|
||
6 years ago
|
laser = svm.LaserEVM()
|
||
6 years ago
|
|
||
|
# Act
|
||
6 years ago
|
laser.sym_exec(world_state=world_state, target_address=int(caller_address, 16))
|
||
6 years ago
|
|
||
|
# Assert
|
||
|
# Initial node starts in contract caller
|
||
6 years ago
|
assert len(laser.nodes.keys()) > 0
|
||
4 years ago
|
node_id = list(laser.nodes.keys())[0]
|
||
|
assert laser.nodes[node_id].contract_name == "Caller"
|
||
6 years ago
|
|
||
|
# At one point we call into contract callee
|
||
|
for node in laser.nodes.values():
|
||
6 years ago
|
if node.contract_name == "Callee":
|
||
6 years ago
|
assert len(node.states[0].transaction_stack) > 1
|
||
|
return
|
||
|
|
||
|
assert False
|