1,移動時代的前端加密:王浩集使用 estools 輔助反混淆Javascriptchichou
其中提到的重要思想:
執(zhí)行代碼字符串的方式有:創(chuàng)建執(zhí)行;調用setTimeout()執(zhí)行;創(chuàng)建new function()執(zhí)行;使用dom事件執(zhí)行;
2,__defineGetter__:
Number.prototype.constructor.constructor:
3,實戰(zhàn):
1,小段代碼會通過eval或者function來執(zhí)行,可以通過修改eval和function的原型來直接執(zhí)行從而獲取內部邏輯.比如:
eval(function(p,a,c,k,e,d){e=function(c){return c};if(!''.replace(/^/,String)){while(c--){d[c]=k[c]||c}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('0 3(){2.1(\'這是準備用來做混淆的\')}0 5(){2.1(\'4 6 \')}',7,7,'function|log|console|test|haha|test2|hah'.split('|'),0,{}))
修改eval: eval = function() {
? console.log('eval', JSON.stringify(arguments));
};?
修改Function: Function = function() {
? console.log('Function', JSON.stringify(arguments));
? return function() {};
};
new Function(修改后的代碼字符串)();
截獲constructor: Function.prototype.__defineGetter__('constructor', function () {
? ? return function () {
? ? ? ? console.log('constructor', JSON.stringify(arguments));
? ? };
});
(function() {}).constructor('console.log("Hello world!")');