views:

1926

answers:

6

This question is exactly the opposite of http://stackoverflow.com/questions/489847/which-javascript-minifier-cruncher-does-the-same-things-that-the-one-google-use

I want to learn how google does it's loading so I can build my own with non-popular JS toolkits.

+2  A: 

Hi,

Try this: http://jsbeautifier.org/

yoda
This is just a code formatter, very good at it but not what I'm look for here.
Jorge Vargas
It doesn't just format youy code, it's supposed to do the "deminifier" thing .. had you tried actually?
yoda
@Yoda: How can it dobfuscate? It appears to know nothing about identifiers.
Ira Baxter
A: 

See our SD ECMAScript Formatter for a tool that will nicely format code.

EDIT: If you want to reverse the renaming process you need something can rename the obfuscated names back to the originals.

This tool can technically do that: SD Thicket ECMAScript Obfuscator.

It does so by applying a renaming map over which you have precise control. Typically you implicitly construct such a map during the obfuscation process by choosing which names to obfuscate and which to preserve, and the obfuscator applies that map to produce the obfuscated code.

The Thicket obfuscator generates this map as side effect when you obfuscate in the form essentially of a set of pairs (originalname,obfuscatedname) for reference and debugging purposes.

Swapping elements gives the map (obfuscatedname,originalname). That inverted map can be applied by Thicket to recover the code with the original names, from the obfuscated code. And the Thicket obfuscator includes the Formatter to let you make it look nice again.

The catch to "reversing minification" (as you put it poorly, you are trying to reverse obfuscation), is that you need the map. Since people doing obfuscation don't give away the map, you, as a recipient of obfuscated code, have nothing to apply. A would-be pirate would have to reconstruct the map presumably by painful reverse engineering.

The "reversing" process also can't recover comments. They're gone forever.

This is all by design, so the real question is why are you looking to reverse obfuscation?

Ira Baxter
same as the others code formatter really.
Jorge Vargas
@Jorge: that's because your original question misused the term "minification" when you meant "obfuscation". I've expanded the answer to tell you exactly how to reverse the obfuscation process to the extent possible. The tools will do it if you have the right data. You are unlikely to have that data.
Ira Baxter
This is not a deobfuscator too. It just maps identifer names and pretty prints.
artificialidiot
That's exactly what I said, and that you'd couldn't do better than that.
Ira Baxter
@Ira, I do not agree variable renaming is not obfuscation, it's simply minification of "letters" rather than "whitespace". Obfuscation of variable names is to add variables/methods that are not needed or to replace 1 call with 2 calls one to a dummy method that simply redirects.
Jorge Vargas
Most users/victims of such tools think they are fine obfuscators even if you have a different definition. It is true that one could do more to obfuscate code. I could claim that adding useless method calls isn't obfuscation, and that I was satisfied only if you scrambled control flow, data flow, and converted the result to a 3 state 7 symbol Turing machine, but this is disingenuous. The issue here is degree of obfuscation, not whether obfuscated. YMMV.
Ira Baxter
+2  A: 

Uhhh, it would be impossible to restore variable names unless there was a mapping of minified -> original variable names available. Otherwise, I think the authors of that tool could win the Randi prize for psychic feats.

patros
Jorge Vargas
You specifically complained that the beautifiers didn't "undo the variable renaming", implying you wanted the original symbols back.
patros
+1  A: 

You will not be able to reconstruct method name or variable names. The best you can hope for is a simple JS code formater (like those previously mentioned), and then to go through the file method by method, line by line, working out what each part does.

Perhaps using a good JS refactoring tool would make this easier as well (being able to rename/document methods)

Matthew
Ok this seems like a better lead, so which is a good JS refractoring tool?
Jorge Vargas
Intellij IDEA can do method/variable renaming on Javascript files. Apparantly CodeRush / Refactor Pro will do the same in Visual Studio
Matthew
A: 

Try javascript deobfuscator extension.

artificialidiot
That isn't a "deobfuscator". It is just a code execution trace.
Ira Baxter
A: 

It's possible to quickly break single string of minified java code using Microsoft Word: 1) press Ctrl+H, or just Replace button. 2) type { in find, 3) and in replace type ^p{^p 4) Press replace all, and repeat with } Also You can try replace ; with ;^p but be careful.

IgorD