Hook全局变量window中的key
// ==UserScript==
// @name Hook全局变量中的key
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author 各位老板
// @include *
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
//监控window(全局变量)中的 _t
var t = window._t;
var window_key = '_t';
var window_value = window[window_key];
Object.defineProperty(window, window_key, {
get: function() {
console.log('Getting window._t',window_value);
return t;
},
set: function(val) {
console.log('Setting window._t', val);
debugger;
t = val;
return t;
}
});
})();
HOOK加密函数,打印加密结果,加密函数内部调用的函数名
// ==UserScript==
// @name Hook
// @namespace http://tampermonkey.net/
// @version 0.1
// @description HOOK加密函数,打印加密结果,加密函数内部调用的函数名
// @author FY
// @include *
// @grant none
// @run-at document-end
// ==/UserScript==
(function() {
'use strict';
var source = ['decodeData','base64decode','md5','decode','btoa','MD5','RSA','AES','CryptoJS','encrypt','strdecode',"encode",'decodeURIComponent','_t','JSON.stringify','String.fromCharCode','fromCharCode'];
console.log("开始测试是否有解密函数");
let realCtx, realName;
function getRealCtx(ctx, funcName) {
let parts = funcName.split(".");
let realCtx = ctx;
for(let i = 0; i < parts.length - 1; i++) {
realCtx = realCtx[parts[i]];
}
return realCtx;
}
function getRealName(funcName) {
let parts = funcName.split(".");
return parts[parts.length - 1];
}
function hook(ctx, funcName, level, originFunc) {
ctx[funcName] = function(a){
console.log("level:" + level + " function:" + funcName,a);
let regexp = / [\S]*\(.*\)\;/g;
let match = originFunc.toString().match(regexp)
console.log(match);
debugger;
return originFunc(a);
};
}
function test(ctx, level) {
for(let i = 0; i < source.length; i++) {
let f = source[i];
let realCtx = getRealCtx(ctx, f);
let realName = getRealName(f);
let chars = realCtx[realName];
hook(realCtx, realName, level, chars);
}
}
test(window, 1);
})();