Wednesday, August 05, 2009

Unpacking Packed Javascript

You ever try to learn a new trick from a web page by looking at the source, only to discover code that looks like this?

eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c ….

That’s been “packed” (note the parameters to the function?) specifically so you can’t read the source.

It’s also easy to get around.  The browser at one point or another has to unpack it to run it, so what you need to do is catch it someplace where you can display it.

Copy your ugly packed code, and open up Firefox’s Error Console. 

Paste the packed code into the “Code” text box.

At the front of the string add the text   “eval=alert;” and then click Evaluate. 

This should bring up an alert box containing your unpacked code.

It’s such a pain in the neck, in fact, that there are also plenty of online tools that will go ahead and just do it for you.

No comments: