48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
// bot/admin.js
|
|
const puppeteer = require('puppeteer');
|
|
const yargs = require('yargs/yargs');
|
|
const { hideBin } = require('yargs/helpers');
|
|
|
|
const argv = yargs(hideBin(process.argv)).options({
|
|
base: { type: 'string', default: 'http://127.0.0.1:80' },
|
|
token: { type: 'string', demandOption: true },
|
|
wait: { type: 'number', default: 3000 }
|
|
}).argv;
|
|
|
|
// Use system chromium installed by apt
|
|
const executablePath = process.env.PUPPETEER_EXECUTABLE_PATH || '/usr/bin/chromium';
|
|
|
|
(async () => {
|
|
const browser = await puppeteer.launch({
|
|
headless: true,
|
|
executablePath,
|
|
args: ['--no-sandbox','--disable-setuid-sandbox','--disable-dev-shm-usage','--disable-gpu']
|
|
});
|
|
try {
|
|
const page = await browser.newPage();
|
|
|
|
page.on('request', r => {
|
|
const u = r.url();
|
|
if (u.includes('collect') || u.includes('exfil') || u.includes('?c=') || u.includes('&c=')) {
|
|
console.log('[exfil-request]', u);
|
|
}
|
|
});
|
|
|
|
const login = `${argv.base.replace(/\/$/,'')}/admin_login?token=${encodeURIComponent(argv.token)}`;
|
|
const post = `${argv.base.replace(/\/$/,'')}/post/1`;
|
|
|
|
console.log('[admin-bot] login', login);
|
|
await page.goto(login, { waitUntil: 'networkidle2', timeout: 20000 });
|
|
|
|
console.log('[admin-bot] post', post);
|
|
await page.goto(post, { waitUntil: 'networkidle2', timeout: 20000 });
|
|
|
|
await new Promise(res => setTimeout(res, argv.wait));
|
|
} finally {
|
|
await browser.close();
|
|
}
|
|
})().catch(e => {
|
|
console.error('[admin-bot] error', e);
|
|
process.exit(1);
|
|
});
|