The Ethernaut - 18. Magic Number

Gunter·2024년 10월 30일
0

The Ethernaut

목록 보기
19/26

To solve this level, you only need to provide the Ethernaut with a Solver, a contract that responds to whatIsTheMeaningOfLife() with the right 32 byte number.

Easy right? Well... there's a catch.

The solver's code needs to be really tiny. Really reaaaaaallly tiny. Like freakin' really really itty-bitty tiny: 10 bytes at most.

Hint: Perhaps its time to leave the comfort of the Solidity compiler momentarily, and build this one by hand O_o. That's right: Raw EVM bytecode.
Good luck!

 


 

되게 재밌게 푼 문제 !! 이런 풀이 접근 방식은 처음 접해봐서 신기한 느낌으로 재밋었당

 

최대 10바이트인 Really reaaaaaaally tiny 한 코드를 만들어야 하는데
힌트 : One by hand = 직접쓰샘ㅋㅋ.

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

contract MagicNum {
    address public solver;

    constructor() {}

    function setSolver(address _solver) public {
        solver = _solver;
    }

    /*
    ____________/\\\_______/\\\\\\\\\_____        
     __________/\\\\\_____/\\\///////\\\___       
      ________/\\\/\\\____\///______\//\\\__      
       ______/\\\/\/\\\______________/\\\/___     
        ____/\\\/__\/\\\___________/\\\//_____    
         __/\\\\\\\\\\\\\\\\_____/\\\//________   
          _\///////////\\\//____/\\\/___________  
           ___________\/\\\_____/\\\\\\\\\\\\\\\_ 
            ___________\///_____\///////////////__
    */
}

magic number는 문제에 주석으로 42라고 대놓고 나와있음

42를 solver에 넣기!!

 

# Runtime Opcodes
6042 //  v: push1 0x2A
6080 // p: push1 0x80
52   //  opcode mstore
6020 // s: push1 0x20
6080 // p: push1 0x80
f3 // return
# to Hex
# Initialization Opcodes
600a // s: push1 0x0a
600c // f: push1 0x0c
6000 // t: push1 0x00
39 // CODECOPY
600a // s: push1 0x0a
6000 // p: push1 0x00
f3 // return to EVM
# to Hex
var account = "0x41482D3f30FfF21308D6c962E167e4Cc8a65576A";
var bytecode = "0x600a600c600039600a6000f3602A60805260206080f3";
await(web3.eth.sendTransaction({ from: account, data: bytecode }, function(err,res){console.log(res)}));
await contract.setSolver("contract address");

1개의 댓글

comment-user-thumbnail
2024년 11월 4일

Looking to make this year's festivities unforgettable? spice up your corporate christmas party with these great entertainment ideas Start with a themed photo booth complete with props, allowing guests to capture fun memories. Consider hiring a live band or DJ to keep the energy high and encourage dancing. For a touch of elegance, you could arrange a cocktail-making class, where employees can learn to mix festive drinks. If you're aiming for laughter, a comedian or improv troupe can engage everyone. Finally, don’t forget interactive games or trivia focused on your company's achievements, ensuring a memorable celebration for all.

답글 달기
Powered by GraphCDN, the GraphQL CDN