-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworker_chrome_driver.js
39 lines (35 loc) · 1.2 KB
/
worker_chrome_driver.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
const {
Worker, MessageChannel, MessagePort, isMainThread, parentPort
} = require('worker_threads');
const querystring = require("querystring");
require("chromedriver");
const {Builder, By, Key, until} = require('selenium-webdriver');
let driver;
parentPort.on("message", async ({port, creation_driver, quit, obj}) => {
if (creation_driver) {
driver = await new Builder().forBrowser('chrome').build();
port.postMessage({});
return;
}
if (quit) {
await driver.quit();
port.postMessage({});
return;
}
obj = JSON.parse(obj);
let html = `
<script>
location.reload = location.replace = alert = confirm = () => {};
window.testSuccess = false;
window.executeTest = () => testSuccess = true;
</script>
${obj.response.data}`;
try {
await driver.get(`data:text/html;charset=utf-8,${html}`);
let success = await driver.executeScript(() => testSuccess);
console.log(`${obj.response.status} ${obj.response.statusText}\t\t\t${obj.url}\t\t\t${success ? "SUCCESS" : "FAIL"}\t\t\t${obj.attack_param}\t\t\t${obj.attack_post}`);
}catch (e) {
console.log(`${obj.response.status} ${obj.response.statusText}\t\t\t${obj.url}\t\t\tFAIL\t\t\t${obj.attack_param}\t\t\t${obj.attack_post}`);
}
port.postMessage({});
});