Skip to content

Instantly share code, notes, and snippets.

@tradertrue
Created May 18, 2022 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tradertrue/bd54eb4d2c714dd99847ac50922b50d2 to your computer and use it in GitHub Desktop.
Save tradertrue/bd54eb4d2c714dd99847ac50922b50d2 to your computer and use it in GitHub Desktop.
let initializationTs = -1
let trustedEventCounter = 0
let keydownEventCounter = 0
let keyupEventCounter = 0
let clickEventCounter = 0;
const signatureVersion = 8
h.initialize = function () {
initializationTs = window.Date.now();
window.addEventListener("mousemove", function (e) {
if (e.isTrusted) {
trustedEventCounter += 1
}
});
window.addEventListener("touchmove", function (e) {
if (e.isTrusted) {
trustedEventCounter += 1
}
});
window.addEventListener("keydown", function () {
keydownEventCounter += 1
});
window.addEventListener("keyup", function () {
keyupEventCounter += 1
});
window.addEventListener("click", function () {
clickEventCounter += 1
})
}
h.sign = function (mailCredential, signatureSecret, clientId) {
let userAgent = window.navigator.userAgent;
let automationCheck = 1;
if (window["document"]["$cdc_asdjflasutopfhvcZLmcfl_"]) {
automationCheck += 2;
}
if (window["document"]["documentElement"]["getAttribute"]("webdriver")) {
automationCheck += 4;
}
if (window["navigator"]["webdriver"]) {
automationCheck += 16;
}
if (window["location"].protocol !== "https:") {
automationCheck += 32;
}
if (window.eval("typeof process") !== "undefined") {
automationCheck += 64;
}
if (window.eval("typeof global") !== "undefined") {
automationCheck += 128;
}
if (window["eval"]("typeof readFully") !== "undefined") {
automationCheck += 256;
}
if (window["_Selenium_IDE_Recorder"]) {
automationCheck += 512;
}
if (window.document["__webdriver_script_fn"]) {
automationCheck += 1024;
}
let browserCheck = 1;
if (window.mozInnerScreenY) {
browserCheck += 2;
}
if (window["onoperacustomcontrol"] === null) {
browserCheck += 4;
}
if (window["msLaunchUri"]) {
browserCheck += 8;
}
if (window["safari"]) {
browserCheck += 16;
}
if (window.chrome) {
browserCheck += 32;
}
let executionTime = Date.now() - initializationTs;
let screenResolution = window["screen"]["width"] * window["screen"]["height"];
let pluginsCheck = 1024;
window.navigator.plugins.forEach((plugin) => {
if (plugin.name === "Chromium PDF Viewer") {
pluginsCheck += 1;
}
if (plugin.name === 'Chrome PDF Viewer') {
pluginsCheck += 2;
}
if (plugin.name === "Native Client") {
pluginsCheck += 4;
}
if (plugin.name === "Widevine Content Decryption Module") {
pluginsCheck += 8;
}
if (plugin.name === "Chrome PDF Plugin") {
pluginsCheck += 16;
}
if (plugin.name === "Java Applet Plug-in") {
pluginsCheck += 32;
}
if (plugin.name === 'Shockwave Flash') {
pluginsCheck += 64;
}
if (plugin.name === "Edge PDF Viewer") {
pluginsCheck += +"128";
}
if (plugin.name === "WebKit built-in PDF") {
pluginsCheck += +"256";
}
})
let signatureString = [
browserCheck,
automationCheck,
executionTime,
trustedEventCounter,
screenResolution,
pluginsCheck,
keyupEventCounter,
keydownEventCounter
]["join"]('-');
let a = clientId + signatureVersion + signatureString + userAgent + mailCredential + signatureSecret + signatureString + clientId;
var b = window.unescape(window.encodeURIComponent(a));
let signatureHash = 8011470;
for (let i = 0; i < b.length; i += 1) {
signatureHash = (signatureHash >> 1) + ((1 & signatureHash) << 23);
signatureHash += b.charCodeAt(i);
signatureHash &= 16777215;
}
return (
signatureVersion + ':' + signatureString + ':' + signatureHash.toString(16) + ':' + clickEventCounter
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment