V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
546669204
V2EX  ›  分享创造

如何解决反调试困扰-反反反反反反反调试-让我们用一个插件搞定

  •  
  •   546669204 · 2020-01-07 13:41:58 +08:00 · 2695 次点击
    这是一个创建于 1563 天前的主题,其中的信息可能已经有所发展或是发生改变。

    fuck-debugger-extensions

    简介

    这个拓展是一个 反反反调试框架

    当看到一段漂亮代码的时候 发现有反调试 卡浏览器 死机 这个时候就很不爽了。

    拥有这个插件 就可以解决问题于无形之中。

    主要解决问题

    1. 基于 console 的 devtool 检测
    2. 基于 pushState 的卡浏览器
    3. 基于 debugger 的卡浏览器 检测 devtool
    4. 基于 regexp 的代码风格检测

    安装和使用

    下载

    cd ~
    git clone https://github.com/546669204/fuck-debugger-extensions.git
    
    

    安装

    1. Navigate to chrome://extensions in your browser. You can also access this page by clicking on the Chrome menu on the top right side of the Omnibox, hovering over   **More Tools** and selecting **Extensions**.  
    2. Check the box next to **Developer Mode**.  
    3. Click **Load Unpacked Extension** and select the directory for your "Hello Extensions" extension.
    
    Congratulations! 
    

    使用

    地址栏右侧找到拓展 点击 配置 功能选项 刷新即可

    快捷键 Alt+Shift+D 开启请求拦截功能

    原理详解

    使用 console.log 来判断是否打开开发者工具

    //方法 1
    var x = document.createElement('div');
    Object.defineProperty(x, 'id', {
        get:function(){
            // 开发者工具被打开
        }
    });
    console.log(x);
    //方法 2
    var c = new RegExp("1");
    c.toString = function(){
      // 开发者工具被打开
    }
    console.log(c);
    

    直接 hook console 对象 让所有输出失效


    使用 debugger 语句判断是否打开开发者工具 和 无限循环 debugger 卡机

    var startTime = new Date();
    debugger;
    var endTime = new Date();
    var isDev = endTime - startTime >100;
    
    while(true){
      debugger;
    }
    
    // debugger 的另一种实现方式
    (function(){}).constructor("debugger")()
    
    

    静态 debugger
    使用 chrome protocol 拦截所有请求 修改返回值

    动态 debugger
    hook 了 Function.protype.constructor 替换所有的 debugger 字符


    基于 regexp 的代码格式化检测

    new RegExp(`\\w+ *\\(\\) *{\\w+ *['|"].+['|"];? *}`).test((function(){return "dev"}).toString())
    

    目前的解决方案是 hook regexp 当触发 apply 函数的时候 参数等于给定值 返回空 regexp


    chrome protocol

    大概流程

    1. chrome.debugger.attach 注入指定 tabId
    2. 监听 chrome.debugger.onEvent 获取返回值
    3. 发送 Fetch.enable 开启请求拦截器
    4. 在事件 Fetch.requestPaused 中修改 response 返回结果
    5. OK !

    该功能使用了 chrome 实验特性 需要新版 chrome

    利用 chrome protocol 还能做到更多

    其他

    如果在使用中遇到问题和建议可以提 issuse 与我们进行联系;

    如果有更好的想法可以参与进来。


    该项目不倡导去破解他人项目来谋取利益。仅做学术研究使用。

    毕竟代码运行在客户端。如果有价值,只要花功夫。都是可以被人攻破的。

    建议把不重要的代码放在客户端。

    项目地址

    https://github.com/546669204/fuck-debugger-extensions/blob/master/README.zh-CN.md

    3 条回复    2020-12-10 09:28:00 +08:00
    yuuko
        1
    yuuko  
       2020-01-07 20:35:35 +08:00 via Android
    滋磁
    Smilecc
        2
    Smilecc  
       2020-01-08 14:14:31 +08:00
    滋磁 x2
    JinTianYi456
        3
    JinTianYi456  
       2020-12-10 09:28:00 +08:00
    感谢分享
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5425 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 07:15 · PVG 15:15 · LAX 00:15 · JFK 03:15
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.