b01lers2020-Welcome-to-Earth

摘要
js 解密

1. 根界面
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
<h1>AMBUSH!</h1>
<p>You've gotta escape!</p>

<script>
document.onkeydown = function(event) {
event = event || window.event;
if (event.keyCode == 27) {
event.preventDefault();
window.location = "/chase/";
} else die();
};

function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

async function dietimer() {
await sleep(10000);
die();
}

function die() {
window.location = "/die/";
}

dietimer();
</script>

在1s内逃跑

2. /chase/
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
<h1>CHASE!</h1>
<p>
You managed to chase one of the enemy fighters, but there's a wall coming
up fast!
</p>

<script>
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

async function dietimer() {
await sleep(1000);
die();
}

function die() {
window.location = "/die/";
}

function left() {
window.location = "/die/";
}

function leftt() {
window.location = "/leftt/";
}

function right() {
window.location = "/die/";
}

dietimer();
</script>

事件触发 leftt……

3. /leftt/
1
2
3
4
5
<h1>SHOOT IT</h1>
<p>You've got the bogey in your sights, take the shot!</p>

<button onClick="window.location='/die/'">Take the shot</button>
<!-- <button onClick="window.location='/shoot/'">Take the shot</button> -->

……

4. /shoot/
1
2
3
<h1>YOU SHOT IT DOWN!</h1>
<p>Well done! You also crash in the process</p>
<button onClick="window.location='/door/'">Continue</button>
5. /door/

很多按钮……

1
<button onClick="check_door()">Check</button>

点击触发事件,看引入的js文件

door.js

1
2
3
4
5
6
7
8
9
10
11
function check_door() {
var all_radio = document.getElementById("door_form").elements;
var guess = null;

for (var i = 0; i < all_radio.length; i++)
if (all_radio[i].checked) guess = all_radio[i].value;

rand = Math.floor(Math.random() * 360);
if (rand == guess) window.location = "/open/";
else window.location = "/die/";
}
6. /open/
1
2
<h1>YOU FOUND THE DOOR!</h1>
<p>How do you open it?</p>

直接看引入的js

1
2
3
4
5
6
7
8
9
10
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

function open(i) {
sleep(1).then(() => {
open(i + 1);
});
if (i == 4000000000) window.location = "/fight/";
}
7. /fight/

又是点击触发,js:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Run to scramble original flag
//console.log(scramble(flag, action));
function scramble(flag, key) {
for (var i = 0; i < key.length; i++) {
let n = key.charCodeAt(i) % flag.length;
let temp = flag[i];
flag[i] = flag[n];
flag[n] = temp;
}
return flag;
}

function check_action() {
var action = document.getElementById("action").value;
var flag = ["{hey", "_boy", "aaaa", "s_im", "ck!}", "_baa", "aaaa", "pctf"];

// TODO: unscramble function
}

“混淆”了flag,直接手解:pctf{hey_boys_im_baaaaaaaaaack!}

大佬的 python 脚本解法

1
2
3
4
5
6
7
8
9
10
#coding:utf-8
from itertools import permutations

flag = ["{hey", "_boy", "aaaa", "s_im", "ck!}", "_baa", "aaaa", "pctf"]

item = permutations(flag)
for i in item:
k = ''.join(list(i))
if k.startswith('pctf{hey_boys') and k[-1] == '}':
print(k)

用的全排列,🐂

参考文章:
qaq

作者

inanb

发布于

2021-08-16

更新于

2021-08-16

许可协议


:D 一言句子获取中...