问题
You know how those packed 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?
回答1:
You can with online unpackers: try one of these, find one that suits you:
- Dean Edwards Unpacker
- JSUnpack
回答2:
JS Beautifier will both reformat and unpack:
http://jsbeautifier.org/
回答3:
Here's an unpacker.
回答4:
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'
来源:https://stackoverflow.com/questions/2460751/how-to-unpack-the-contents-of-a-javascript-file