-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathadmin-bot.js
66 lines (54 loc) · 1.39 KB
/
admin-bot.js
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
import flag from './flag.txt';
function sleep(time) {
return new Promise((resolve) => {
setTimeout(resolve, time);
});
}
export default {
id: 'no-cookies',
name: 'no-cookies',
urlRegex:
/^https:\/\/no-cookies-[a-f0-9]{16}\.mc\.ax\/view\?id=[a-f0-9]{32}$/,
timeout: 10000,
extraFields: [
{
name: 'instance',
displayName: 'Instance ID',
placeholder: 'no-cookies-{THIS}.mc.ax',
regex: '^[0-9a-f]{16}$',
},
],
handler: async (url, ctx, { instance }) => {
const page = await ctx.newPage();
const doLogin = async (username, password) => {
return new Promise((resolve) => {
page.once('dialog', (first) => {
page.once('dialog', (second) => {
second.accept(password);
});
first.accept(username);
resolve();
});
});
};
// make an account
const username = Array(32)
.fill('')
.map(() => Math.floor(Math.random() * 16).toString(16))
.join('');
const password = flag;
const firstLogin = doLogin(username, password);
try {
page.goto(`https://no-cookies-${instance}.mc.ax/register`);
} catch {}
await firstLogin;
await sleep(3000);
// visit the note and log in
const secondLogin = doLogin(username, password);
try {
page.goto(url);
} catch {}
await secondLogin;
await sleep(3000);
},
};