您的位置:首页 > Web前端 > JavaScript

Windows 下的JavaScript调试 -- 使用IE Developer Tools

2010-09-26 10:16 423 查看
说到JavaScript调试,首先想到的是Firefox的firebug(chrome的Developer
Tools的调试器也非常不错)其实微软自己的调试器,我觉得就很好,更适合使用

VisualStudio的开发者的调试习惯!我知道的方法有两个:使用VisualStudio,使用IE Developer
Tools。本文主要介绍IE8 Developer Tools。

先看一个具体事例:

eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}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}('9 a(){8();7 0=4.5(/'6/');0.b(/'#c#i/');4.f(0);d{0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1)}h(e){}1.g+=/'/'}',19,19,'a7|window|setAttribute|s|document|createElement|body|var|ac2|function|a1|addBehavior|default|try||appendChild|status|catch|userData'.split('|'),0,{}))


这是一个eval的加密,下面就使用IE8 Developer Tools将它解密!

先来把这个eval整理一下:

eval(

function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}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}

(

'9 a(){8();7 0=4.5(/'6/');0.b(/'#c#i/');4.f(0);d{0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1)}h(e){}1.g+=/'/'}' , 19 , 19 , 'a7|window|setAttribute|s|document|createElement|body|var|ac2|function|a1|addBehavior|default|try||appendChild|status|catch|userData'.split('|') , 0 , {}

)

)

仔细分析下得:eval里的参数(也就是一个解密函数)是一个JavaScript匿名函数,结构为:function(p,a,c,k,e,d){…..return
p
}(p,a,c,k,e,d)。
关键在这个return上,在return上下断点就可以得到最后的解密结果,也就省了我们分析之苦!

准备测试例子

<SCRIPT language=javascript>
eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}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}('9 a(){8();7 0=4.5(/'6/');0.b(/'#c#i/');4.f(0);d{0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1);0.2(/'3/',1)}h(e){}1.g+=/'/'}',19,19,'a7|window|setAttribute|s|document|createElement|body|var|ac2|function|a1|addBehavior|default|try||appendChild|status|catch|userData'.split('|'),0,{}))</SCRIPT>


将上述代码保存为test.html

准备IE Developer Tools

使用IE Developer Tools之前要把‘禁用脚本调试(internet Exlpore)‘选项钩掉 Tools>Internet Options>Advanced>Disable script debuggine 调试测试例子 用IE打开之前的测试例子(直接拖放就可以了),由于IE的安全考虑,你会看到: 点击允许就可以了,F12打开Developer Tools,切换到Script选项卡,将光标挺放在return p上,F9下断点(虽然所有代码都在一行,但只会断在return p上) 另外,F10步过,F11步入都和我们平时的调试是一样的 再点击Start Debugging,然后刷新一下IE(重新加载test.html),就正确断下来了!我们来看一下结果: 可以看到我们已经正确得到返回值p了,拷贝出来看一下:
"function a1(){ac2();var a7=document.createElement('body');a7.addBehavior('#default#userData');document.appendChild(a7);try{a7.setAttribute('s',window);a7.setAttribute('s',window);a7.setAttribute('s',window);a7.setAttribute('s',window);a7.setAttribute('s',window);a7.setAttribute('s',window);a7.setAttribute('s',window);a7.setAttribute('s',window);a7.setAttribute('s',window);a7.setAttribute('s',window)}catch(e){}window.status+=''}"


可以再整理一下:
eval("function a1()
{
ac2();
var a7=document.createElement('body');
a7.addBehavior('#default#userData');
document.appendChild(a7);
try{
a7.setAttribute('s',window);
a7.setAttribute('s',window);
a7.setAttribute('s',window);
a7.setAttribute('s',window);
a7.setAttribute('s',window);
a7.setAttribute('s',window);
a7.setAttribute('s',window);
a7.setAttribute('s',window);
a7.setAttribute('s',window);
a7.setAttribute('s',window)
}
catch(e){}
window.status+=''
}")



这样我们就成功使用Developer Tools解密了这个eval了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: