开发者

How to unpack the contents of a JavaScript file?

You know how those pa开发者_JAVA技巧cked js files look like, right?

 eval(function(p,a,c,k,e,d){ ... } ('obfuscated-string'.split('|'),0,{}))

It just so happens to be that i have to tweak some large legacy code that looks like that and I want to find a way to turn this into a more readable version.

If that's not possible, can i at least get rid of the eval?


JS Beautifier will both reformat and unpack:

http://jsbeautifier.org/


You can with online unpackers: try one of these, find one that suits you:

  • Dean Edwards Unpacker
  • JSUnpack


Here's an unpacker.


eval(function(W,H,A,K){function z(i){return(i< 62?'':z(this['parseInt'](i/62)))+((i=i%62)>35?String.fromCharCode(i+29):i.toString(36))}for(var i=0;i<W.length;i++)A[z(i)]=W[i];function d(w){return A[w]?A[w]:w;};return H.replace(/\b\w+\b/g,d);}('alert|Testing|packed'.split('|'),'0("1 0 2");',{}));

What I do is change eval to document.getElementByID('test').value= and then make sure I have a textarea (no DOM parsing, multilines) wuth id

test.value=(function(W,H,A,K){function z(i){return(i< 62?'':z(this['parseInt'](i/62)))+((i=i%62)>35?String.fromCharCode(i+29):i.toString(36))}for(var i=0;i<W.length;i++)A[z(i)]=W[i];function d(w){return A[w]?A[w]:w;};return H.replace(/\b\w+\b/g,d);}('alert|Testing|packed'.split('|'),'0("1 0 2");',{}));
<textarea id=test rows=9 cals=77></textarea>

='test'

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