De"compressing" Javascript [duplicate] - javascript

This question already has answers here:
Is there such a thing as a javascript deminifier (deobfuscator)? [closed]
(10 answers)
Closed 8 years ago.
This will without a doubt be a duplicate, but I have no idea what else to call it.
A friend of mine is trying to learn Javascript. He accidentally saved the "compressed" (all whitespace removed) version as the version he has, and wants me to help format it again. He's emailed me a massive .js file and... I'm not sure what to do.
I don't want to install (no doubt Eclipse has one) a Javascript plugin for Eclipse just to right click and format once. Is there a tool for this? A parser that'll build an AST then format that AST?

Tool to Unminify / Decompress JavaScript
Apparently JS beautifier will do the trick sometimes.
There's a plethora of others on there.

Related

The mysterious widgets.map file [duplicate]

This question already has answers here:
How can I use JavaScript source maps (.map files)?
(5 answers)
Closed 1 year ago.
I am working on an HCL Commerce project and I receive this error when I load cart page locally:
File not found: /MyWebExtSitesSAS/javascript/widgets.map
I cannot find anywhere in the web references for widgets.map. Can you describe me what is this file used for, and if I can ignore this error?
I repost the answer in the comment by #disinfor because it answered my question
You can ignore that. A map file is used for debugging purposes. When
you minify code, e.g. js, css, etc. it obviously becomes hard to read
to find any errors. The map file is used by a browser to show where in
the original, unminified code the error is coming from.

How to unobfuscate java-script code [duplicate]

