-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhint.js
82 lines (70 loc) · 2.52 KB
/
hint.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
const sleep = time => new Promise(resolve => setTimeout(resolve, time));
// not the actual admin bot script
// but basically the same :>
// npm install puppeteer
const puppeteer = require("puppeteer");
const BASE = "https://blogme.be.ax"
const FLAG = "corctf{ult1mate_x55_g0d!!!}";
const USER = "test_user";
const PASS = "test_pass";
const visit = (id) => {
let browser, page;
return new Promise(async (resolve, reject) => {
try {
browser = await puppeteer.launch({
headless: true,
pipe: true,
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--js-flags=--noexpose_wasm'
],
dumpio: true
});
page = await browser.newPage();
await page.goto(BASE + "/api/login", {
waitUntil: "networkidle2"
});
await page.evaluate((user, pass) => {
document.querySelector("input[name=user]").value = user;
document.querySelector("input[name=pass]").value = pass;
document.querySelector("button[type=submit].btn-primary").click();
}, USER, PASS);
await page.waitForNavigation();
await page.goto(BASE + "/post/" + id, {
waitUntil: "networkidle2"
});
await page.waitForNavigation();
await page.goto(BASE + "/api/comment/" + id, {
waitUntil: "networkidle2"
});
let responses = [
"wow!!!",
"amazing!!!",
"very cool!",
"uhhh... okay?",
":lemonthink:",
"cool i guess?",
"why did you send me this?"
];
let response = responses[Math.floor(Math.random()*responses.length)]
response += " " + FLAG;
await page.evaluate(response => {
document.querySelector("textarea[name=text]").value = response;
document.querySelector("button[type='submit'].btn-primary").click();
}, response);
await page.waitForNavigation();
await page.close();
page = null;
await browser.close();
browser = null;
} catch (err) {
console.log(err);
} finally {
if (page) await page.close();
if (browser) await browser.close();
resolve();
}
});
};
visit("post-id");