织梦DedeCms5.3/5.6最新Get Shell漏洞
这个漏洞很早就被人公布了,可惜我现在才注意到,不过目前对我的网站没什么影响,因为开启了会员功能才会遭到恶意攻击。
下面漏洞描述转自php100。
漏洞描述:
DedeCms 基于PHP+MySQL的技术开发,支持Windows、Linux、Unix等多种服务器平台,从2004年开始发布第一个版本开始,至今已经发布了五个大版本。DedeCms以简单、健壮、灵活、开源几大特点占领了国内CMS的大部份市场,目前已经有超过二十万个站点正在使用DedeCms或居于 DedeCms核心,是目前国内应用最广泛的php类CMS系统。
article_add.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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
........................
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->ParseDMFields($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']}<br />"; 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来生成图片里的后门! |
上面是漏洞的成因,如何执行漏洞这里就不写了,也不要问我具体怎么操作。想了解的自己到网上搜索一下,目前官方还没出新的补丁,开启了会员功能的朋友要注意做好备份了。
相关仿站教程:
- 相关链接:
- 教程说明:
织梦DedeCms5.3/5.6最新Get Shell漏洞
。