找回密码
 注册

QQ登录

只需一步,快速开始

查看: 494|回复: 1

Decompressing (p,a,c,k,e,d) Javascript Files

[复制链接]
发表于 2013-9-23 13:49:04 | 显示全部楼层 |阅读模式
Now, I know why most people compress they’re js files, because they don’t won’t people to steal the code, but it must be the case that sometimes, like what happened to me today, you’ve just gotta crack that encryption. I’m a bit worried about posting this, so I hope it’s in someway new and/or useful.
Basically we need to go into a js file that was given to us, in order to change a few DOM-based functions. I opened up the file, and lo and behold, this was the first few characters…
eval(function(p,a,c,k,e,d){…
This is the trademark sign of the packer by Dean Edwards. I’d seen this a few more times, and used it myself too, but never had to decode it before. So I did a little searching and found a nice method of decoding it:





  • Use the bookmarklet found here whilst on the packer encode/decode page. This will enable the decode button and remove the read-only limitation on the bottom text area.
  • Paste your encoded code into the bottom textarea and press decode. In theory, you should get the original code, but without line breaks, whitespace etc.
  • a better beautifer JS Beautifier, so use this to re-add the whitespace.

So yeah, that’s how to decode the p,a,c,k,e,r compressor. Theres other ways too, apparently replacing the eval function with alert works too, didn’t seem too for me unfortunately.

from: RedRoot


反編譯 eval(function(p,a,c,k,e,d) 格式的 Javascript

今天開始研究 Ajaxplorer 這個 Open Source Project,結果令人傻眼的居然將關鍵的 ajaxplorer.js 給編碼了,他採用的是 Dran Edwards 所提供的編碼方式,還好[1] 提供了解碼方式,我將他稍微修改整理成如下步驟(我用 FF3.5)





  • 連線到 http://dean.edwards.name/packer/
  • 將 javascript:for%20(i=0;i<document.forms.length;++i)%20{for(j=0;j<document.forms[ i].elements.length;++j){document.forms[ i].elements[j].removeAttribute(%22readonly%22);document.forms[ i].elements[j].removeAttribute(%22disabled%22);}} 貼到網址列並執行
  • 將編碼的 js 複製到下方的文字方塊並執行「Decode」
  • 複製下方解碼厚的內容
  • 連線到 http://tool.chinaz.com/Tools/JsFormat.aspx
  • 將解碼後的程式碼貼在文字方塊
  • 執行格式化
  • 複製格式化結果
  • 完成
備註:[1] 有使用 Javascript Tidy 進行後處理,可是我的測試結果是會導致 js 錯誤

2013/1/30 更新
新版混淆方式破解可參考 [2],可將 “while(c–){if(k[c]){p=p.replace(new egExp(‘\\b’+e(c)+’\\b’,'g’),k[c])}}return p"片段的 return p 改為 console.log(p) 即可取得 source code, 在透過 jsFormat 就可完全還原

參考資料
[1] http://www.red-root.com/code/decompressing-packed-javascript-files/
[
2] http://www.cnblogs.com/wangchunm ... /04/01/2429455.html

From Chui-Wen Chiu's Note
发表于 2013-9-23 14:06:20 | 显示全部楼层

sample code

本帖最后由 MySense 于 2013-9-23 14:13 编辑

This codes decoded from canadadebtsupport.com

It will pop up a farewell window when viewer palns leaving the webpage without click the submit buttom.
  1. var Move = {
  2.     browserHeight: function () {
  3.         if (typeof window.innerWidth == 'number') {
  4.             return window.innerHeight - 2
  5.         } else {
  6.             if (document.documentElement && document.documentElement.clientHeight) {
  7.                 return document.documentElement.clientHeight
  8.             } else {
  9.                 if (document.body && document.body.clientHeight) {
  10.                     return document.body.clientHeight
  11.                 }
  12.             }
  13.         }
  14.     },
  15.     browserWidth: function () {
  16.         if (typeof window.innerWidth == 'number') {
  17.             return window.innerWidth - 2
  18.         } else {
  19.             if (document.documentElement && document.documentElement.clientWidth) {
  20.                 return document.documentElement.clientWidth
  21.             } else {
  22.                 if (document.body && document.body.clientWidth) {
  23.                     return document.body.clientWidth
  24.                 }
  25.             }
  26.         }
  27.     }
  28. };
  29. var actionTemplate;
  30. var actionWidth, actionHeight, actionLeft, actionTop, actionColor, actionEffect, actionTimeout, actionLimit, actionDelay;
  31. var actionThanks, actionRedirect;
  32. var actionAffiliate;
  33. var actionShowClose;
  34. (function () {
  35.     var _jQuery = window.jQuery,
  36.         _$ = window.$;
  37.     var jQuery = window.jQuery = window.$ = function (selector, context) {
  38.         return new jQuery.fn.init(selector, context)
  39.     };
  40.     var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/,
  41.         isSimple = /^.[^:#\[\.]*$/,
  42.         undefined;
  43.     jQuery.fn = jQuery.prototype = {
  44.         init: function (selector, context) {
  45.             selector = selector || document;
  46.             if (selector.nodeType) {
  47.                 this[0] = selector;
  48.                 this.length = 1;
  49.                 return this
  50.             }
  51.             if (typeof selector == "string") {
  52.                 var match = quickExpr.exec(selector);
  53.                 if (match && (match[1] || !context)) {
  54.                     if (match[1]) selector = jQuery.clean([match[1]], context);
  55.                     else {
  56.                         var elem = document.getElementById(match[3]);
  57.                         if (elem) {
  58.                             if (elem.id != match[3]) return jQuery().find(selector);
  59.                             return jQuery(elem)
  60.                         }
  61.                         selector = []
  62.                     }
  63.                 } else return jQuery(context).find(selector)
  64.             } else if (jQuery.isFunction(selector)) return jQuery(document)[jQuery.fn.ready ? "ready" : "load"](selector);
  65.             return this.setArray(jQuery.makeArray(selector))
  66.         },
  67.         jquery: "1.2.6",
  68.         size: function () {
  69.             return this.length
  70.         },
  71.         length: 0,
  72.         get: function (num) {
  73.             return num == undefined ? jQuery.makeArray(this) : this[num]
  74.         },
  75.         pushStack: function (elems) {
  76.             var ret = jQuery(elems);
  77.             ret.prevObject = this;
  78.             return ret
  79.         },
  80.         setArray: function (elems) {
  81.             this.length = 0;
  82.             Array.prototype.push.apply(this, elems);
  83.             return this
  84.         },
  85.         each: function (callback, args) {
  86.             return jQuery.each(this, callback, args)
  87.         },
  88.         index: function (elem) {
  89.             var ret = -1;
  90.             return jQuery.inArray(elem && elem.jquery ? elem[0] : elem, this)
  91.         },
  92.         attr: function (name, value, type) {
  93.             var options = name;
  94.             if (name.constructor == String)
  95.                 if (value === undefined) return this[0] && jQuery[type || "attr"](this[0], name);
  96.                 else {
  97.                     options = {};
  98.                     options[name] = value
  99.                 }
  100.             return this.each(function (i) {
  101.                 for (name in options) jQuery.attr(type ? this.style : this, name, jQuery.prop(this, options[name], type, i, name))
  102.             })
  103.         },
  104.         css: function (key, value) {
  105.             if ((key == 'width' || key == 'height') && parseFloat(value) < 0) value = undefined;
  106.             return this.attr(key, value, "curCSS")
  107.         },
  108.         text: function (text) {
  109.             if (typeof text != "object" && text != null) return this.empty().append((this[0] && this[0].ownerDocument || document).createTextNode(text));
  110.             var ret = "";
  111.             jQuery.each(text || this, function () {
  112.                 jQuery.each(this.childNodes, function () {
  113.                     if (this.nodeType != 8) ret += this.nodeType != 1 ? this.nodeValue : jQuery.fn.text([this])
  114.                 })
  115.             });
  116.             return ret
  117.         },
  118.         wrapAll: function (html) {
  119.             if (this[0]) jQuery(html, this[0].ownerDocument).clone().insertBefore(this[0]).map(function () {
  120.                 var elem = this;
  121.                 while (elem.firstChild) elem = elem.firstChild;
  122.                 return elem
  123.             }).append(this);
  124.             return this
  125.         },
  126.         wrapInner: function (html) {
  127.             return this.each(function () {
  128.                 jQuery(this).contents().wrapAll(html)
  129.             })
  130.         },
  131.         wrap: function (html) {
  132.             return this.each(function () {
  133.                 jQuery(this).wrapAll(html)
  134.             })
  135.         },
  136.         append: function () {
  137.             return this.domManip(arguments, true, false, function (elem) {
  138.                 if (this.nodeType == 1) this.appendChild(elem)
  139.             })
  140.         },
  141.         prepend: function () {
  142.             return this.domManip(arguments, true, true, function (elem) {
  143.                 if (this.nodeType == 1) this.insertBefore(elem, this.firstChild)
  144.             })
  145.         },
  146.         before: function () {
  147.             return this.domManip(arguments, false, false, function (elem) {
  148.                 this.parentNode.insertBefore(elem, this)
  149.             })
  150.         },
  151.         after: function () {
  152.             return this.domManip(arguments, false, true, function (elem) {
  153.                 this.parentNode.insertBefore(elem, this.nextSibling)
  154.             })
  155.         },
  156.         end: function () {
  157.             return this.prevObject || jQuery([])
  158.         },
  159.         find: function (selector) {
  160.             var elems = jQuery.map(this, function (elem) {
  161.                 return jQuery.find(selector, elem)
  162.             });
  163.             return this.pushStack(/[^+>] [^+>]/.test(selector) || selector.indexOf("..") > -1 ? jQuery.unique(elems) : elems)
  164.         },
  165.         clone: function (events) {
  166.             var ret = this.map(function () {
  167.                 if (jQuery.browser.msie && !jQuery.isXMLDoc(this)) {
  168.                     var clone = this.cloneNode(true),
  169.                         container = document.createElement("div");
  170.                     container.appendChild(clone);
  171.                     return jQuery.clean([container.innerHTML])[0]
  172.                 } else return this.cloneNode(true)
  173.             });
  174.             var clone = ret.find("*").andSelf().each(function () {
  175.                 if (this[expando] != undefined) this[expando] = null
  176.             });
  177.             if (events === true) this.find("*").andSelf().each(function (i) {
  178.                 if (this.nodeType == 3) return;
  179.                 var events = jQuery.data(this, "events");
  180.                 for (var type in events)
  181.                     for (var handler in events[type]) jQuery.event.add(clone[i], type, events[type][handler], events[type][handler].data)
  182.             });
  183.             return ret
  184.         },


  185. ......(see the attachment for whole code)

  186. jQuery(function () {
  187.     actionpopup_start()
  188. });
复制代码
Complete code:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|BC Morning Website ( Best Deal Inc. 001 )

GMT-8, 2026-6-11 09:20 , Processed in 0.016711 second(s), 17 queries .

Supported by Weloment Group X3.5

© 2008-2026 Best Deal Online

快速回复 返回顶部 返回列表