Chrome 禁止调试

noDebugger.js

let onDebug = function () {
    document.write('检测到非法调试!请你停止调试后刷新本页面!');
};

setInterval(function () {
    let st, et;
    st = new Date().getTime();
    et = new Date().getTime();
    if ((et - st) > 1000) {
         onDebug();
    }
}, 1000);

document.onkeydown = document.onkeyup = document.onkeypress = function (event) {
    const e = event || window.event || arguments.callee.caller.arguments[0];

    if (e && e.keyCode == 123) {
         onDebug();
    }
};

let div = document.createElement('div');
Object.defineProperty(div, "id", {
    get: () => {
        clearInterval(loop);
        onDebug();
    }
});
let loop = setInterval(() => {
    console.log(div);
    console.clear();
});
(() => {
    function block() {
        setInterval(() => {
            debugger;
        }, 50);
    }
    try {
        block();
    } catch (err) {}
})();

禁止断点

添加条件断点 logpoint 为 false

添加忽略 add script ignore list 规则

(() => {
    function block() {
        setInterval(() => {debugger;}, 50);
    }
    try {
        block();
    } catch (err) {}
})();

(() => {
    function block() {
        setInterval(() => {
            Function("debugger")();
        }, 50);
    }
    try {
        block();
    } catch (err) {}
})();

  • 混淆之后的代码
eval(function(c,g,a,b,d,e){d=String;if(!"".replace(/^/,String)){for(;a--;)e[a]=b[a]||a;b=[function(f){return e[f]}];d=function(){return"\\\\w+"};a=1}for(;a--;)b[a]&&(c=c.replace(new RegExp("\\\\b"+d(a)+"\\\\b","g"),b[a]));return c}('(()=>{1 0(){2(()=>{3("4")()},5)}6{0()}7(8){}})();',9,9,"block function setInterval Function debugger 50 try catch err".split(" "),0,{}));

  • Function("debugger").call() 改成 (function(){return false;})["constructor"]("debugger")["call"](); 更不难识别代码
(() => {
    function block() {
        if (
            window.outerHeight - window.innerHeight > 200 ||
            window.outerWidth - window.innerWidth > 200
        ) {
            document.body.innerHTML =
                "检测到非法调试,请关闭后刷新重试!";
        }
        setInterval(() => {
            (function () {
                return false;
            }
                ["constructor"]("debugger")
                ["call"]());
        }, 50);
    }
    try {
        block();
    } catch (err) {}
})();

Notion – The all-in-one workspace for your notes, tasks, wikis, and databases.icon-default.png?t=M3K6https://serious-lose.notion.site/Chrome-noDebugger-js-17ff1e02847944ff9f852f8b4e12f495 

你可能感兴趣的:(Other,Javascript,javascript,前端,开发语言)