一.js hook 过无限debugger
var _constructor = constructor;
Function.prototype.constructor = function(s) {if (s == "debugger") {console.log(s);return null;}return _constructor(s);
}//去除无限debugger
Function.prototype.__constructor_back = Function.prototype.constructor ;
Function.prototype.constructor = function() {if(arguments && typeof arguments[0]==='string'){//alert("new function: "+ arguments[0]);if( "debugger" === arguments[0]){// arguments[0]="consoLe.Log(\"anti debugger\");";//arguments[0]=";";return}}return Function.prototype.__constructor_back.apply(this,arguments);
};var _Function = Function;
Function = function(s) {if (s == "debugger") {console.log(s);return null;}return _Function(s);
}
二.过debugger—1 constructor 构造器构造出来的
var _constructor = constructor;
Function.prototype.constructor = function(s) {if (s == "debugger") {console.log(s);return null;}return _constructor(s);
}
三.过debugger—2 eval的
(function() {'use strict';var eval_ = window.eval;window.eval = function(x) {eval_(x.replace("debugger;", " ; "));};window.eval.toString = eval_.toString;
}
)();
四.过debugger 阿布牛逼
function Closure(injectFunction) {return function() {if (!arguments.length)return injectFunction.apply(this, arguments)arguments[arguments.length - 1] = arguments[arguments.length - 1].replace(/debugger/g, "");return injectFunction.apply(this, arguments)}
}var oldFunctionConstructor = window.Function.prototype.constructor;
window.Function.prototype.constructor = Closure(oldFunctionConstructor)
//fix native function
window.Function.prototype.constructor.toString = oldFunctionConstructor.toString.bind(oldFunctionConstructor);var oldFunction = Function;
window.Function = Closure(oldFunction)
//fix native function
window.Function.toString = oldFunction.toString.bind(oldFunction);var oldEval = eval;
window.eval = Closure(oldEval)
//fix native function
window.eval.toString = oldEval.toString.bind(oldEval);// hook GeneratorFunction
var oldGeneratorFunctionConstructor = Object.getPrototypeOf(function*() {}).constructor
var newGeneratorFunctionConstructor = Closure(oldGeneratorFunctionConstructor)
newGeneratorFunctionConstructor.toString = oldGeneratorFunctionConstructor.toString.bind(oldGeneratorFunctionConstructor);
Object.defineProperty(oldGeneratorFunctionConstructor.prototype, "constructor", {value: newGeneratorFunctionConstructor,writable: false,configurable: true
})// hook Async Function
var oldAsyncFunctionConstructor = Object.getPrototypeOf(async function() {}).constructor
var newAsyncFunctionConstructor = Closure(oldAsyncFunctionConstructor)
newAsyncFunctionConstructor.toString = oldAsyncFunctionConstructor.toString.bind(oldAsyncFunctionConstructor);
Object.defineProperty(oldAsyncFunctionConstructor.prototype, "constructor", {value: newAsyncFunctionConstructor,writable: false,configurable: true
})// hook dom
var oldSetAttribute = window.Element.prototype.setAttribute;
window.Element.prototype.setAttribute = function(name, value) {if (typeof value == "string")value = value.replace(/debugger/g, "")// 向上调用oldSetAttribute.call(this, name, value)
}
;
var oldContentWindow = Object.getOwnPropertyDescriptor(HTMLIFrameElement.prototype, "contentWindow").get
Object.defineProperty(window.HTMLIFrameElement.prototype, "contentWindow", {get() {var newV = oldContentWindow.call(this)if (!newV.inject) {newV.inject = true;core.call(newV, globalConfig, newV);}return newV}
})
转载地址:https://www.cnblogs.com/xiaoweigege/p/14954648.html