MichaelXF / js-confuser

JS-Confuser is a JavaScript obfuscation tool to make your programs *impossible* to read.
https://js-confuser.com
MIT License
241 stars 36 forks source link

Add CDP Signal Detection to Anti Debug #138

Open youdie323323 opened 3 months ago

youdie323323 commented 3 months ago

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

doctor8296 commented 3 months ago

There is a lot other methods to check for devtool: https://github.com/AEPKILL/devtools-detector

MichaelXF commented 3 months ago

Great find, this can be added

Mrgaton commented 1 month ago

Great find, this can be added

you could add to run your custom script or function or to do a custom action

doctor8296 commented 2 weeks ago

Great find, this can be added

you could add to run your custom script or function or to do a custom action

I am still waiting for custom string manipulation functions :(