This question already has answers here:
Deobfuscating Javascript [closed]
(5 answers)
Closed 8 years ago.
How to un obfuscate java-script code like that : it takes alot of time to know the expression obfuscate for the javascript to protect the code , but I'm tring to get the main code of this script but don't know How ?
var _0x843d=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x53\x4C\x41\x4D\x52","\x6E\x61\x76","\x72\x65\x73\x69\x7A\x65","\x77\x69\x64\x74\x68","\x74\x6F\x70\x2D\x6E\x61\x76\x2D\x63\x6F\x6C\x6C\x61\x70\x73\x65","\x68\x61\x73\x43\x6C\x61\x73\x73","\x2E\x6E\x61\x76\x62\x61\x72\x2D\x66\x69\x78\x65\x64\x2D\x74\x6F\x70","\x61\x64\x64\x43\x6C\x61\x73\x73","\x72\x65\x6D\x6F\x76\x65\x43\x6C\x61\x73\x73","\x74\x6F\x70","\x6F\x66\x66\x73\x65\x74","\x2E\x6E\x61\x76\x62\x61\x72","\x73\x63\x72\x6F\x6C\x6C","\x64\x72\x6F\x70\x64\x6F\x77\x6E","\x61\x63\x74\x69\x76\x65\x2D\x73\x75\x62","\x65\x61\x73\x65\x4F\x75\x74\x45\x78\x70\x6F","\x3A\x6E\x6F\x74\x28\x2E\x65\x78\x29","\x6F\x6E\x65\x50\x61\x67\x65\x4E\x61\x76","\x2E\x6E\x61\x76\x62\x61\x72\x2D\x6E\x61\x76\x20\x2E\x64\x72\x6F\x70\x64\x6F\x77\x6E","\x61\x63\x74\x69\x76\x65","\x2E\x6E\x61\x76\x62\x61\x72\x2D\x6E\x61\x76","\x73\x6C\x69\x64\x65\x44\x6F\x77\x6E\x48\x65\x61\x64","\x2D\x35\x30\x30\x70\x78","\x30","\x63\x73\x73","\x2E\x70\x61\x67\x65\x48\x65\x61\x64","\x2E\x70\x61\x67\x65\x48\x65\x61\x64\x20\x2E\x68\x65\x72\x6F\x20\x68\x31\x2C\x20\x2E\x70\x61\x67\x65\x48\x65\x61\x64\x20\x2E\x68\x65\x72\x6F\x20\x68\x33","\x72\x65\x61\x64\x79","\x30\x70\x78","\x31","\x65\x61\x73\x65\x4F\x75\x74\x43\x75\x62\x69\x63","\x61\x6E\x69\x6D\x61\x74\x65","\x2E\x70\x61\x67\x65\x48\x65\x61\x64\x20\x2E\x68\x65\x72\x6F\x20\x68\x33","\x2E\x70\x61\x67\x65\x48\x65\x61\x64\x20\x2E\x68\x65\x72\x6F\x20\x68\x31","\x64\x65\x6C\x61\x79","\x73\x74\x6F\x70","\x6C\x6F\x61\x64","\x70\x61\x72\x61\x6C\x6C\x61\x78","\x74\x6F\x75\x63\x68","\x73\x65\x74","\x72\x61\x6E\x64\x6F\x6D","\x69\x6E\x69\x74","\x70\x72\x65\x6C\x6F\x61\x64\x65\x72","\x6F\x76\x65\x72\x66\x6C\x6F\x77","\x76\x69\x73\x69\x62\x6C\x65","\x62\x6F\x64\x79","\x66\x61\x64\x65\x4F\x75\x74","\x23\x70\x72\x65\x6C\x6F\x61\x64\x65\x72","\x73\x6C\x69\x64\x65\x72","\x73\x75\x70\x65\x72\x73\x6C\x69\x64\x65\x73","\x6F\x77\x6C\x43\x61\x72\x6F\x75\x73\x65\x6C","\x65\x61\x63\x68","\x73\x6B\x69\x6C\x6C\x62\x61\x72","\x61\x6E\x69\x6D\x61\x74\x65\x64","\x75\x73\x65\x72\x41\x67\x65\x6E\x74","\x74\x65\x73\x74","\x64\x61\x74\x61\x2D\x70\x65\x72\x63\x65\x6E\x74","\x61\x74\x74\x72","\x2E\x73\x6B\x69\x6C\x6C\x62\x61\x72\x2D\x62\x61\x72","\x66\x69\x6E\x64","\x68\x65\x69\x67\x68\x74","\x6F\x75\x74\x65\x72\x48\x65\x69\x67\x68\x74","\x77\x61\x79\x70\x6F\x69\x6E\x74","\x2E\x73\x6B\x69\x6C\x6C\x62\x61\x72","\x76\x69\x64\x65\x6F\x42\x67\x59\x54","\x74\x75\x62\x75\x6C\x61\x72","\x3C\x69\x6D\x67\x20\x73\x72\x63\x3D\x27\x69\x6D\x67\x2F\x62\x67\x2D\x68\x65\x61\x64\x2D\x31\x2E\x6A\x70\x67\x27\x20\x61\x6C\x74\x3D\x27\x27\x20\x2F\x3E","\x68\x74\x6D\x6C","\x62\x6F\x6F\x74\x73\x74\x72\x61\x70\x43\x61\x72\x6F\x75\x73\x65\x6C","\x63\x61\x72\x6F\x75\x73\x65\x6C","\x66\x69\x74\x56\x69\x64\x73","\x70\x6F\x72\x74\x66\x6F\x6C\x69\x6F\x46\x69\x6C\x74\x65\x72","\x70\x72\x65\x76\x65\x6E\x74\x44\x65\x66\x61\x75\x6C\x74","\x63\x75\x72\x72\x65\x6E\x74","\x64\x61\x74\x61\x2D\x67\x72\x6F\x75\x70","\x61\x6C\x6C","\x69\x6E\x61\x63\x74\x69\x76\x65","\x2E\x70\x6F\x72\x74\x66\x6F\x6C\x69\x6F\x2D\x6C\x69\x6E\x6B","\x75\x6E\x64\x65\x66\x69\x6E\x65\x64","\x2C","\x73\x70\x6C\x69\x74","\x63\x6C\x69\x63\x6B","\x68\x6F\x76\x65\x72","\x70\x6F\x72\x74\x66\x6F\x6C\x69\x6F","\x70\x6F\x72\x74\x66\x6F\x6C\x69\x6F\x45\x78\x70\x61\x6E\x64\x65\x72","\x73\x63\x72\x6F\x6C\x6C\x41\x6E\x69\x6D","\x79\x65\x73","\x64\x65\x66\x61\x75\x6C\x74\x73","\x66\x6E","\x61\x6E\x69\x6D\x61\x74\x69\x6F\x6E","\x64\x61\x74\x61","\x64\x61\x74\x61\x2D\x61\x6E\x69\x6D\x61\x74\x69\x6F\x6E","\x64\x61\x74\x61\x2D\x61\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2D\x64\x65\x6C\x61\x79","\x61\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2D\x64\x65\x6C\x61\x79","\x20\x76\x69\x73\x69\x62\x6C\x65","\x25","\x2E\x61\x6E\x69\x6D\x61\x74\x65\x64","\x76\x69\x73\x69\x62\x69\x6C\x69\x74\x79","\x66\x69\x78\x65\x64","\x2E\x62\x61\x63\x6B\x67\x72\x6F\x75\x6E\x64\x2D\x6D\x69\x64\x64\x6C\x65\x2D\x66\x75\x6C\x6C","\x6D\x61\x67\x6E\x69\x66\x69\x63","\x6D\x61\x67\x6E\x69\x66\x69\x63\x50\x6F\x70\x75\x70","\x63\x6F\x6E\x74\x61\x63\x74\x46\x6F\x72\x6D","\x63\x6C\x69\x63\x6B\x20\x74\x6F\x75\x63\x68\x73\x74\x61\x72\x74","\x64\x69\x73\x61\x62\x6C\x65\x64","\x70\x72\x6F\x70","\x3C\x69\x20\x63\x6C\x61\x73\x73\x3D\x27\x66\x61\x20\x66\x61\x2D\x63\x6F\x67\x20\x66\x61\x2D\x73\x70\x69\x6E\x27\x3E\x3C\x2F\x69\x3E\x20\x53\x45\x4E\x44\x49\x4E\x47","\x23\x63\x6F\x6E\x74\x61\x63\x74\x2D\x73\x75\x62\x6D\x69\x74","\x23\x63\x6F\x6E\x74\x61\x63\x74\x2D\x66\x6F\x72\x6D","\x73\x65\x72\x69\x61\x6C\x69\x7A\x65","\x50\x4F\x53\x54","\x69\x6E\x63\x2F\x63\x6F\x6E\x74\x61\x63\x74\x2E\x70\x68\x70","\x6A\x73\x6F\x6E","\x73\x74\x61\x74\x75\x73","","\x76\x61\x6C","\x23\x63\x6F\x6E\x74\x61\x63\x74\x2D\x66\x6F\x72\x6D\x20\x69\x6E\x70\x75\x74","\x23\x63\x6F\x6E\x74\x61\x63\x74\x2D\x66\x6F\x72\x6D\x20\x74\x65\x78\x74\x61\x72\x65\x61","\x65\x6D\x70\x74\x79","\x23\x63\x6F\x6E\x74\x61\x63\x74\x2D\x66\x6F\x72\x6D\x2D\x72\x65\x73\x70\x6F\x6E\x73\x65","\x3C\x69\x20\x63\x6C\x61\x73\x73\x3D\x27\x66\x61\x20\x66\x61\x2D\x63\x68\x65\x63\x6B\x27\x3E\x3C\x2F\x69\x3E\x20\x53\x55\x42\x4D\x49\x54","\x61\x6A\x61\x78","\x6F\x6E"];
I have another question related to that , Could I use this script as it's or I have to decode it to use at my HTML5 page ?
The point of obfuscation is to make it very challenging to restore the original code as written while maintaining the same functionality. So to answer your first question there really is no way to get back to the original code as the author clearly didn't want you to see it or be able to edit it. To answer your second question yes you should be able to use it normally assuming it was properly obfuscated.
I suggest you do a little reading on the topic: http://en.wikipedia.org/wiki/Obfuscation_%28software%29
There might be a few deobfuscation tools out there for javascript, but the chance that these work well is probably low.

