消息详情
暗夜之界 | Hacker技术 SQL · @AZQVQ · 2026年11月9日 15:54
影响版本: 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 代码
相關消訊
- $templet = preg_replace("/[.]+[\/\\\\]+/", "/", $templet); if(empty($dopos…
- function SaveTo($filename) { $fp = @fopen($filename,"w") or die("DedeT…
- 代码分析 漏洞文件:/dede/makehtml_homepage.php 代码 else if($dopost=="make") { $re…
- #!/usr/bin/env python3 import struct # PostgreSQL 页面大小 8KB PG_PAGE_SIZE = 8192…
- def main(): # 解析命令行参数 parser = argparse.ArgumentParser(description='P…
- #!/usr/bin/env python3 import argparse import struct import csv import base64 f…
- 4 仅用SELECT语句实现远程代码执行 4.0 读取原始postgresql.conf配置文件 完成 RCE 第一步是下载原始配置文件。目前已是超管可直接通…
- 区块结构 区块是一种记录交易的数据结构,每个区块由区块头和区块主体组成,区块主体负责记录前一段时间内的所有交易信息,区块链的大部分功能都由区块头实现,区块头数…
- Telegram必备的搜索引擎,极搜JISOU帮你精准找到,想要的群组、频道、视频、音乐 👉 t.me/jisou2?start=a_8315722010
- Telegram必备的搜索引擎,极搜JISOU帮你精准找到,想要的群组、频道、视频、音乐 👉 t.me/jisou2?start=a_8315722010