페이지 소스코드다
<!-- index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BISC 금고</title>
<script src="https://cdn.jsdelivr.net/npm/web3@1.6.0/dist/web3.min.js"></script>
</head>
<body>
<h1>BISC 금고를 열어주세요!!</h1>
<div class="safe-container">
<div class="safe">
<div class="door" id="door">
<div class="handle"></div>
</div>
</div>
<button id="openButton" onclick="openSafe()">열기</button>
<div id="result"></div>
</div>
<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
<script>
const start = async () => {
if(window.ethereum !== "undefined") {
const accounts = await ethereum.request({method: "eth_requestAccounts"});
account = accounts[0];
console.log(`my contract: ${account}`);
}
const ABI = [
{
"inputs": [
{
"internalType": "address",
"name": "_owner",
"type": "address"
}
],
"name": "changeOwner",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "opensafe",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
}
];
const ADDRESS = "0x5e992854Bd912ae170b7b5b8a64323e4e5E0feAF";
window.web3 = await new Web3(window.ethereum);
window.contract = new web3.eth.Contract(ABI, ADDRESS);
console.log(`safe contract: ${window.contract.options.address}`);
}
start();
async function openSafe() {
try {
const result = await window.contract.methods.opensafe().call({from: account});
if (result === "Your not owner!!") {
document.getElementById('result').innerText = result;
} else {
document.getElementById('result').innerText = result;
var door = document.getElementById('door');
door.style.transform = 'rotateY(-90deg)';
}
} catch (error) {
console.error(error);
}
}
</script>
</body>
<style>
/* styles.css */
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
}
.safe-container {
display: flex;
flex-direction: column;
align-items: center;
}
.safe {
background-color: #333;
padding: 20px;
border-radius: 15px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
width: 300px;
}
.door {
position: relative;
width: 250px; /* 크기 조정 */
height: 350px; /* 크기 조정 */
background-color: #777;
border-radius: 15px;
display: flex;
justify-content: center;
align-items: center;
position: relative;
overflow: hidden;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}
button {
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
margin-top: 10px;
}
.handle {
position: absolute;
top: 50%;
left: 95%;
transform: translate(-50%, -50%);
width: 20px;
height: 80px;
background-color: #444;
border-radius: 5px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}
.safe-text {
text-align: center;
margin-top: 10px;
color: #fff;
font-size: 24px;
font-weight: bold;
}
</style>
</html>
safe.sol파일이다
// SPDX-License-Identifier: MIT
pragma solidity >= 0.7.0 < 0.9.0;
contract Safe {
address public owner;
string private flag = "bisc2023{FAKE_FLAG}";
constructor() {
owner = msg.sender;
}
function opensafe() public view returns (string memory) {
if(owner == msg.sender){
return flag;
}
else {
return "Your not owner!!";
}
}
function changeOwner(address _owner) public {
require(owner == msg.sender, "Your not owner!!");
owner = _owner;
}
}
owner == msg.sender랑 일치해야 flag가 나온다
https://lucykorea414.tistory.com/104
풀이를 보고 문제를 풀어봤다..!
MetaMask chrome extension을 다운로드 받고 계정을 생성해야한다!!
출처:https://lucykorea414.tistory.com/104
[지은이는 지은이:티스토리]
짜자잔 flag 등장! gpt한테 물어보고싶은데..지금 서버 오류뜸;;
'Dreamhack > Dreamhack Wargame (Challenge)' 카테고리의 다른 글
[136] IT 비전공자 [dreamhack]Base64 10 Times문제 풀기 (0) | 2025.01.24 |
---|---|
[135] IT 비전공자 [dreamhack]Arm Training-v1문제 풀기 (0) | 2025.01.23 |
[133] IT 비전공자 [dreamhack]sane-env문제 풀기 (0) | 2025.01.22 |
[132] IT 비전공자 [dreamhack]STREAMer-Prototype문제 풀기 (0) | 2025.01.20 |
[131] IT 비전공자 [dreamhack]Grand Theft Auto문제 풀기 (0) | 2025.01.19 |