### 简要描述:
补了20140605
### 详细说明:
首先是个注入,这个漏洞比较无语,真正的无视过滤,没引号保护。。
漏洞位于bbs/add-archive.php:
```
<?php
require_once 'bbs_public.php';
//验证用户登陆相关操作
$admin = new action_admin();
$admin->check_login();
$category = db_bbs_category::getInstance();
$category_data = $category->getAll();
$cid = isset($_GET['cid']) ? intval($_GET['cid']) : 1 ;
$label = db_bbs_label::getInstance();
$lable_data = $label->getAll();
if(isset($_POST['submit'])){
if(strtolower(trim($_POST['verify'])) != strtolower($_SESSION['verify'])){
action_public::turnPage('index.php','验证码输入错误!');
}
$archive = db_bbs_archive::getInstance();
unset($_POST['submit']);
unset($_POST['verify']);
$_POST['username'] = $_COOKIE['login_username'];
$_POST['userid'] = $admin->userid;
$_POST['ip'] = $_SERVER['REMOTE_ADDR'];
$_POST['addtime'] = mktime();
if($id = $archive->inserData($_POST)){ //这里直接将表单中的值交给了insertData函数,我们跟进
action_public::turnPage('archive-display.php?aid='.$id,'文章添加成功');
}else{
action_public::turnPage('index.php','添加失败,请联系我们!');
}
}
?>
```
inserData函数代码:
```
public function inserData($data){
$r = $this->odb->insert($this->tblName,$data);//继续跟进
if($r)
return $this->odb->getInsertId();
else
return false;
}
```
insert函数代码:
```
public function insert($table, $data)
{
$sql = $this->getInsertString($table, $data);//这里跟进
return $this->execSql($sql);//执行sql语句
}
```
getInsertString函数代码:
```
public function getInsertString($table, $data)
{
$n_str = '';
$v_str = '';
$table = $this->filterString($table);
foreach ($data as $k => $v)
{
$n_str .= $this->filterString($k).',';//对key进行filter,跟进filter函数
$v_str .= "'".$this->filterString($v)."',";
}
$n_str = preg_replace( "/,$/", "", $n_str );
$v_str = preg_replace( "/,$/", "", $v_str );
$str = 'INSERT INTO '.$table.' ('.$n_str.') VALUES('.$v_str.')';
return $str;
}
```
filterString函数代码:
```
else {
$ret = @mysqli_real_escape_string($this->con, $str);//对单引号、双引号和一些字符进行了转义。
if ( strlen($str) && !isset($ret) ) {
$r = $this->checkConnection();
if ($r !== true) {
$this->closeDB();
$ret = $str;
}
}
return $ret;
}
```
构造查询语句时没有加引号保护,导致注入。
另外就是验证码的问题打包下发出来吧,见漏洞证明。
### 漏洞证明:
```
SQL注入漏洞
```
key的insert注入,构造exp还是费了点劲,看下结果吧:
1、bbs上发帖:
[<img src="https://images.seebug.org/upload/201407/0423444230bceb64963059aa1ac6aba331294d2d.jpg" alt="c1.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201407/0423444230bceb64963059aa1ac6aba331294d2d.jpg)
2、抓包在content后写上exp:
[<img src="https://images.seebug.org/upload/201407/04234522d56160f4d117624f55f17b14ef0b6d3d.jpg" alt="c2.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201407/04234522d56160f4d117624f55f17b14ef0b6d3d.jpg)
3.forward后看我们的帖子:
[<img src="https://images.seebug.org/upload/201407/04234551709ce9253c8cd21e2d8375aca4c5b93a.jpg" alt="c3.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201407/04234551709ce9253c8cd21e2d8375aca4c5b93a.jpg)
```
验证码漏洞打包
```
首先以论坛发帖为例。发帖最下方需要验证码验证,我们输入验证码后点击发帖后抓包,这个包会验证下验证码是否正确,我们forward此包,再将第二个包放到repeater里即可实现重放攻击,造成无限制刷帖。
1.要重放的包:
[<img src="https://images.seebug.org/upload/201407/0500002072571f3c4ba4bf04851a52cfd2a3c7d4.jpg" alt="t.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201407/0500002072571f3c4ba4bf04851a52cfd2a3c7d4.jpg)
2.刷帖结果:
[<img src="https://images.seebug.org/upload/201407/050000493b1de1d37d6fc5bea9941f6288bb03cc.jpg" alt="t1.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201407/050000493b1de1d37d6fc5bea9941f6288bb03cc.jpg)
存在同样的问题还有论坛回复处:
[<img src="https://images.seebug.org/upload/201407/0500012879a36475332c323ec9b1f7a106e5a422.jpg" alt="t2.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201407/0500012879a36475332c323ec9b1f7a106e5a422.jpg)
商品评论处:
[<img src="https://images.seebug.org/upload/201407/05000148d17c27f5bab51a774eed6ade0ed5f5eb.jpg" alt="t3.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201407/05000148d17c27f5bab51a774eed6ade0ed5f5eb.jpg)
暂无评论