Pwnstar

Ethernaut Level 8(Vault) 본문

Wargame/Ethernaut

Ethernaut Level 8(Vault)

포너블처돌이 2023. 4. 3. 16:19

Vault(금고)인데, 역대급으로 쉬운 문제였다.

이건 뭐 도움말도 없음.

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

contract Vault {
  bool public locked;
  bytes32 private password;

  constructor(bytes32 _password) {
    locked = true;
    password = _password;
  }

  function unlock(bytes32 _password) public {
    if (password == _password) {
      locked = false;
    }
  }
}

코드는 이렇게 되어 있는데, 혹시 뭐 변수의 값을 확인할 수 있는 게 있지 않을까? 싶어서 검색해봤는데, getStorageAt이라는 함수가 있다.

이 함수는 특정 address의 스토리지를 가져오는데, getStorageAt(address, idx) 와 같이 사용할 수 있다.

변수 두 개 중 locked가 첫 번재, password가 두 번째니까, idx로는 1을 주고 address로는 contract의 주소를 넣어주면 된다.


Sepolia testnet이나 Goerli testnet에서는 문제를 정상적으로 풀 수 있지만, Mumbai testnet에서는 getStorageAt이 작동하지 않는다.

원인은 아직 모르겠음.


Uploaded by N2T

'Wargame > Ethernaut' 카테고리의 다른 글

Ethernaut Level 10(Re-entrancy)  (0) 2023.04.04
Ethernaut Level 9(King)  (0) 2023.04.03
Ethernaut Level 7(Force)  (0) 2023.04.03
Ethernaut Level 6(Delegation)  (0) 2023.04.03
Ethernaut Level 5(Token)  (1) 2023.03.12
Comments