我发现一个url请求有可疑代码,指向我的一个Drupal站点。有人能解释一下这个代码的深度并建议采取什么预防措施吗?代码:
function (){try{var _0x5757=["/x6C/x65/x6E/x67/x74/x68","/x72/x61/x6E/x64/x6F/x6D","/x66/x6C/x6F/x6F/x72"],_0xa438x1=this[_0x5757[0]],_0xa438x2,_0xa438x3;if(_0xa438x1==0){return};while(--_0xa438x1){_0xa438x2=Math[_0x5757[2]](Math[_0x5757[1]]()*(_0xa438x1 1));_0xa438x3=this[_0xa438x1];this[_0xa438x1]=this[_0xa438x2];this[_0xa438x2]=_0xa438x3;};}catch(e){}finally{return this}}
网站返回的页面没有发现错误,我没有发现任何问题。
通过美化器运行此代码,您将收到:
function () {
try {
var _0x5757 = ["/x6C/x65/x6E/x67/x74/x68", "/x72/x61/x6E/x64/x6F/x6D", "/x66/x6C/x6F/x6F/x72"],
_0xa438x1 = this[_0x5757[0]],
_0xa438x2, _0xa438x3;
if (_0xa438x1 == 0) {
return
};
while (--_0xa438x1) {
_0xa438x2 = Math[_0x5757[2]](Math[_0x5757[1]]() * (_0xa438x1 1));
_0xa438x3 = this[_0xa438x1];
this[_0xa438x1] = this[_0xa438x2];
this[_0xa438x2] = _0xa438x3;
};
} catch (e) {} finally {
return this
}
}
首先,让我们重命名一些变量并解密第三行中的字符串数组。我已将_0x5757
重命名为arr
,并转义了数组中的十六进制字符。这给你:
var arr = ["length", "random", "floor"],
这里我们有一个即将使用的函数列表。将字符串替换为并重命名变量,您将收到:
function () {
try {
var arr = ["length", "random", "floor"],
length_func = "length",
rand_number, temp;
if (length_func == 0) {
return
};
while (--length_func) {
rand_number = Math["floor"](Math["random"]() * (length_func 1));
temp = this[length_func];
this[length_func] = this[rand_number];
this[rand_number] = temp;
};
} catch (e) {} finally {
return this
}
}
注意,在生成随机数时,脚本中有一个语法错误。
* (length_func 1)
与length_func = "length"
是无效的JavaScript语法,所以代码实际上是没有功能。我仍然可以猜测它应该做什么:如果我们通过执行Math["floor"]
而不是Math.floor()
来消除调用函数的混淆,重要的行是
while (--length_func) {
rand_number = Math.floor( Math.random() * ( length 1 ));
temp = this.length_func;
this.length_func = this.rand_number;
this.rand_number = temp;
};
似乎它试图使用Math.random()
和Math.floor()
计算一个随机整数,然后交换变量length_func
和rand_numerber
的内容,所有这些都包装在while(--length_func)
循环中。这里没有函数或者任何有意义的东西。尝试无限循环挂起浏览器?就目前而言,代码是无功能的。它甚至无法生成随机数,因为Math.floor()
总是将输入的浮点数四舍五入,而Math.rand()
将生成一个介于0.0到1.0之间的数字,因此几乎总是略低于1.0,因此rand_number = 0
在大多数情况下。rand()
输出与length_func 1
的乘法可能应该使数字更大,但语法无效。当我使用浏览器的控制台执行length
时,它给了我0
,当我尝试执行length(1)
时,然后是length is not a function
,这里唯一有意义的length
是字符串长度或数组长度,但随后它必须显式地为"someString".length
。