Skip to content

Instantly share code, notes, and snippets.

@ultrafunkamsterdam
Last active June 2, 2021 20:18
Show Gist options
  • Save ultrafunkamsterdam/e86484eb826582169d744d1378df5cac to your computer and use it in GitHub Desktop.
Save ultrafunkamsterdam/e86484eb826582169d744d1378df5cac to your computer and use it in GitHub Desktop.
Modern bot detection mechanism (simplified) which is being used by all modern js challenges to check if running in a vm or automated way.
/* This work is part of research and development of the undetected-chromedriver
// https://github.com/UltrafunkAmsterdam/undetected-chromedriver
// in automation controlled browsers, doing the below evaluates c always to 0
// while the same on a regular browser causes c to always be non 0, albeight small ( ~ 0.0000497656 ) values, but not 0
//
// var a = performance.now() / 1000,
// b = performance.now() / 1000 ,
// c = b - a;
// console.log(c);
//
// c will always 0 on automation,vmware,or other virtual isolation.
//
// The below will loop repeating the test several times until a 0 is found and then break.
// This gives little more confidence.
*/
function _1337() {
function e(n, t) {
return n < 1e-8 ?
t :
n < t ?
e(t - Math.floor(t / n) * n, n) :
n == t ?
n : e(t, n)
}
for (var n = performance.now() / 1e3,
t = performance.now() / 1e3 - n,
r = 0; r < 10; r++)
t = e(t, performance.now() / 1e3 - n);
return Math.round(1 / t)
}
var _f = 0;
for (var x = 0; x < 25; x++) {
// the first to find 0 found will break the loop and output "automation controlled"
if (_1337() == Infinity) {
_f = 1;
// well, we found one. stop here, we don't need more evidence.
break;
}
}
alert(_f ? 'Using automation' : 'Not using automation');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment