Level 1 Noob Hacker
Ethernaut 15 Gatekeeper Two
0 / 100 EXP 100 EXP to Junior Hacker
0%

Challenge 15 / Ethernaut

Gatekeeper Two

Goal

  1. Set the player address as Gatekeeper Two's entrant.

Your task

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

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

/// @notice Adapted from OpenZeppelin Ethernaut level 14. Original authorship and
/// source attribution are recorded in the challenge manifest.
contract GatekeeperTwo {
    address public entrant;

    modifier gateOne() {
        require(msg.sender != tx.origin, "GatekeeperTwo: gate one");
        _;
    }

    modifier gateTwo() {
        uint256 size;
        assembly {
            size := extcodesize(caller())
        }
        require(size == 0, "GatekeeperTwo: gate two");
        _;
    }

    modifier gateThree(bytes8 gateKey) {
        require(
            uint64(bytes8(keccak256(abi.encodePacked(msg.sender)))) ^ uint64(gateKey) == type(uint64).max,
            "GatekeeperTwo: gate three"
        );
        _;
    }

    constructor(bytes8 gateKey) gateOne gateTwo gateThree(gateKey) {
        entrant = tx.origin;
    }
}