我的网站中存在恶意 JavaScript 代码

发布于 2024-08-28 22:46:38 字数 978 浏览 3 评论 0原文

我在我的网站源代码中找到了这段代码:

var _0xd28d=["\x5F\x30\x78\x33\x32\x6C\x73\x6A\x39","\x5F\x78\x6C\x74","\x5F\x78\x38\x66\x6B\x63\x33","\x66\x6C\x6F\x6F\x72","\x72\x61\x6E\x64\x6F\x6D","\x6C\x65\x6E\x67\x74\x68"];
var _0x9ae4=[_0xd28d[0],12,_0xd28d[1],_0xd28d[2],2,31,Math,_0xd28d[3]];
var _0xcd6e=[_0x9ae4[5],_0x9ae4[0],_0x9ae4[_0x9ae4[4]],_0x9ae4[3],4,_0xd28d[4]];
var _0xr6g0={};
_0xr6g0[_0xcd6e[2]]=0;
_0xr6g0[_0x9ae4[4]]=function (){
var _0x4c68x4={};
_0x4c68x4[_0xd28d[0]]=_0x9ae4[0];
do{
_0x4c68x4[_0x9ae4[0]]+=_0x4c68x4[_0xd28d[0]][_0x9ae4[6][_0x9ae4[7]](_0x9ae4[6][_0xcd6e[5]]()*_0x4c68x4[_0xd28d[0]][_0xd28d[5]])];
}while(_0x4c68x4[_0xd28d[0]][_0xd28d[5]]<_0xcd6e[0]);
_0x4c68x4[_0x4c68x4[_0x9ae4[0]]]=function (){
_0xr6g0[_0xcd6e[2]]++;
_0xr6g0[_0xcd6e[2]]%=_0x9ae4[1];
return _0x4c68x4[_0x4c68x4[_0x9ae4[0]]];
};
return _0x4c68x4[_0x4c68x4[_0xcd6e[1]]];
};
_0xr6g0[_0x9ae4[_0xcd6e[4]]]()()()()()()()()()()()()()()()();

我想知道,它是什么?它有什么作用?

I found this code in my website sourcecode:

var _0xd28d=["\x5F\x30\x78\x33\x32\x6C\x73\x6A\x39","\x5F\x78\x6C\x74","\x5F\x78\x38\x66\x6B\x63\x33","\x66\x6C\x6F\x6F\x72","\x72\x61\x6E\x64\x6F\x6D","\x6C\x65\x6E\x67\x74\x68"];
var _0x9ae4=[_0xd28d[0],12,_0xd28d[1],_0xd28d[2],2,31,Math,_0xd28d[3]];
var _0xcd6e=[_0x9ae4[5],_0x9ae4[0],_0x9ae4[_0x9ae4[4]],_0x9ae4[3],4,_0xd28d[4]];
var _0xr6g0={};
_0xr6g0[_0xcd6e[2]]=0;
_0xr6g0[_0x9ae4[4]]=function (){
var _0x4c68x4={};
_0x4c68x4[_0xd28d[0]]=_0x9ae4[0];
do{
_0x4c68x4[_0x9ae4[0]]+=_0x4c68x4[_0xd28d[0]][_0x9ae4[6][_0x9ae4[7]](_0x9ae4[6][_0xcd6e[5]]()*_0x4c68x4[_0xd28d[0]][_0xd28d[5]])];
}while(_0x4c68x4[_0xd28d[0]][_0xd28d[5]]<_0xcd6e[0]);
_0x4c68x4[_0x4c68x4[_0x9ae4[0]]]=function (){
_0xr6g0[_0xcd6e[2]]++;
_0xr6g0[_0xcd6e[2]]%=_0x9ae4[1];
return _0x4c68x4[_0x4c68x4[_0x9ae4[0]]];
};
return _0x4c68x4[_0x4c68x4[_0xcd6e[1]]];
};
_0xr6g0[_0x9ae4[_0xcd6e[4]]]()()()()()()()()()()()()()()()();

I was wondering, what is it? And What does it does?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

日记撕了你也走了 2024-09-04 22:46:38

代码本身没有任何有用或危险的作用。

手动反混淆后:

count = 0;
func_a = function() {
    func_b = function() {
        count++;
        count %= 12;
        return func_b;
    };
    return func_b;
};
func_a()()()()()()()()()()()()()()()();

看起来更像是让浏览器保持忙碌的无效尝试。但对于保持人们的好奇心非常有效。

更新:修复了反混淆。

By itself, the code does nothing useful nor dangerous.

After manually deobfuscating:

count = 0;
func_a = function() {
    func_b = function() {
        count++;
        count %= 12;
        return func_b;
    };
    return func_b;
};
func_a()()()()()()()()()()()()()()()();

Looks like more an invalid attempt to keep the browser busy. But very valid to keep people curious.

UPDATE: fixed the deobfuscation.

前 5 行初始化变量。解密 \x 转义并索引到其他数组后,我们得到:

