-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplay.html
More file actions
208 lines (196 loc) · 10.7 KB
/
Copy pathplay.html
File metadata and controls
208 lines (196 loc) · 10.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mister CTF</title>
<link rel="stylesheet" href="./assets/style.css">
<link rel="icon" href="assets/Mr.CTF.png">
</head>
<body class="center">
<section class="chall">
<button class="back center" onclick="back()">
<p><</p>
</button>
<div class="title center" style="margin: 25px 25px">
<h1>
Mister - CTF!!
</h1>
<p class="subtitle">
Capture the Flag🚩 With MisterO
</p>
</div>
<hr style="width: min(1000px, 90%);">
<section class="navs">
<!-- <button class="nav arrow"><</button>
<p class="label nav">Label</p>
<button class="nav arrow">></button> -->
</section>
</section>
<script>
let id = new URLSearchParams(document.location.search).get("stage");
if(id == null){
// Append Lobby
let stages = document.createElement("section");
stages.classList.add("stages");
document.querySelector("section.chall").appendChild(stages);
let extras = document.createElement("section");
extras.classList.add("extras");
document.querySelector("section.chall").appendChild(extras);
fetch('content/data.json')
.then(response => response.json())
.then(res=>{
for(let id=1;id<=10;id++){
let data = res[id];
let stage = document.createElement("a");
stage.classList.add("stage");
if(window.localStorage.getItem(`stage-${id}`) != null && CryptoJS.SHA1(window.localStorage.getItem(`stage-${id}`)).toString() == data.key){
stage.classList.add("passed");
}else if(window.localStorage.getItem(`stage-${id}`) != null && CryptoJS.SHA1(window.localStorage.getItem(`stage-${id}`)).toString() != data.key){
stage.classList.add("wrong_hash");
}
stage.href = `?stage=${id}`;
stage.innerHTML = `Stage ${id}<hr class="underline">${data.name}`;
document.querySelector("section.stages").appendChild(stage);
}
});
}
fetch('content/data.json')
.then(response => response.json())
.then(res => {
document.cookie = "hex-val=a3b0f922dc7034ed3d002f8852a5fee0c65d4d0643d756b372af5a07aaad315b96f04533b3df29d468b0c55655c0b3e6d84f22b78c315f88c79a49a6897b5a1cbf231db1c675c3bde417b21f46c3bf7d; path=/; max-age=0";
document.cookie = "hint=blowfish; path=/; max-age=0";
if(id != null && (1 > Number(id) || Number(id) > 10)) window.location.href = "https://www.youtube.com/watch?v=itJ_DJVKAW0";
if(id != null){
let require = 0;
// console.log("id : ", id);
if (Array.isArray(res[id]["require"])) {
if(id === "extra3"){ window.location.href = "https://www.youtube.com/watch?v=itJ_DJVKAW0"; return; }
res[id]["require"].forEach(idx => {
if(require) return;
if(CryptoJS.SHA1(window.localStorage.getItem(`stage-${idx}`)).toString() != res[idx]["key"]){
alert(`Please do Stage-${idx} to unlock this stage!`);
window.location.href = "play.html";
require = 1;
return;
}
});
}
if(require) return;
res = res[id];
let prev = document.createElement("button");
prev.classList.add("arrow");
prev.classList.add("nav");
prev.innerText = "<";
prev.onclick = () => previousPage(id);
document.querySelector("section.navs").appendChild(prev);
let label = document.createElement("p");
label.classList.add("label");
label.classList.add("nav");
if(Number(id)) label.innerText = `Stage - ${id}`;
else label.innerText = `Extra Stage #${id[id.length-1]}`;
document.querySelector("section.navs").appendChild(label);
let next = document.createElement("button");
next.classList.add("arrow");
next.classList.add("nav");
next.innerText = ">";
next.onclick = () => nextPage(id);
document.querySelector("section.navs").appendChild(next);
if(id == 10){
document.cookie = "hex-val=a3b0f922dc7034ed3d002f8852a5fee0c65d4d0643d756b372af5a07aaad315b96f04533b3df29d468b0c55655c0b3e6d84f22b78c315f88c79a49a6897b5a1cbf231db1c675c3bde417b21f46c3bf7d; path=/; max-age=3600";
document.cookie = "hint=blowfish; path=/; max-age=3600";
}else{
document.cookie = "hex-val=a3b0f922dc7034ed3d002f8852a5fee0c65d4d0643d756b372af5a07aaad315b96f04533b3df29d468b0c55655c0b3e6d84f22b78c315f88c79a49a6897b5a1cbf231db1c675c3bde417b21f46c3bf7d; path=/; max-age=0";
document.cookie = "hint=blowfish; path=/; max-age=0";
}
document.querySelector("section.chall").classList.add("center");
let div = document.createElement("div");
div.classList.add("chall");
// console.log("Name : ", res.name);
let name = document.createElement("p");
name.innerHTML = `Name : ${res.name}`;
div.appendChild(name);
// console.log("Challenge : ", res.challenge);
let challenge = document.createElement("p");
challenge.innerHTML = `Challenge : ${res.challenge}`;
div.appendChild(challenge);
if(res.files != null){
let list = document.createElement("div");
res.files.forEach(file => {
let container = document.createElement("div");
container.classList.add("file");
// console.log("File : ",file)
let a = document.createElement("a");
a.href = `content/${id}/${file}`;
a.download = file
a.innerText = `${file}`;
container.appendChild(a);
list.appendChild(container);
});
div.appendChild(list);
}
if(res.hints != null){
let list = document.createElement("div");
let cnt = 1;
res.hints.forEach((_, index) => {
let container = document.createElement("div");
container.classList.add("file");
let btn = document.createElement("button");
btn.innerText = `Hint #${index+1}`;
btn.onclick = () => hint(index);
cnt += 1;
container.appendChild(btn);
list.appendChild(container);
});
div.appendChild(list);
}
let input = document.createElement("input");
input.type="text";
input.autocomplete = "off";
input.id = `ans-${id}`;
div.appendChild(input);
let submit = document.createElement("button");
submit.innerText = "Submit!!"
submit.onclick = () => judge(id);
div.appendChild(submit);
document.querySelector("section.chall").append(div);
}else{
let flag = 1;
let cnt = 0;
for(let i=1;i<=10;i++){
if(window.localStorage.getItem(`stage-${i}`) === null || CryptoJS.SHA1(window.localStorage.getItem(`stage-${i}`)).toString() != res[i]['key']){
flag = 0;
}else{
cnt += 1;
}
}
if(cnt >= 5){
let extra1 = document.createElement("div");
extra1.classList.add("center");
extra1.innerHTML = `<a href="?stage=extra1" class="extra"${window.localStorage.getItem(`stage-extra1`) !== null && CryptoJS.SHA1(window.localStorage.getItem("stage-extra1")).toString() == res["extra1"]['key']?'style="background-color:#53ff53;"' : ""}>Extra Stage #1<hr class="underline">${res["extra1"]["name"]}</a>`;
document.querySelector("section.extras").appendChild(extra1);
}
if(window.localStorage.getItem(`stage-extra1`) !== null && CryptoJS.SHA1(window.localStorage.getItem("stage-extra1")).toString() == res["extra1"]['key']){
let extra2 = document.createElement("div");
extra2.classList.add("center");
extra2.innerHTML = `<a href="?stage=extra2" class="extra"${window.localStorage.getItem(`stage-extra2`) !== null && CryptoJS.SHA1(window.localStorage.getItem("stage-extra2")).toString() == res["extra2"]['key']?'style="background-color:#53ff53;"' : ""}>Extra Stage #2<hr class="underline">${res["extra2"]["name"]}</a>`;
document.querySelector("section.extras").appendChild(extra2);
}
if(window.localStorage.getItem(`stage-extra3`) !== null && CryptoJS.SHA1(window.localStorage.getItem("stage-extra3")).toString() == res["extra3"]['key']){
let extra3 = document.createElement("div");
extra3.classList.add("center");
extra3.innerHTML = `<a href="?stage=extra3" class="extra" style="background-color:#53ff53;">Extra Stage #3<hr class="underline">${res["extra3"]["name"]}</a>`;
document.querySelector("section.extras").appendChild(extra3);
}
}
})
.catch(error => {
console.error("Error loading JSON:", error);
});
</script>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/core.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"></script>
<script src="script/stage10.js"></script>
<script src="script/main.js"></script>
</html>