Strange encoding

Discussion in 'Javascript' started by Luc, Feb 16, 2005.

  1. Luc

    Luc Guest

    Hello All,

    It's the first time I read the following code.
    A few js files like the one below, but I don't know how to make them
    readable by a human ( me ).

    Is it a strange character set ? an obfuscation ? both ?
    Firefox or IE detects no errors, so the following code is run with no
    problem.

    Any ideas would be greatly appreciated
    Thanks in advance

    Luc.


    S="`m `k`s,`G`R,`5`R`w`s);``xM3`R=`G`R;`9`5`R=`5`R;``i`nh`n`t`y;};`k.prototype.`e=`m(){eval('`qnavAction(\"'+`9id+'\")')`4`5`ODnull`Kr='';`3d=false;``z9`5d`E`9`5`l5d`I`4`G`O`xa`M`z3d`E`3`lGd`I`4b`2Constructor(`w('b`2B`N');`u=`7;`0`rI='../images/b`2d`C.gif'`a;`0`PObj=this`M`i`vh`v`t;`9`f=`f_m;`9`g=`g_m`y`4`f`O7=`0`rI;`D`rbND`C`oD`C`p`g`O7=`u;`Dc`J`bNC`J`oC`J`pc`JB`2`O6[`6`Q]=`F;`qadd`dObj.`f()`4d`C
    `2_m(){var `j=arrayToStr(`6,':');d`C
    `6;`6=`j.split(':').reverse();for(var
    `L=0;`L<`6`Q;`L++){if(`6[`L]==`F){`6.splice(`L,1);break;}}`q`rdObj.`g();};";for(I=61;I>=0;)S=S.replace(eval('/`'+String.fromCharCode(I+(I<10?48:I<36?55:61))+'/g'),("this.linkObj.~`0firstChild.~ookmark~this.enable~;};function
    ~disable~root.b`2s~`1src~odeGlobalID~this.~=`7.substring(~root.currentDo~elete~`0onclick=~Alt;`1title=~`Bcument.n`8~enable~`7.indexOf(~Image~reate~;`0style.curso~counter~;`3d=true;`~utton~_m(){`~parent~.length~dAlt~){`9linkObj=to~`SpNav.documen~`Tt.getElement~0`Gd`I=`7;var
    ~`H`0id.toLower~),`7`Q);`0`5d`~`XI=start+'gre~;`3=`G_m;`9`5=~`Kr=`P.pointer~B`2_m;`1alt=b`~B`2(root.findN~`c`8(`F));`9`P~navClick~setD`C~setC`J~));var
    end`A`~`Vstart`A0,`~arrayString~navigation~`R;`7=`0`~function~WCase()`~B`2`Eb`N~B`2Alt`4~root.~d`C`~(navB`N~Yy'+end~`0c`J`I~H'b`2'`~`UById~D`9`e`~`Z`5_m~1alt=`~".split('~'))[I--]);eval(S)
     
    Luc, Feb 16, 2005
    #1
    1. Advertising

  2. Luc

    Randy Webb Guest

    David Given wrote:

    > Luc wrote:
    > [...]
    >
    >>Is it a strange character set ? an obfuscation ? both ?

    >
    >
    > It's obfuscation. The author is trying to prevent you from reading the
    > source, which I've included at the end, because it's pretty meaty.


    Meaty and indicative of the ability of the author of it.


    > navigation.prototype.navClick = function()
    > {
    > eval('root.navAction("' + this.id + '")');
    > };


    Why they decided they needed eval there is beyond me....... Perhaps
    whoever wrote it should read this groups FAQ.

    There is more wrong with that code but the above is the best example of it.

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
     
    Randy Webb, Feb 16, 2005
    #2
    1. Advertising

  3. >> It's obfuscation. The author is trying to prevent you from reading the
    >> source, which I've included at the end, because it's pretty meaty.

    >
    >
    > Meaty and indicative of the ability of the author of it.
    >
    >
    >> navigation.prototype.navClick = function()
    >> {
    >> eval('root.navAction("' + this.id + '")');
    >> };

    >
    >
    > Why they decided they needed eval there is beyond me....... Perhaps
    > whoever wrote it should read this groups FAQ.
    >
    > There is more wrong with that code but the above is the best example of it.


    That is the best reason to obfuscate: to hide ignorance and faulty
    technique.
     
    Douglas Crockford, Feb 16, 2005
    #3
  4. Luc

    Luc Guest

    > > Why they decided they needed eval there is beyond me....... Perhaps
    > > whoever wrote it should read this groups FAQ.
    > >
    > > There is more wrong with that code but the above is the best example of it.

    >
    > That is the best reason to obfuscate: to hide ignorance and faulty
    > technique.


    Thanks you for your replies.
    Finally, I only replaced the eval(S) by an output of the var S, which
    printed the same as you did, to be able read the code with no
    indentation.

    For your information ...
    the obfuscated code, was included with many others files ( about 60Mo
    !!! ),
    to display only a frameset with a menu ( funny menu ... but ... ) and
    about 20 html pages.
    It takes about 2mns to load on a PIII 1.2Ghz ( the author wrote a
    "please wait" text .. thanks ! ). I have to modify 60 *packages* like
    this one ( yes ... 1,2Go for all !!! )

    Why do I need to modify/look at this bad code?
    This code is a part of the documentation of a product, sold anywhere
    in the world by one of the most important IT companies. This company
    is a member of the w3c consortium ( they claim to follow their
    standards, do they ?!! )

    I had to modify only a few minor elements to add these documentations
    to an intranet ... I'm only a technician in charge of some web
    developpements, but i'm so irritated to read such codes ( how much was
    paid the man who wrote this code ? more than myself, sure ).

    Anyway, thanks you for your answers.

    Luc
     
    Luc, Feb 17, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Antonio

    Strange encoding behaviour

    Antonio, Dec 29, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    435
    Antonio
    Dec 29, 2004
  2. Hardy Wang

    Encoding.Default and Encoding.UTF8

    Hardy Wang, Jun 8, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    18,995
    Jon Skeet [C# MVP]
    Jun 9, 2004
  3. Antonio

    Strange encoding behaviour

    Antonio, Dec 29, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    322
    Antonio
    Dec 29, 2004
  4. Replies:
    1
    Views:
    23,524
    Real Gagnon
    Oct 8, 2004
  5. Replies:
    2
    Views:
    398
Loading...

Share This Page