Can i hide some code in Javascript from the user? [duplicate]

This question already has answers here:
How can I obfuscate (protect) JavaScript? [closed]
(22 answers)
Closed 9 years ago.
I want to have two separate files in JavaScript with the same name , can i do it in javascript ?
I want to expose only part of the code to the user and not all the file
(Do we have any concept on javascript like the c# partial classes ?)
Thanks
Shimon
In the Web Browser, all of the JavaScript code is interpreted locally on the user's machine. So for the Web Browser to be able to interpreted correctly it needs all of the source code. So the answer to your main question is "no".
The closest solution to your problem is doing some sort of obfuscation of the source code. When you do that, it makes the source code very hard for the user to read the source code, but the Web Browser can still interpret it.
To answer the last question, all objects in JavaScript can be extended like partial classes in C#.
Nope - you can't fully hide JavaScript from your end users. The users browser needs to be able to parse the code and as such the user will have access to it as well.
What you can try to is use some form of code obfusication. This will still allow the user's browser to parse the code but will make it very difficult for a user to read and understand what's going on.
That said, it's not impossible for a user to un-obfusicate the code and see the logic behind it - it is just another layer of security but by no means fool proof.

compress a javascript [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How can I obfuscate JavaScript?
I want my js not to be understood by anyone. I have read some similar posts on this site but can get an exe or a full desktop application for it. Whatever I get are online tools.
OR how to sense '\n' character in js?
UglifyJS / UglifyJS2:
JavaScript parser / mangler / compressor / beautifier toolkit
You can download "yui compressor" to compress the javascript. But I does not means that no-one can read you scripts.
Their are again tool which make your compressed javascript files again readable :(

Protecting JavaScript? Or use Something else? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
How can I obfuscate JavaScript?
I have been working on a web app in JavaScript. Nearing complete.
How do I protect me JavaScript code from someone copying it? I mean if you view my page source, it references the .js files and one could really steal these.
Should I be using something else? RoR?
Does Google Maps have a RoR API?
Your closest bet would be to use something like
A Javascript Obfucator
A Javascript Minifier
A Javascript Packer
People will still be able to steal and use your code though, it will just be harder to modify.

Categories