13

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?

Mark Byers
  • 811,555
  • 193
  • 1,581
  • 1,452
Valentin Brasso
  • 1,388
  • 7
  • 21
  • 41

4 Answers4

14

JS Beautifier will both reformat and unpack:

http://jsbeautifier.org/

Dan Grossman
  • 51,866
  • 10
  • 112
  • 101
12

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

Martin Smith
  • 438,706
  • 87
  • 741
  • 845
OverLex
  • 2,501
  • 1
  • 24
  • 27
2

Here's an unpacker.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
0
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'

Dave Brown
  • 923
  • 9
  • 6
  • http://www.scriptcompress.com/unpack.htm is a online tool I made for unpacking, also http://www.scriptcompress.com/decoder.htm will try to decode it in the DOM, through JSOn parser and more – Dave Brown Jul 20 '15 at 22:17