李恒道 发表于 2024-7-21 04:55:12

disable-devtool防控制台解除

测试地址https://tongcheng360.com/
堆栈回溯可以拿到
```
A = window.setInterval(function() {
                        if (!(e.isSuspend || l || D())) {
                            var t, n, i = f(U);
                            try {
                              for (i.s(); !(t = i.n()).done; ) {
                                    var o = t.value;
                                    L = !1,
                                    o.detect(q++)
                              }
                            } catch (e) {
                              i.e(e)
                            } finally {
                              i.f()
                            }
                            T(),
                            "function" == typeof d.ondevtoolclose && (n = j,
                            !_() && n && d.ondevtoolclose())
                        }
                  }, d.interval),
```
根据代码特征很像这个库
https://link.zhihu.com/?target=https%3A//github.com/theajack/disable-devtool
!(data/attachment/forum/202407/21/045453trx8w828tp59585w.webp)
先不思考太多,我们先一处一处过,首先对setInterval进行hook,对函数进行toString来检测

代码如下
```
// ==UserScript==
// @name         Pass Console
// @namespace    https://bbs.tampermonkey.net.cn/
// @version      0.1.0
// @descriptiontry to take over the world!
// @author       You
// @match      https://tongcheng360.com/*
// @run-at       document-start
// @grant      none
// ==/UserScript==

const originSetInterval = window.setInterval

window.setInterval = function (func, time) {
    if (func.toString().indexOf('ondevtoolclose') !== -1) {
      return -1
    }
    return originSetInterval.call(this, func, time)
}
```
测试一下,结果发现只有这一个地方检测
!(data/attachment/forum/202407/21/045510xipo33igb5cgpbmf.webp)

潘钜森 发表于 2024-7-21 13:29:51

ggnb!
页: [1]
查看完整版本: disable-devtool防控制台解除