_0xd28d = ['_0x32lsj9', '_xlt', '_x8fkc3', 'floor', 'random', 'length']
_0x9ae4 = ['_0x32lsj9', 12, '_xlt', '_x8fkc3', 2, 31, Math, 'floor']
_0xcd6e = [31, '_0x32lsj9', '_xlt', '_x8fkc3', 4, 'random']
_0xr6g0 = {'_xlt': 0}

第 6-18 行创建一个函数(扩展数组索引后):

_0xr6g0[2] = function() {
   var _0x4c68x4={};
   _0x4c68x4['_0x32lsj9'] = '_0x32lsj9';

   do{
      _0x4c68x4['_0x32lsj9']+=_0x4c68x4['_0x32lsj9'][Math['floor'](Math['random']()*_0x4c68x4['_0x32lsj9']['length'])];
   } while(_0x4c68x4['_0x32lsj9']['length'] < 31);

      _0x4c68x4[_0x4c68x4['_0x32lsj9']] = function (){
      _0xr6g0['_xlt']++;
      _0xr6g0['_xlt'] %= 12;
      return _0x4c68x4[_0x4c68x4['_0x32lsj9']];
   };

   return _0x4c68x4[_0x4c68x4['_0x32lsj9']];
};

Javascript 允许 a['b'] 作为 ab 的替代语法,因此这相当于:

 _0xr6g0[2] = function() {
   var _0x4c68x4 = {'_0x32lsj9': '_0x32lsj9'};

   do{
      _0x4c68x4._0x32lsj9 += _0x4c68x4._0x32lsj9[Math.floor(Math.random()*_0x4c68x4._0x32lsj9.length)];
   } while(_0x4c68x4._0x32lsj9.length < 31);

   _0x4c68x4[_0x4c68x4._0x32lsj9] = function (){
      _0xr6g0._xlt++;
      _0xr6g0._xlt %= 12;
      return _0x4c68x4[_0x4c68x4._0x32lsj9];
   };

   return _0x4c68x4[_0x4c68x4._0x32lsj9];
};

内部函数有一个随机生成的31个字符的名称,这并不重要,因此可以简化为:

_0xr6g0[2] = function() {
   function f()
   {
      _0xr6g0._xlt++;
      _0xr6g0._xlt %= 12;
      return f;
   };

   return f;
};

最后一行调用_0xr6g0[2] 16次,这是一种混淆方式写作的

_0xr6g0._xlt = 4

The first 5 lines initialize variables. After decrypting the \x escapes and indexing to other arrays, we get:

_0xd28d = ['_0x32lsj9', '_xlt', '_x8fkc3', 'floor', 'random', 'length']
_0x9ae4 = ['_0x32lsj9', 12, '_xlt', '_x8fkc3', 2, 31, Math, 'floor']
_0xcd6e = [31, '_0x32lsj9', '_xlt', '_x8fkc3', 4, 'random']
_0xr6g0 = {'_xlt': 0}

Lines 6-18 create a function (after expanding the array indexing):

_0xr6g0[2] = function() {
   var _0x4c68x4={};
   _0x4c68x4['_0x32lsj9'] = '_0x32lsj9';

   do{
      _0x4c68x4['_0x32lsj9']+=_0x4c68x4['_0x32lsj9'][Math['floor'](Math['random']()*_0x4c68x4['_0x32lsj9']['length'])];
   } while(_0x4c68x4['_0x32lsj9']['length'] < 31);

      _0x4c68x4[_0x4c68x4['_0x32lsj9']] = function (){
      _0xr6g0['_xlt']++;
      _0xr6g0['_xlt'] %= 12;
      return _0x4c68x4[_0x4c68x4['_0x32lsj9']];
   };

   return _0x4c68x4[_0x4c68x4['_0x32lsj9']];
};

Javascript allows a['b'] as an alternate syntax for a.b, so this is equivalent to:

 _0xr6g0[2] = function() {
   var _0x4c68x4 = {'_0x32lsj9': '_0x32lsj9'};

   do{
      _0x4c68x4._0x32lsj9 += _0x4c68x4._0x32lsj9[Math.floor(Math.random()*_0x4c68x4._0x32lsj9.length)];
   } while(_0x4c68x4._0x32lsj9.length < 31);

   _0x4c68x4[_0x4c68x4._0x32lsj9] = function (){
      _0xr6g0._xlt++;
      _0xr6g0._xlt %= 12;
      return _0x4c68x4[_0x4c68x4._0x32lsj9];
   };

   return _0x4c68x4[_0x4c68x4._0x32lsj9];
};

The inner function has a randomly-generated 31-character name that doesn't matter, so it can be simplified to:

_0xr6g0[2] = function() {
   function f()
   {
      _0xr6g0._xlt++;
      _0xr6g0._xlt %= 12;
      return f;
   };

   return f;
};

The last line calls _0xr6g0[2] 16 times, and this is an obfuscated way of writing

_0xr6g0._xlt = 4
掩耳倾听 2024-09-04 22:46:38

此代码中的十六进制正在创建一个包含文本“_0x32lsj9_xlt_x8fkc3floorrandomlength”的字符串,

其余部分正在解析该字符串以运行某种 JavaScript。

The hex in this code is creating a string with the text "_0x32lsj9_xlt_x8fkc3floorrandomlength"

The rest is parsing that to run some sort of javascript.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文