Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to unpack the contents of a JavaScript file?

You know how those packed js files look like, right?

 eval(function(p,a,c,k,e,d){ ... } ('obfuscated-string'.split('|'),0,{}))

It just so happens to be that i have to tweak some large legacy code that looks like that and I want to find a way to turn this into a more readable version.

If that's not possible, can i at least get rid of the eval?

like image 999
Valentin Brasso Avatar asked Mar 17 '10 08:03

Valentin Brasso


People also ask

How do I open a JavaScript file?

Open Notepad or TextEdit, open the template folder, then drag the . js file into Notepad or TextEdit and drop it. Open Notepad or TextEdit, select "file" then "open", browse to the template folder, select "all file types" and open the . js file that way.

How do I open and edit JavaScript files?

Editing JavaScript code in real-time is possible in Chrome and Chromium based browsers. After loading a web page completely, press the F12 key to open the developer tools, then open the 'Sources' tab. Now open any Javascript file loaded on the browser and you can directly edit it by clicking anywhere in that file.

Should I separate JavaScript files?

You should put your JS code in a separate file because this makes it easier to test and develop. The question of how you serve the code is a different matter. Serving the HTML and the JS separately has the advantage that a client can cache the JS.


2 Answers

JS Beautifier will both reformat and unpack:

http://jsbeautifier.org/

like image 120
Dan Grossman Avatar answered Oct 21 '22 09:10

Dan Grossman


You can with online unpackers: try one of these, find one that suits you:

  • Dean Edwards Unpacker
  • JSUnpack
like image 12
OverLex Avatar answered Oct 21 '22 08:10

OverLex