Level 1 Noob Hacker
Ethernaut 14 Gatekeeper One
0 / 100 EXP 100 EXP to Junior Hacker
0%

Challenge 14 / Ethernaut

Gatekeeper One

Goal

  1. Pass all three gates and set the player as entrant.

Your task

Read GatekeeperOne.sol, then complete Exploit.s.sol.

:~/targets/ethernaut-gatekeeper-one$
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract GatekeeperOne {
    address public entrant;

    modifier gateOne() {
        require(msg.sender != tx.origin);
        _;
    }

    modifier gateTwo() {
        require(gasleft() % 8191 == 0);
        _;
    }

    modifier gateThree(bytes8 _gateKey) {
        require(uint32(uint64(_gateKey)) == uint16(uint64(_gateKey)));
        require(uint32(uint64(_gateKey)) != uint64(_gateKey));
        require(uint32(uint64(_gateKey)) == uint16(uint160(tx.origin)));
        _;
    }

    function enter(bytes8 _gateKey) public gateOne gateTwo gateThree(_gateKey) returns (bool) {
        entrant = tx.origin;
        return true;
    }
}