js-confuser
js-confuser copied to clipboard
Add CDP Signal Detection to Anti Debug
in Chrome, possible to detect when devtools is open by using the Runtime.enable event. for information, please read this article: How New Headless Chrome & the CDP Signal Are Impacting Bot Detection.
Here is a simple example that can detect if devtools is open (only chrome):
if (window.chrome) {
let r = Math.random() * 1000 | 0;
let r2 = Math.random() * 1000 | 0;
let _r = r;
try {
let err = new Error();
Object.defineProperty(err, "stack", {
configurable: false,
enumerable: false,
get: function () {
_r += r2;
return "";
}
});
// Dont remove this line
console.debug(err);
err.stack;
if (r + r2 !== _r) {
// Implement countermeasures here
console.log("DevTools detected!");
}
} catch (e) { }
}
Test on chrome 127:
https://github.com/user-attachments/assets/13fd7baf-9451-4206-aa71-9ab20bf72e4e