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 ...
随机推荐
- 前端见微知著AngularJS备忘篇:温故而知新,可以为师矣
话说以前JQuery刚出来的时候,真的是对个人的冲击蛮大的.记得当时我买的第一本书就是<锋利的JQuery>,藉由这本书开始,我从此以后的项目基本用上了JQuery,其给我带来的便利性是不 ...
- 别出心裁的Linux系统调用学习法
别出心裁的Linux系统调用学习法 操作系统与系统调用 操作系统(Operating System,简称OS)是计算机中最重要的系统软件,是这样的一组系统程序的集成:这些系统程序在用户对计算机的使用中 ...
- Webwork 学习之路【03】核心类 ServletDispatcher 的初始化
1. Webwork 与 Xwork 搭建环境需要的的jar 为:webwork-core-1.0.jar,xwork-1.0.jar,搭建webwork 需要xwork 的jar呢?原因是这样的,W ...
- Word 打包 zip 并提供下载
该篇博客记录Java Web项目将word打包zip并提供下载功能的实现和其中遇到的坑,方便后续自己的查看的参照. 1. 后台处理的java 方法 首先将所有的word生成到uploadword目录下 ...
- 如何禁止IE自动生成链接
今天一位园友反馈,他用的是IE浏览器,在博客后台编辑器中输入下面的URL: http://www.windowsphone.com/zh-cn/store/app/博客园-uap/500f08f0-5 ...
- [leetcode]算法题目 - Sudoku Solver
最近,新加坡总理李显龙也写了一份代码公布出来,大致瞧了一眼,竟然是解数独题的代码!前几天刚刚写过,数独主要算法当然是使用回溯法.回溯法当时初学的时候在思路上比较拧,不容易写对.写了几个回溯法的算法之后 ...
- Web Audio API 实现音频可视化
声明:本文为原创文章,如需转载,请注明来源WAxes,谢谢! 一转眼就已经有三个月没写博客了,毕业季事情确实多,现在也终于完全毕业了,博客还是不能落下.偶尔还是要写一下. 玩HTML5的Audio A ...
- MVC-通过对象获取整个表单内容
-------- 在MVC的Controller(控制器)里面定义相同的方法时,我们需要解决重载问题: 解决方案一:在参数中定义一个FormCollection类型,解决问题 [HttpSet] pu ...
- python代码缩进
习惯了java,c++之类的宽容,初学python,被它摆了道下马威,写if else,竟然必须要我正确用缩进格式,原来在python里不能用括号来表示语句块,也不能用开始/结束标志符来表示,而是靠缩 ...
- VMWare虚拟机提供的桥接、nat和主机模式的区别
虚拟机网络模式 无论是vmware,virtual box,virtual pc等虚拟机软件,一般来说,虚拟机有三种网络模式: 1.桥接 2.NAT 3.Host-Only 哪一种网络是适合自己的虚拟 ...