-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathadminbot_test.js
53 lines (43 loc) · 1.4 KB
/
adminbot_test.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
// npm i puppeteer
// script to emulate admin bot
const puppeteer = require("puppeteer");
const FLAG = "SEKAI{testflag}";
const SITE = "http://localhost:1234";
const visit = async (url) => {
// here's a gift to you:
// flag format: ^SEKAI{[a-z]+}$
if (!/^SEKAI{[a-z]+}$/.test(FLAG)) {
console.log("warning: flag not in correct format");
}
let browser;
try {
browser = await puppeteer.launch({
headless: true,
pipe: true,
args: [
"--no-sandbox",
"--disable-setuid-sandbox",
"--js-flags=--noexpose_wasm,--jitless",
],
dumpio: true
});
let page = await browser.newPage();
await page.goto(SITE, { timeout: 3000, waitUntil: 'domcontentloaded' });
await page.evaluate((flag) => {
document.querySelector("input[type=text]").value = flag;
document.querySelector("input[type=submit]").click();
}, FLAG);
await page.waitForNavigation();
await page.close();
page = await browser.newPage();
await page.goto(url, { timeout: 3000, waitUntil: 'domcontentloaded' })
await page.waitForTimeout(40000);
await browser.close();
browser = null;
} catch (err) {
console.log(err);
} finally {
if (browser) await browser.close();
}
};
visit("TARGET_URL");