選擇語言
繁體中文
繁體中文 Traditional Chinese
简体中文
简体中文 Simplified Chinese
English
English English
日本語
日本語 Japanese
AI 助手

今日情報速問。不用選範圍,直接問今天值得看什麼。

完整分析

通知訊訊

暫無新訊訊

影响版本: DeDeCMS <=5.7.115   代码分析 漏洞文件:  dede/task_do.php 代码 if($dopost=='makeindex') {     require_once(DEDEINC.'/arc.partview.class.php');     $envs = $_sys_globals = array();     $envs['aid'] = 0;     $pv = new PartView();     $row = $pv->dsql->GetOne('SELECT * FROM `#@__homepageset`');     $templet = str_replace("{style}", $cfg_df_style, $row['templet']);     $homeFile = dirname(__FILE__).'/'.$row['position'];     $homeFile = str_replace("//", "/", str_replace("\\", "/", $homeFile));     $fp = fopen($homeFile, 'w') or die("无法更新网站主页到:$homeFile 位置");     fclose($fp);     $tpl = $cfg_basedir.$cfg_templets_dir.'/'.$templet;     if(!file_exists($tpl))     {         $tpl = $cfg_basedir.$cfg_templets_dir.'/default/index.htm';         if(!file_exists($tpl)) exit("无法找到主页模板:$tpl ");     }     $GLOBALS['_arclistEnv'] = 'index';     $pv->SetTemplet($tpl);     $pv->SaveToHtml($homeFile);     $pv->Close(); 其中进一步深入分析 $pv->SetTemplet($tpl)和  $pv->SaveToHtml($homeFile); $pv->SetTemplet($tpl); 跟进去 代码 function SetTemplet($temp,$stype="file") {     if($stype=="string")     {         $this->dtp->LoadSource($temp);     }     else     {         $this->dtp->LoadTemplet($temp);  //进入到这里     }     if($this->TypeID > 0)     {         $this->Fields['position'] = $this->TypeLink->GetPositionLink(TRUE);         $this->Fields['title'] = $this->TypeLink->GetPositionLink(false);     }     $this->ParseTemplet(); } 代码 function LoadTemplet($filename) {     $this->LoadTemplate($filename);//继续跟进 } 代码 function LoadTemplate($filename) {     $this->SetDefault();     if(!file_exists($filename))     {         $this->SourceString = " $filename Not Found! ";         $this->ParseTemplet();     }     else     {         while($line = fgets($fp,1024))  //将文件内容赋值给$line         {             $this->SourceString .= $line;  //最后赋予$this->SourceString         }         fclose($fp);         if($this->LoadCache($filename))         {             return '';         }         else         {             $this->ParseTemplet();         }     } } 上面将读取到的文件内容赋值给$this->SourceString $pv->SaveToHtml($homeFile); 这行代码跟进 代码 function SaveToHtml($filename,$isremote=0) {     global $cfg_remote_site;     _//__如果启用远程发布则需要进行判断_    if($cfg_remote_site=='Y' && $isremote == 1)     {         _//__分析远程文件路径_        $remotefile = str_replace(_DEDEROOT_, '', $filename);         $localfile = '..'.$remotefile;         _//__创建远程文件夹_        $remotedir = preg_replace('/[^\/]*\.js/', '', $remotefile);         $this->ftp->rmkdir($remotedir);         $this->ftp->upload($localfile, $remotefile, 'ascii');     }     $this->dtp->SaveTo($filename);   //跟进到这里 } 代码 function SaveTo($filename) {     $fp = @fopen($filename,"w") or die("DedeTag Engine Create File False: {$filename}");     fwrite($fp,$this->GetResult());  //写入功能 继续跟进去看将什么内容写入了     fclose($fp); } function GetResult() {     $ResultString = '';     if($this->Count==-1)   //这里由于$Count 的值已经定义为-1 所以在这里被赋值     {         return $this->SourceString;    //之前templet的文件内容被赋值到$this->SourceString中     }     $this->AssignSysTag();     $nextTagEnd = 0;     $strok = "";     for($i=0;$i<=$this->Count;$i++)     {         $ResultString .= substr($this->SourceString,$nextTagEnd,$this->CTags[$i]->StartPos-$nextTagEnd);         $ResultString .= $this->CTags[$i]->GetValue();         $nextTagEnd = $this->CTags[$i]->EndPos;     }     $slen = strlen($this->SourceString);     if($slen>$nextTagEnd)     {         $ResultString .= substr($this->SourceString,$nextTagEnd,$slen-$nextTagEnd);     }     return $ResultString;  //最后返回内容 将templet传入的文件内容写入到了$homeFile中也就是传入的position指定的文件中 } 分析完这两个方法得知这是读取$tpl文件内容并写入到$homeFile的一个操作 并且分析代码得知 这两个的值都是从数据库中取出   所以接下来就是看 有没有其他功能 能改写数据库中这个表中的对应的值  看这个值是否可控  全局搜索发现此处存在sql语句更新表中内容   文件  dede/makehtml_homepage.php 代码