大米CMS官网:http://www.damicms.com
网站源码版本:大米CMS_V5.5.3试用版(更新时间:2017-04-15)
程序源码下载:http://www.damicms.com/downes/dami.rar
测试网站首页:

1、首先来看一下全局过滤代码/php_safe.php 第24-33行中:
//$ArrPGC=array_merge($_GET,$_POST,$_COOKIE);
foreach($_GET as $key=>$value){
StopAttack($key,$value,$getfilter);
}
foreach($_POST as $key=>$value){
StopAttack($key,$value,$postfilter);
}
foreach($_COOKIE as $key=>$value){
StopAttack($key,$value,$cookiefilter);
10. }
这段函数对GET,_GET,GET,_POST,COOKIE等全局变量调用StopAttack函数进行处理,可以发现如果是从_COOKIE等全局变量调用StopAttack函数进行处理,可以发现如果是从COOKIE等全局变量调用StopAttack函数进行处理,可以发现如果是从_REQUEST获取参数,那么将绕过全局过滤防护。
2、漏洞文件位置1:/Admin/Lib/Action/MemberAction.class.php 第93-110行中:
function cartlist(){
$model = D('TradeView');
import('ORG.Util.Page');
$where ='';
if(!empty($_REQUEST['start_time']) && !empty($_REQUEST['end_time'])){
$where .= 'member_trade.addtime>='.strtotime($_REQUEST['start_time']." 00:00:00").' and member_trade.addtime<='.strtotime($_REQUEST['end_time']." 23:59:59")." and ";
}
else if(!empty($_REQUEST['start_time']) && empty($_REQUEST['end_time'])){
$where .= 'member_trade.addtime>='.strtotime($_REQUEST['start_time']." 00:00:00").' and member_trade.addtime<='.strtotime($_REQUEST['start_time']." 23:59:59")." and ";
10. }
11. else if(empty($_REQUEST['start_time']) && !empty($_REQUEST['end_time'])){
12. $where .= 'member_trade.addtime>='.strtotime($_REQUEST['end_time']." 00:00:00").' and member_trade.addtime<='.strtotime($_REQUEST['end_time']." 23:59:59")." and ";
13. }
14. if(!empty($_REQUEST['keyword'])){
15. $where .= "article.title like '%".htmlspecialchars(trim($_REQUEST['keyword']))."%' and ";
16. }
17. $where .='1=1';
18. $count = $model->where($where)->count();
19. $p = new Page($count,20);
2、漏洞文件位置2:/Admin/Lib/Action/MemberAction.class.php 第126-135行中:
function userlist(){
$model = M('member');
import('ORG.Util.Page');
$where ='';
if(!empty($_REQUEST['keyword'])){
$where .= "(username like '%".htmlspecialchars(trim($_REQUEST['keyword']))."%' or realname like '%".htmlspecialchars(trim($_REQUEST['keyword']))."%' or address like '%".htmlspecialchars(trim($_REQUEST['keyword']))."%') and ";
}
$where .='1=1';
$count = $model->where($where)->count();$p = new Page($count,20);
在这两个函数中,将获取到的$_REQUEST[‘keyword’]参数拼接到SQL语句,然后带入数据库执行,导致程序在实现上存在SQL注入漏洞,攻击者可利用该漏洞获取数据库敏感信息。
1、登录后台,网站后台–会员系统–会员管理–关键字搜索–注入点:
SQLMAP注入测试:

1、使用参数化查询避免SQL注入