akamai-sensordata-generator/sensorData.js

140 lines
6.7 KiB
JavaScript

/*
* ByePASS by Moony
* Version 1.0.0
* This file processes and decrypts the sensor data.
*/
const request = require('request');
var beautify = require('js-beautify').js;
module.exports = {
grab: (urls, cocaine, hostName, callback) => {
url = new URL(urls);
getUrl = hostName ? `${url.protocol}//${url.hostname}` : urls;
request.get(getUrl, {
headers: {
ACCEPT: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'ACCEPT-ENCODING': 'gzip, deflate, br',
'ACCEPT-LANGUAGE': 'en-US,en;q=0.9',
'HOST': url.hostname,
'SEC-FETCH-MODE': 'navigate',
'SEC-FETCH-SITE': 'none',
'SEC-FETCH-USER': '?1',
'UPGRADE-INSECURE-REQUESTS': 1,
'USER-AGENT': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36',
cookie: cocaine
},
encoding: null,
gzip: true,
jar: request.jar()
}, (err, resp) => {
if (err != null) {
console.log(err);
} else {
let pattern = /var _cf = _cf.*?><script type=".*? src=\"(.*?)\"/g;
let match = pattern.exec(resp.body);
if (match[1]) {
let scriptUrl = `${url.protocol}//${url.hostname}${match[1]}`
getScript(scriptUrl, (e) => { return callback({err: false, d: e, url: scriptUrl }); });
}
else
return callback({err: true, d:"Couldn't find akamai script."});
}
});
},
/* grabScriptUrl: (urls, cocaine, callback) => {
console.log(urls)
url = new URL(urls);
request.get(url, {
headers: {
ACCEPT: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng;q=0.8,application/signed-exchange;v=b3;q=0.9',
'ACCEPT-ENCODING': 'gzip, deflate, br',
'ACCEPT-LANGUAGE': 'en-US,en;q=0.9',
'HOST': url.hostname,
'SEC-FETCH-MODE': 'navigate',
'SEC-FETCH-SITE': 'none',
'SEC-FETCH-USER': '?1',
'UPGRADE-INSECURE-REQUESTS': 1,
'USER-AGENT': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36',
cookie: cocaine
},
encoding: null,
gzip: true,
jar: request.jar()
}, (err, resp, bd) => {
if (err != null) {
console.log(err);
} else {
let pattern = /var _cf = _cf.*?><script type=".*? src=\"(.*?)\"/g;
let match = pattern.exec(resp.body);
if(!match) return callback(null);
return callback(`${url.protocol}//${url.hostname}` + match[1]);
}
});
} */
};
function replaceStuff(script, url, protocol)
{
script = script.replace(`bmak["pen"] = window["_phantom"] ? 1 : 0, bmak["wen"] = window["webdriver"] ? 1 : 0, bmak["den"] = window["domAutomation"] ? 1 : 0`, `bmak["pen"] = 0, bmak["wen"] = 0, bmak["den"] = 0`);
script = script.replace(`a = window["\$cdc_asdjflasutopfhvcZLmcfl_"] || document["\$cdc_asdjflasutopfhvcZLmcfl_"] ? "1" : "0";`, `"0"`);
script = script.replace(`t = null != window["document"]["documentElement"]["getAttribute"]("webdriver") ? "1" : "0"`, `t = null != "0";`);
script = script.replace(`e = void 0 !== navigator["webdriver"] && navigator["webdriver"] ? "1" : "0";`, `e = void 0 !== "0";`);
script = script.replace(`n = void 0 !== window["webdriver"] ? "1" : "0";`, `n = void 0 !== "0";`);
script = script.replace(`o = void 0 !== window["XPathResult"] || void 0 !== document["XPathResult"] ? "1" : "0";`, `o = void 0 !== "0";`);
script = script.replace(`m = null != window["document"]["documentElement"]["getAttribute"]("driver") ? "1" : "0";`, `m = null != "0";`);
script = script.replace(`return r = null != window["document"]["documentElement"]["getAttribute"]("selenium") ? "1" : "0", [a, t, e, n, o, m, r]["join"](",")`, `return r = null != 0, [a, t, e, n, o, m, r].join(",");`);
script = script.replace(`return bmak["enReadDocUrl"] ? document["URL"]["replace"](/\\\\|"/g, "") : ""`, `return "${url}"`);
script = script.split(`document["location"]["protocol"]`).join(`"${protocol}"`)
script = script.split(`document["location"]["hostname"]`).join(`"${url}"`)
script = script.replace(`var o = "{"sensor_data":"" + bmak["sensor_data"] + ""}";`, `var o = \`{"sensor_data":"\` + bmak["sensor_data"] + \`"}\`;`)
script = script.replace(`t["fpValstr"] = e["replace"](/\\"/g, "\\\\"");`, `t["fpValstr"] = e["replace"](/\"/g, "\\\\\\\\\\"");`);
script = script.replace(`bmak["auth"] = ","auth" : "" + n + """, e["setRequestHeader"] && (e["setRequestHeader"]("Content-type", "application/json"), e["setRequestHeader"]("Authorization", "Basic " + n), bmak["auth"] = "");`, `bmak["auth"] = ",\\"auth\\" : \\"" + n + "\\"", e.setRequestHeader && (e.setRequestHeader("Content-type", "application/json"), e.setRequestHeader("Authorization", "Basic " + n), bmak["auth"] = "");`);
script = script.replace(`var o = "{"session_id" : "" + bmak["session_id"] + "","sensor_data" : "" + bmak["sensor_data"] + """ + bmak["auth"] + "}";`, `var o = "{\\"session_id\\" : \\"" + bmak["session_id"] + "\\",\\"sensor_data\\" : \\"" + bmak["auth"] + "\\"" + bmak["auth"] + "}";`)
return script;
}
function getScript(url, cb)
{
var uri = new URL(url);
request.get(url, {
headers: {
ACCEPT: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'ACCEPT-ENCODING': 'gzip, deflate, br',
'ACCEPT-LANGUAGE': 'en-US,en;q=0.9',
'HOST': uri.hostname,
'SEC-FETCH-MODE': 'navigate',
'SEC-FETCH-SITE': 'none',
'SEC-FETCH-USER': '?1',
'UPGRADE-INSECURE-REQUESTS': 1,
'USER-AGENT': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36',
cookie: ''
},
gzip: true
}, (err, resp) => {
if (err != null) {
console.log(err);
}
else {
let pretty = beautify(resp.body, { indent_size: 2, space_in_empty_paren: true, unescape_strings: true });
let arrayPattern = /var _ac = (\[.*?])/g;
let array = arrayPattern.exec(pretty)[1];
let _ac = eval(array);
let pattern = /_ac\[([0-9]+)\]/g;
var matches;
while (matches = pattern.exec(pretty)) {
pretty = pretty.split(matches[0]).join(`"${_ac[matches[1]]}"`)
}
pretty = pretty.replace(array, '[]')
pretty = replaceStuff(pretty, uri.hostname, uri.protocol);
return cb(pretty)
}
});
}