用統計方法反推 JavaScript 壓縮程式的變數名稱

JavaScript 在正式提供服務時一般都會使用「YUI Compressor」、「UglifyJS」或是「Closure Compiler」壓縮後再拿到正式環境上使用,最主要的目的是為了降低網路傳輸量。

這些工具其中一個特點是,local function 與 local variable 會被較短的名字取代掉,這可以讓想要反組譯的人比較麻煩。

不過今天看到的這個工具可以解決「困擾」:「JSNice」。(在 Slashdot 上的「Machine Learning Used For JavaScript Code De-obfuscation」這篇看到的)

用統計方法去「猜測」這些 local function 與 local variable 應該叫什麼名字,讓人比較好理解。官方對準確度的說法是超過 60%:

In our experiments, we found JSNice to be effective for deobfuscating minified code. On average, more than 60% of the identifiers are recovered to the same name as before the minification process.

接下來會想辦法提供 UI 讓使用者可以選擇另外的名字:

Further, as JSNice computes multiple ranked suggestions, we provide a UI to navigate through these suggestions and select alternative identifier names.

先記錄起來,這網站很有趣,之後要 trace 別人的程式碼應該常常會用到 XDDD

2 thoughts on “用統計方法反推 JavaScript 壓縮程式的變數名稱”

  1. othree says:

    我一直以為是照順序 a, b, c, d 這樣給耶

  2. 琪琪 says:

    我是一個22歲的在校女學生

    覺得自身條件還算是ok的啦

    在網路尋找好心的人幫助呢

    我無靠行 單純個人租屋賺扣扣

    本人照 http://album.blog.yam.com/ntmd779

    喜歡我 對小妹有興趣 可賴我qq19921128

    地點

    不相信的那種大哥哥 就別找我

    因為小妹性格不好!! 不然直接刪除!!

Leave a Reply

Your email address will not be published. Required fields are marked *