Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    Regular Coder
    Join Date
    Jul 2006
    Posts
    399
    Thanks
    33
    Thanked 7 Times in 7 Posts

    unpacking a js file

    anyone knows a good unpacker? i am tryng to read js file that are packed , unpacking them would make things easier

  2. #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    19,384
    Thanks
    217
    Thanked 2,697 Times in 2,673 Posts
    Depends on what progarm was used to pack the script in the first place. There are several out there.


    It is your responsibility to die() if necessary….. - PHP Manual

  3. #3
    Regular Coder
    Join Date
    Jul 2006
    Posts
    399
    Thanks
    33
    Thanked 7 Times in 7 Posts
    well i dont know they are random files i found on the internet, anyway they are readable but compacted(no line breaks, no comments etc..), i think i should try a couple of unpackers out there to see if they work..i've just found the dean packer but it's a packer tho.

  4. #4
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,650
    Thanks
    11
    Thanked 626 Times in 605 Posts
    you can use mine.

    the app itself only works in firefox, but the code it compresses/formats runs in all browsers.
    Create, Share, and Debug HTML pages and snippets with a cool new web app I helped create: pagedemos.com

  5. #5
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    2,116
    Thanks
    120
    Thanked 79 Times in 79 Posts
    rnd_me

    could u add one more buton: reformat1
    that would output instead of:
    Code:
    function isColor(c) {
      alert('A');    
    }
    this

    Code:
    function isColor(c) 
    {
      alert('A');    
    }
    I realy hate first formatting, can't imagine who invented it
    Last edited by BubikolRamios; 11-05-2008 at 10:47 AM.

  6. #6
    Regular Coder
    Join Date
    Jul 2006
    Posts
    399
    Thanks
    33
    Thanked 7 Times in 7 Posts
    Quote Originally Posted by rnd me View Post
    you can use mine.

    the app itself only works in firefox, but the code it compresses/formats runs in all browsers.
    thank you , but it does not works for unpacking my code it must be due to the fact that another packer was used.

  7. #7
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,650
    Thanks
    11
    Thanked 626 Times in 605 Posts
    the function name(){ format is actually preferred by me, crockford, and others as it avoids possible erroneous automatic semi-colon insertion.

    i also don't like to use a lot of regexps on things. i figure that closer to programmatic the formating functionality is, the fewer problems could arise later.

    the code is simple enough you can easily modify it yourself.
    the formatted code generator is only one or two lines of code...
    Create, Share, and Debug HTML pages and snippets with a cool new web app I helped create: pagedemos.com

  8. The Following 2 Users Say Thank You to rnd me For This Useful Post:

    Philip M (11-05-2008), sybil6 (11-05-2008)

  9. #8
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,650
    Thanks
    11
    Thanked 626 Times in 605 Posts
    Quote Originally Posted by sybil6 View Post
    thank you , but it does not works for unpacking my code it must be due to the fact that another packer was used.

    if it's just whitespace, it should work. it won't serialize the eval-based routines like packr. it should not matter at all what was used to strip it, unless it broke the validity of the code.

    if you install firebug, you can browse the globals, any look for functions that pique your interest. then run functionName.toString() in the console to see a formatted view of the function.

    one other thing:

    you might try wrapping a temporary function around the code before you format it with my formatter.

    for example, if your code was "alert(5+5)", you would want to try formatting "function bs(){ alert(5+5) }" instead. (not that that tiny example really needs formatted)

    ii wrote it as a dev tool for me, not a general purpose utility for the public, so a little wiggle work might be required, but i have never found code it couldn't handle.
    Create, Share, and Debug HTML pages and snippets with a cool new web app I helped create: pagedemos.com

  10. #9
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    19,384
    Thanks
    217
    Thanked 2,697 Times in 2,673 Posts
    Quote Originally Posted by rnd me View Post
    the function name(){ format is actually preferred by me, crockford, and others including Philip M as it avoids possible erroneous automatic semi-colon insertion.

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

  11. #10
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,584
    Thanks
    3
    Thanked 516 Times in 503 Posts
    impressive
    BTW an HTML error?

    Code:
    <input type='checkbox' ' value='standalone' id="sa" onchange="validate = !! this.checked" title="validates the code for missing globals" />
    Last edited by vwphillips; 11-05-2008 at 05:34 PM.
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  12. #11
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,650
    Thanks
    11
    Thanked 626 Times in 605 Posts
    Quote Originally Posted by vwphillips View Post
    impressive
    BTW an HTML error?
    yup. i threw it together in about 20 mins, so that's what happens when you rush.


    ----
    i never thought anyone would use it, but it seems like there is some interest in this crapplet.

    perhaps it's worth putting another 20mins into...
    Create, Share, and Debug HTML pages and snippets with a cool new web app I helped create: pagedemos.com

  13. #12
    New to the CF scene
    Join Date
    May 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to unpack JS

    The following page will allow you to paste in packed JS code and hit an "unpack" button which will then output the original unpacked code in a textarea box you can copy from:

    http://www.strictly-software.com/unpacker.asp

    There are 2 reasons you may want to be doing this.

    1. You are stealing someone else's code. They have obviously packed it to prevent you from seeing what it does. This is actually pretty pointless in this day and age as a browser is a client side tool and everything I view is loaded on my machine as temporary files so in reality it could be considered as mine to tamper with. With tools like Firebug, Yslow, Hackbar and other developer toolbars trying to put security on the client is pointless as it will never stop someone who knows what they are doing (read this for more details: http://blog.strictly-software.com/20...-security.html)

    In fact just to reduce the size of the code minification is the best method and obfusicating the code can actually make it much larger again. For example go to http://dean.edwards.name/packer/ and enter something like this in the top box:

    function(var1){if(var==1){alert('hello')}else{alert('goodbye')}}

    Choose both the Shrink Variables and Base62 encode options and you will get this:

    eval(function(p,a,c,k,e,r){e=String;if(!''.replace(/^/,String)){while(c--)r[c]=k[c]||c;k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('8(2){7(3==1){0(\'6\')}4{0(\'5\')}}',9,9,'alert||a|var|else|goodbye|hello|if|function'.split('|') ,0,{}))

    which as you can see if is obviously much longer that just compressing the original code so the aim is not just compression.

    2. The other reason to want to unpack someone else's code is to check whether a script being loaded on a page/site is malicious or not. Without unpacking you will have no idea.

    If you want to unpack packed JS code go to this site

    http://www.strictly-software.com/unpacker.asp

    paste the packed code in the top box, hit "unpack" and the original code will appear in the second box for you to copy and do as you wish.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •