PHPYun /uploads/member/ajax.class.php SQL注入漏洞
PHPYun简介
PHP云人才管理系统,专业的人才招聘网站系统开源程序,采用PHP和MySQL 数据库构建的高效的人才与企业求职招招聘系统,在尊重版权的前提下能极大的满足站长对于网站程序进行二次开发。
漏洞原理
参数未过滤,直接被带入到SQL语句中进行查询,导致注入漏洞的产生
漏洞分析
查看/uploads/member/ajax.class.php文件
function getzphcom_action(){
if(!$_GET['jobid']){
$arr['status']=0;
$arr['content']=iconv("gbk","utf-8","您还没有职位,<a href='".Url("login",array(),"1")."'>请先登录</a>");
}else{
$row=$this->obj->DB_select_all("company_job","`id` in (".$_GET['jobid'].") and `uid`='".$this->uid."' and `r_status`<>'2' and `status`<>'1'","`name`");
$space=$this->obj->DB_select_all("zhaopinhui_space");
$zhaopinhui=$this->obj->DB_select_once("zhaopinhui","`id`='".intval($_GET['zid'])."'","`title`,`address`,`starttime`,`endtime`");
$com=$this->obj->DB_select_once("zhaopinhui_com","`zid`='".intval($_GET['zid'])."' and `uid`='".$this->uid."'");
foreach($row as $v){
$data[]=$v['name'];
}
$spaces=array();
foreach($space as $val){
$spaces[$val['id']]=$val['name'];
}
$cname=@implode('、',$data);
$arr['status']=1;
$arr['content']=iconv("gbk","utf-8",$cname);
$arr['title']=iconv("gbk","utf-8",$zhaopinhui['title']);
$arr['address']=iconv("gbk","utf-8",$zhaopinhui['address']);
$arr['starttime']=iconv("gbk","utf-8",$zhaopinhui['starttime']);
$arr['endtime']=iconv("gbk","utf-8",$zhaopinhui['endtime']);
$arr['sid']=iconv("gbk","utf-8",$spaces[$com['sid']]);
$arr['bid']=iconv("gbk","utf-8",$spaces[$com['bid']]);
$arr['cid']=iconv("gbk","utf-8",$spaces[$com['cid']]);
}
echo json_encode($arr);
}
分析上面代码段:
$row=$this->obj->DB_select_all("company_job","`id` in (".$_GET['jobid'].") and `uid`='".$this->uid."' and `r_status`<>'2' and `status`<>'1'","`name`");
可以看到这里没有对$_GET[‘jobid’]进行过滤
继续跟进DB_select_all()函数,查看/uploads/app/public/action.class.php文件
function DB_select_all($tablename, $where = 1, $select = "*",$special='') {
$cachename=$tablename.$where;
if(!$row_return=$this->Memcache_set($cachename)){
$row_return=array();
if($this->siteadmindir&&$special==''){
$where = $this->site_fetchsql($where,$tablename);
}
$SQL = "SELECT $select FROM `" . $this->def . $tablename . "` WHERE ".$where;
$query=$this->db->query($SQL);
while($row=$this->db->fetch_array($query)){
$row_return[]=$row;}
$this->Memcache_set($cachename,$row_return);
}
return $row_return;
}
可以看出依旧没有对$_GET[‘jobid’]进行过滤
所以最终拼出来的SQL语句是
SELECT `name` FROM `phpyun_company_job` WHERE `id` in (可控) and `uid`='1' and `r_status`<>'2' and `status`<>'1'
由于360waf对于接受到的参数,单引号,双引号进行转义,英文括号变中文括号,关键字select,update,delete,insert,/**/,带有这些就会被360拦截,所以可以用xor进行绕过,执行SQL注入漏洞