DedeCms 基于PHP+MySQL的技术开发,支持Windows、Linux、Unix等多种服务器平台,从2004年开始发布第一个版本开始,至今已经发布了五个大版本。DedeCms以简单、健壮、灵活、开源几大特点占领了国内CMS的大部份市场,目前已经有超过二十万个站点正在使用DedeCms或居于 DedeCms核心,是目前国内应用最广泛的php类CMS系统。
article_add.php
1. ........................
2. else if($dopost=='save')
3. {
4. include(DEDEMEMBER.'/inc/archives_check.php');
5.
6. //分析处理附加表数据
7. $inadd_f = $inadd_v = '';
8. if(!emptyempty($dede_addonfields))
9. {
10. $addonfields = explode(';',$dede_addonfields);
11. ............................................ //省略部份代码
12. $inadd_f .= ','.$vs[0];
13. $inadd_v .= " ,'".${$vs[0]}."' ";
14. }
15. }
16. }
17. ..........................................
18. $addtable = trim($cInfos['addtable']);
19. if(emptyempty($addtable))
20. {
21. ......................................
22. }
23. else
24. {
25. $inquery = "INSERT INTO `{$addtable}`(aid,typeid,userip,redirecturl,templet,body{$inadd_f}) Values('$arcID','$typeid','$userip','','','$body'{$inadd_v})";
26. if(!$dsql->ExecuteNoneQuery($inquery))
27. {
28. ..........................................
29. }
30. }
31. ..........................................
32. $artUrl = MakeArt($arcID,true); //利用地方(arc.archives.functions.php有定义)
33.
34.
35. function MakeArt($aid,$ismakesign=false)
36. {
37. global $cfg_makeindex,$cfg_basedir,$cfg_templets_dir,$cfg_df_style;
38. include_once(DEDEINC.'/arc.archives.class.php');
39. if($ismakesign)
40. {
41. $envs['makesign'] = 'yes';
42. }
43. $arc = new Archives($aid);
44. $reurl = $arc->MakeHtml(); //arc.archives.class.php有定义
45. ............................
46. }
arc.archives.class.php
1. class Archives
2. {
3. ................
4. function __construct($aid)
5. {
6. ............
7. if($this->ChannelUnit->ChannelInfos['addtable']!='')
8. {
9. $query = "SELECT * FROM `{$this->ChannelUnit->ChannelInfos['addtable']}` WHERE `aid` = '$aid'";
10. $this->addTableRow = $this->dsql->GetOne($query);
11. }
12. ........................
13. if($this->ChannelUnit->ChannelInfos['addtable']!='' && $this->ChannelUnit->ChannelInfos['issystem']!=-1)
14. {
15. if(is_array($this->addTableRow))
16. {
17. ...............................
18. $this->Fields['templet'] = $this->addTableRow['templet'];//注意1
19. ......................................
20. }
21. }
22. .............................
23. }
24.
25. function MakeHtml($isremote=0)
26. {
27. global $cfg_remote_site,$fileFirst;
28. if($this->IsError)
29. {
30. return '';
31. }
32. $this->Fields["displaytype"] = "st";
33. //预编译$th
34. $this->LoadTemplet(); //触发1
35.
36. ......................................//省略部份代码
37. $this->ParseDMFields($i,1);
38. $this->dtp->SaveTo($truefilename); //触发2
39. ......................................
40. }
41. 继续跟(触发1)$this->LoadTemplet(); //arc.archives.class.php有定义
42.
43. function LoadTemplet()
44. {
45. if($this->TempSource=='')
46. {
47. $tempfile = $this->GetTempletFile(); //注意2
48. if(!file_exists($tempfile) || !is_file($tempfile))
49. {
50. echo "文档ID:{$this->Fields['id']} - {$this->TypeLink->TypeInfos['typename']} - {$this->Fields['title']}<br />";
51. echo "模板文件不存在,无法解析文档!";
52. exit();
53. }
54. $this->dtp->LoadTemplate($tempfile); //触发3
55. $this->TempSource = $this->dtp->SourceString;
56. }
57. else
58. {
59. $this->dtp->LoadSource($this->TempSource);
60. }
61. }
62.
63. 看注意2 的$this->GetTempletFile() //arc.archives.class.php有定义
64.
65. function GetTempletFile()
66. {
67. global $cfg_basedir,$cfg_templets_dir,$cfg_df_style;
68. $cid = $this->ChannelUnit->ChannelInfos['nid'];
69. if(!emptyempty($this->Fields['templet'])) //注意3
70. {
71. $filetag = MfTemplet($this->Fields['templet']);
72. if( !ereg('/', $filetag) ) $filetag = $GLOBALS['cfg_df_style'].'/'.$filetag;
73. }
74. else
75. {
76. $filetag = MfTemplet($this->TypeLink->TypeInfos["temparticle"]);
77. }
78. .......................................
79. if($cid=='spec')
80. {
81. if( !emptyempty($this->Fields['templet']) )
82. {
83. $tmpfile = $cfg_basedir.$cfg_templets_dir.'/'.$filetag;
84. }
85. else
86. {
87. $tmpfile = $cfg_basedir.$cfg_templets_dir."/{$cfg_df_style}/article_spec.htm";
88. }
89. }
90. ...........................................
91. return $tmpfile;
92. }
注意3中的值来自注意1是通过查表得来的,控制了它就等于控制了任意模板,然后通过触发3来触发漏洞
看下怎么控制注意1的值
article_edit.php
1. ......................
2. else if($dopost=='save')
3. { ....................
4. if(!emptyempty($dede_addonfields))
5. {
6. $addonfields = explode(';',$dede_addonfields);
7. if(is_array($addonfields))
8. {
9. ........................
10. ${$vs[0]} = GetFieldValueA(${$vs[0]},$vs[1],$aid);
11. $inadd_f .= ','.$vs[0]." ='".${$vs[0]}."' ";
12.
13. }
14. }
15. ...................
16. if($addtable!='')
17. {
18. $upQuery = "Update `$addtable` set typeid='$typeid',body='$body'{$inadd_f},userip='$userip' where aid='$aid' ";
19. if(!$dsql->ExecuteNoneQuery($upQuery))
20. {..............
21. }
22. }
23. ....................
24. }
$dede_addonfields没有过滤,我们可以构造$inadd_f为,templet='上传的模板图片地址',包含我们的图片后,再通过触发2来生成图片里的后门!
DEDECMS 5.3/5.6
厂商补丁:
DEDECMS
------------
目前厂商还没有提供补丁或者升级程序,我们建议使用此软件的用户随时关注厂商的主页以获取最新版本:
http://www.dedecms.com/
暂无评论