Apr
10
2012

Dean Edwards Packer exposed.

Have you ever packed code and misplaced the original? Sadly, so have I.

Well after really looking at the packer for the first time the solution to decode it is painfully easy!

The secret lies in the eval() function

That is the function that allows the JavaScript engine to make sense of the code from Dean Edwards packer function. Replacing that function is what will allow us to make sense of the code.

So using JavaScript (mootools in this example) we can do something super simple such as:

Prep Work

/**
  * Open your packed code in your fav IDE.
  * Remove the opening eval(
  * than at the end of the string remove the );
  * copy what is left. (minus any comments, other JS functions etc...)
**/

Core HTML

<textarea id="decoded"></textarea>

Core Javascript (mooTools)

var decoder = function() {
    $('decoded').set('value', PASTE_YOUR_CODE_HERE);
}

window.addEvent('domready' , decoder);

Run the code and behold your unPacked Javascript!

Complete code example:

<!doctype html>
<head>
	<title>Javascript UnPacker</title>
	<script src="https://ajax.googleapis.com/ajax/libs/mootools/1.4.5/mootools-yui-compressed.js"></script>
	<script>
		var decoder = function() {
		    $('decoded').set('value', PASTE_YOUR_CODE_HERE);
		}
		window.addEvent('domready' , decoder);
	</script>
	<style>
		body {
			margin:0;
			padding:0;
		}
		textarea {
			display: block;
			height: 500px;
			margin: 12px auto;
			width: 80%;
		}
		p {
			text-align: center;
		}
	</style>
</head>
<body>
	<p>Copy your code below and use it here: <a href="http://jsbeautifier.org/">Beautify JavaScript</a>
	<textarea id="decoded"></textarea>
</body>
</html>

1 Comment + Add Comment

  • Goodmorning Tim!
    (I assume you’re in the states).
    I have just looked into your Ajax upload. Splendid coding!
    As for the eval, I am constantly refusing to use any script that relies on the eval function (eval is evil… ) So, I wonder is there a way to replace eval with native javascript?
    By the way, if you have the time and interest, there’s an addon over at oscommerce contribution area called “Ajax attribute manager” which needs a complete rework. As it is today, is very buggy logic is… bla..bla… If you’d do it you can be sure of finding a lot of customers. Regular shop owners don’t have coding skills or knowledge, for almost everything for their shops. Just have a look in the osCommerce forums…. :)

    Kind regards from Sweden

    Thumb up 0 Thumb down 0

Leave a comment

Show/Hide Footer Actions

Status: Available for your project.