常规hook cookie失效,另类hook方法
var cookieDesc = Object.getOwnPropertyDescriptor(Document.prototype, 'cookie');
if (cookieDesc && cookieDesc.configurable) {
Object.defineProperty(document, 'cookie', {
get: function () {
return cookieDesc.get.call(document);
},
set: function (val) {
console.log(val);
debugger;
cookieDesc.set.call(document, val);
}
});
}
有时候拼接的匿名函数调用无限debugger 往上跟的函数一直被重写,可以hook Function
window.__cr_fun = window.Function;
var myfun = function(){
//var args = Array.prototype.slice.call(arguments, 0, -1).join(","), src = arguments[arguments.length - 1]
return window.__cr_fun.apply(this, arguments);
}
// 这里主要是屏蔽js中对原生函数native属性的检测
myfun.toString = function(){return window.__cr_fun + ""}
Object.defineProperty(window, 'Function', {value: myfun});
评论 (0)