爬虫前端反反调试的油猴脚本

 debugger作用

某些网站抓取调试分析的时候,打开chrome的控制台,会无限debug暂停,导致我们无法调试。

debugger原理

目标网站后端在开发的时候在前端代码里面“反调试”,在代码里面插入了很多这种代码:

debugger

出现以下情况

反调试油猴脚本

// ==UserScript==
// @name         Anti Anti-debugger
// @namespace    http://tampermonkey.net/
// @version      1
// @description  Stops most anti debugging implementations by JavaScript obfuscaters
// @author       ww
// @match        *
// @grant        unsafeWindow
// @run-at       document-start
// ==/UserScript==

(function() {
    var _constructor = unsafeWindow.Function.prototype.constructor;
    // Hook Function.prototype.constructor
    unsafeWindow.Function.prototype.constructor = function() {
        var fnContent = arguments[0];
        if (fnContent) {
            if (fnContent.includes('debugger')) { // An anti-debugger is attempting to stop debugging
                var caller = Function.prototype.constructor.caller; // Non-standard hack to get the function caller
                var callerContent = caller.toString();
                if (callerContent.includes(/\bdebugger\b/gi)) { // Eliminate all debugger statements from the caller, if any
                    callerContent = callerContent.replace(/\bdebugger\b/gi, ''); // Remove all debugger expressions
                    eval('caller = ' + callerContent); // Replace the function
                }
                return (function () {});
            }
        }
        // Execute the normal function constructor if nothing unusual is going on
        return _constructor.apply(this, arguments);
    };
})();

在油猴里安装以上脚本,可以去除掉代码里面的debugger

  • 6
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值