现在很多网站都会加一些骚操作来限制逆向,无限debugger就是其中的一种,废话不多说直接开始吧!下面是我暂时遇到的几种常见的做法。
一、使用setInterval、setTimeout来定时运行含有debugger的方法
例如:
setInterval(function(){debugger})
setTimeout也是类似的写法,这种比较简单,可以直接将这两个函数重写,不过要注意这两个函数是不是没有意义的,不然就需要定制性的重写才行。
重写:
window.setInterval = function(){return {unref: function(){}}}
window.setTimeout = function(){}
这里多了一个返回值,是因为我碰到的这个站需要这个返回值才能通过,相当于做了简单定制化。
二、使用Function做一些手脚
例如:
Function.constructor("debugger").call("action")
一般这种代码都是会被混淆的,记得大概长这样就行了,碰到这种通过的方法也不难,就按下面这样写就行了。
window._constructor = window.Function.prototype.constructor
Object.defineProperty(window.Function.prototype, "constructor", {
configurable: false,
enumerable: false,
value: function constructor(){
if (arguments[0] == "debugger" || arguments[0] == 'while (true) {}'){
return
}
if (arguments[0] == 'return /" + this + "/'){
return function name() {
return /" + this + "/
}
}
return window._constructor.apply(this, arguments)},
writable: true
});
还有些网站里面会夹带了一些骚操作来阻碍我们逆向的,上面是我遇到的,顺便也写上去了,可以做为参考。
三、检测重写后的Function的bind方法
一般我们重写之后是没有bind方法的,所以就需要重新加上去。
window.Function.prototype.constructor.prototype.bind = function(){var aa = function(){}; aa.prototype.bind=function(){}; return aa}
虽然这样写的并不优雅,还有可能被检测,不过搞这些东西都是需要见招拆招的,凑合用吧。还有这个bind不一定就是在我上面这种,但应该相差不多。
最后想说的是,上面这几种比较常见的了,再遇到其他的无限debugger,应该都可以触类旁通了。如果觉得我写的不行,就当做一个笑话就行了,不喜勿喷哈!就当做随便聊聊而已。