Home > javascript > Unobfuscating packed javascript

Unobfuscating packed javascript

July 31st, 2007

I started to get curious around Virb's code and wanted to take a peek at how they're doing some things.. Their global js didn't prove to be too helpful.. It was just packed and obfuscated: http://www.virb.com/_js/global.js
packedcode.PNG



In fact, a lot of javascript gets packed up these days with Dean Edwards amazing Packer functionality. This is great for delivery and optimization, but hard for people to poke in and learn some new techniques. I couldn't be so easily defeated by Virb's code.

Ryan at YAIB created a little bookmarklet widget to enable the decode functionality at dean's packer site.
Drag the reEnable link to your bookmark bar, then head over to the packer site and click the button. The "copy" textarea should now be writeable and the decode button activated.
Now copy in your packed and obfuscated code and hit decode.

If successful, you should now see some var's and null's and everything be looking a little more like readable javascript.
Head over to Beautify Javascript, paste your decoded code in, and hit the big button.

You'll now have some nice looking javascript to inspect. Cheers.

Update 2008.12.17: Changed to use Beautify Javacript instead of PrettyPrinter.de

Paul Irish javascript

  1. July 31st, 2007 at 17:08 #1

    Thank you, thank you! I was *just* looking at the packed javascript for the iPhone Bejeweled (http://static.popcap.com/iphone/) script last night and haven't had a chance to look for an unpacker…

  2. January 29th, 2008 at 13:10 #2

    To see what is behind a packed script, I simply replace eval() by document.print()

    and the page shows the original source code :)

  3. February 9th, 2008 at 20:09 #3

    Thank you for the trick !

  4. March 6th, 2011 at 06:07 #4

    Thanks for this post it was really usefull i was trying to understand some packed code.

  5. April 27th, 2011 at 00:16 #5

    Verification for' Dear news this chapter. I think if everyone behaved well. There would be no problem motleyed That can not be redacted offline. Every network station to figure a plan

  6. April 27th, 2011 at 02:07 #6

    Verification for' Dear news this chapter. I think if everyone behaved well. There would be no problem motleyed That can not be redacted offline. Every network station to figure a plan

  1. No trackbacks yet.

For code blocks, use <pre lang="javascript">. css and html4strict are also accepted.

i left this space here for you to play. <3