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 ...
随机推荐
- jquery选择器空格与大于号、加号与波浪号的区别
空格:$('parent childchild')表示获取parent下的所有的childchild节点,所有的子孙. 大于号:$('parent > child')表示获取parent下的所有 ...
- 通过js动态生成页面表格
var redlineTemplateP = $(".redlineDataList"); for (var index in detailArraryLists.rows){ v ...
- visual studio 2012 的制作ActiveX、打包和发布
开发环境是Vs 2012 Framework 4.0 源码和制作工具在文章最下边 一. ActiveX控件Demo 新建一个Window窗体控件库项目 在自动生成的UserControl1页面上添加 ...
- 2015/11/9用Python写游戏,pygame入门(8):按钮和游戏结束
昨天没有更新内容,今天相对多写一些. 因为我们已经基本完成游戏框架,但是游戏结束后,并不知道怎样比较好开始.我本来本着懒的原则,想结束后显示一个黑屏,然后你重新点一下鼠标就重新开始.但是那样实在太不像 ...
- Sentinel-Redis高可用方案(二):主从切换
Redis 2.8版开始正式提供名为Sentinel的主从切换方案,Sentinel用于管理多个Redis服务器实例,主要负责三个方面的任务: 1. 监控(Monitoring): Senti ...
- SQLite剖析之内核研究
先从全局的角度把握SQLite内核各个模块的设计和功能.SQLite采用了层次化.模块化的设计,而这些使得它的可扩展性和可移植性非常强.而且SQLite的架构与通用DBMS的结构差别不是很大,所以它对 ...
- 准确率(Accuracy), 精确率(Precision), 召回率(Recall)和F1-Measure
yu Code 15 Comments 机器学习(ML),自然语言处理(NLP),信息检索(IR)等领域,评估(Evaluation)是一个必要的 工作,而其评价指标往往有如下几点:准确率(Accu ...
- pdo知识总结
PDO 用了这么久了这里抽时间总结下: pdo (php data object) 是php5 新出来的支持 mysql 操作的一个功能.用其可代替mysqli扩展.因为是php自带的.所以我觉得效率 ...
- C语言变参数函数
#include<iostream> #include<stdarg.h> using namespace std; int sum(int cnt, ...){ va_lis ...
- C#高级特性_Attribute
Attribute: 公共语言运行时允许你添加类似关键字的描述声明,叫做attributes, 它对程序中的元素进行标注,如类型.字段.方法和属性等.Attributes和Microsoft .NET ...