dedeCMS /data/mysql_error_trace.php DB error raised PHP Code Injection Via /include/dedesql.class.php Log FIle Without Access Validation
目录
. 漏洞描述
. 漏洞触发条件
. 漏洞影响范围
. 漏洞代码分析
. 防御方法
. 攻防思考
1. 漏洞描述
dedecms采用面向对象封装的方式实现了功能操作的模块集中化,例如对于数据库管理
. /include/dedesql.class.php: mysql数据库操作
. /include/dedesqli.class.php: mysqli数据库操作
当发生数据库操作语句执行错误的时候,框架代码会集中对错误相关信息进行收集,并保存到一个指定的文件中(/data/mysql_error_trace.php),但是这里存在一个安全上的漏洞
. MySQL字段数值采用了C语言同样的定义,当传入的数值大于字段定义的类型的时候,将引发整型上溢出错误 . /data/mysql_error_trace.php没有进行正确的访问认证
/*
security practice
在不需要被访问的日志文件头应该加上以下代码
die('Request Error!');
or
exit();
*/ . 日志文件最好使用例如".txt"的文本文件进行保存
真正导致漏洞的原因是数据库处理库(/include/dedesql.class.php),而触发这个漏洞的文件有很多,攻击向量路径很多,理论上只要调用了如下代码即存在漏洞
/*
$dsql->ExecuteNoneQuery("Update `$maintable` set scores = scores + {$cfg_caicai_add},goodpost=goodpost+1,lastpost=".time()." where id=$id");
*/
目前已知的可以成为攻击向量的文件有
. /plus/digg_frame.php
. /plus/digg_ajax.php
. /plus/comments_frame.php
Relevant Link:
http://icarusli.iteye.com/blog/610715
http://www.007hack.com/?p=522
2. 漏洞触发条件
3. 漏洞影响范围
. < dede 5.7
4. 漏洞代码分析
/include/dedesql.class.php
//显示数据链接错误信息
function DisplayError($msg)
{
$errorTrackFile = dirname(__FILE__).'/../data/mysql_error_trace.inc';
//这里将日志文件的后缀改为了.inc,是一个好的防御方法
if( file_exists(dirname(__FILE__).'/../data/mysql_error_trace.php') )
{
@unlink(dirname(__FILE__).'/../data/mysql_error_trace.php');
}
$emsg = '';
$emsg .= "<div><h3>DedeCMS Error Warning!</h3>\r\n";
$emsg .= "<div><a href='http://bbs.dedecms.com' target='_blank' style='color:red'>Technical Support: http://bbs.dedecms.com</a></div>";
$emsg .= "<div style='line-helght:160%;font-size:14px;color:green'>\r\n";
$emsg .= "<div style='color:blue'><br />Error page: <font color='red'>".$this->GetCurUrl()."</font></div>\r\n";
$emsg .= "<div>Error infos: {$msg}</div>\r\n";
$emsg .= "<br /></div></div>\r\n"; echo $emsg; $savemsg = 'Page: '.$this->GetCurUrl()."\r\nError: ".$msg;
//保存MySql错误日志
$fp = @fopen($errorTrackFile, 'a');
//直接将错误信息写入了可执行的.PHP文件中
@fwrite($fp, '<'.'?php'."\r\n/*\r\n{$savemsg}\r\n*/\r\n?".">\r\n");
@fclose($fp);
}
5. 防御方法
//显示数据链接错误信息
function DisplayError($msg)
{
$errorTrackFile = dirname(__FILE__).'/../data/mysql_error_trace.inc';
if( file_exists(dirname(__FILE__).'/../data/mysql_error_trace.php') )
{
@unlink(dirname(__FILE__).'/../data/mysql_error_trace.php');
}
$emsg = '';
$emsg .= "<div><h3>DedeCMS Error Warning!</h3>\r\n";
$emsg .= "<div><a href='http://bbs.dedecms.com' target='_blank' style='color:red'>Technical Support: http://bbs.dedecms.com</a></div>";
$emsg .= "<div style='line-helght:160%;font-size:14px;color:green'>\r\n";
$emsg .= "<div style='color:blue'><br />Error page: <font color='red'>".$this->GetCurUrl()."</font></div>\r\n";
$emsg .= "<div>Error infos: {$msg}</div>\r\n";
$emsg .= "<br /></div></div>\r\n"; echo $emsg; $savemsg = 'Page: '.$this->GetCurUrl()."\r\nError: ".$msg."\r\nTime".date('Y-m-d H:i:s');
//保存MySql错误日志
$fp = @fopen($errorTrackFile, 'a');
@fwrite($fp, '<'.'?php' . "\r\n" . "die('Request Error!');" . "\r\n/*\r\n{$savemsg}\r\n*/\r\n?".">\r\n");
@fclose($fp);
}
6. 攻防思考
Copyright (c) 2014 LittleHann All rights reserved
dedeCMS /data/mysql_error_trace.php DB error raised PHP Code Injection Via /include/dedesql.class.php Log FIle Without Access Validation的更多相关文章
- dedeCMS /plus/ad_js.php、/plus/mytag_js.php Vul Via Injecting PHP Code By /plus/download.php Into DB && /include/dedesql.class.php
目录 . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 对于这个漏洞,我们可以简单概括如下 . "/plus/download. ...
- dedecms data文件夹外迁
出于网站安全考虑,我们一般要把data文件夹迁移到网站根目录外面. dedecms data文件夹外迁方法: 1. 修改首页文件中配置文件路径 打开/index.php,把代码 if(!file_ex ...
- Data access between different DBMS and other txt/csv data source by DB Query Analyzer
1 About DB Query Analyzer DB Query Analyzer is presented by Master Genfeng,Ma from Chinese Mainl ...
- Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'系列一:
从库报这个错误:Got fatal error 1236 from master when reading data from binary log: 'Could not find first lo ...
- 元数据管理器中存在错误。 实例化来自文件“\\?\C:\Program Files\Microsoft SQL Server\MSAS11.MSSQLSERVER\OLAP\Data\Tfs_Analysis.0.db\vDimTestCaseOverlay.874.dim.xml”的元数据对象时出错。
一.发现问题 启动SQLSERVER的数据分析服务失败 查看系统日志错误如下: 双击错误后显示详细错误: 元数据管理器中存在错误. 实例化来自文件“\\?\C:\Program Files\Micro ...
- mysql从库Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'报错处理
年后回来查看mysql运行状况与备份情况,登录mysql从库查看主从同步状态 mysql> show slave status\G; *************************** . ...
- hive sequencefile导入文件遇到FAILED: SemanticException Unable to load data to destination table. Error: The file that you are trying to load does not match the file format of the destination table.错误
hive sequencefile导入文件遇到FAILED: SemanticException Unable to load data to destination table. Error: Th ...
- Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'
setup slave from backup i got error Got fatal error 1236 from master when reading data from binary l ...
- How to Fix "Linux Failure to Download extra data files for ttf-mscorefonts-installer" error
How to Fix "Linux Failure to Download extra data files for ttf-mscorefonts-installer" erro ...
随机推荐
- 韩国网页设计资料《网页设计大师2》JPG+PSD+TXT等 73.89G 百度云下载
< 网页设计大师2 >超越第一代版本,提供更新更精美的网页素材模板.全部由国际顶级设计师精选打造,完全展示走在潮流 之前的设计风格.是网页设计师/UI交互界面设计师必备工具. < 网 ...
- 命令行下 mysql 不是内部或外部命令排查方法
首先确定你没有更改过MySQL的安装目录.如果你进行过改名或者更改了你的路径,那么要在相应的配置文件中更改你的你路径.找到C:\Windows\my.ini文件,更改你配置的文件路径,改成你修改后的路 ...
- 前端科普文—为什么<!DOCTYPE> 不可或缺
When question comes 你一定在 HTML 页面最前面看到过这样一行代码(比如 百度): <!DOCTYPE html> 或者说类似这样的(比如 博客园-韩子迟 PS:博客 ...
- Koa框架实践与中间件原理剖析
最近尝试用了一下Koa,并在此记录一下使用心得. 注意:本文是以读者已经了解Generator和Promise为前提在写的,因为单单Generator和Promise都能够写一篇博文来讲解介绍了,所 ...
- 20160223 - Windows 10 的文件资源管理器下出现重复文件夹的解决办法
现象: 安装 OneDrive 从 Windows 7.8.8.1 升级来的 Windows 10 的电脑,可能会出现文件资源管理器左侧面板中出现重复的文件夹. 通常有:视频.图片.文档.下载.音频. ...
- linux | 管道符、输出重定向
1 输出重定向 ll > a.txt 将 ll的结果写入到a.txt 2 管道符 ls -la | grep h* 这条命令的理解为:ls -la 的结果作为gerp h* 的结果 gerp 是 ...
- 【Python】[函数式编程]高阶函数,返回函数,装饰器,偏函数
函数式编程高阶函数 就是把函数作为参数的函数,这种抽象的编程方式就是函数式编程.--- - -跳过,不是很理解,汗 - ---
- 【JavaEE企业应用实战学习记录】logFilter
package sanglp.servlet; import javax.servlet.*; import javax.servlet.annotation.WebFilter; import ja ...
- 64-who 简明笔记
显示已登录用户的信息 who [options] who am i who程序显示在本地系统上登录的用户的信息.这些信息包括每个用户的用户名.终端设备.登录时间和相应的远程主机名(如果可应用) 参数 ...
- js浏览器窗口
一.clientwidth和clientheight 注:返回了元素大小,但没有单位,默认单位是 px,如果你强行设置了单位,比如 100em之类,它还是会返回 px的大小. (CSS获取的话,是照着 ...