Windows 下的JavaScript調試 — 使用IE Developer Tools

來源:互聯網
上載者:User

說到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,{}))<br /> 

 


這是一個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><br />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,{}))<br /></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了。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.