点击上方蓝字关注我们 并设为星标
0x01 前台SQL注入漏洞
受某朋友之托,帮忙审计一套涉H项目,具体名字就不给出了
框架为 ThinkPHP 6.0.8 Debug:True
位于 /app/map/controller/Index.php 控制器的 coachList 方法 通过GET传入 distance 被直接带到mapCoachList 方法之中,且未加过滤,我们追踪一下 mapCoachList 方法.
public functioncoachList(){
$input = $this->_param;
$shield_coach = $this->coach_model->getShieldCoach($this->getUserId());
if(!empty($input['service_time'])){
//
$working_coach = $this->coach_model->getWorkingCoach($this->_uniacid,$input['service_time']);
//
$cannot = CoachTimeList::getCannotCoach($this->_uniacid,$input['service_time']);
$working_coach = array_merge($working_coach,$cannot);
$shield_coach = array_merge($working_coach,$shield_coach);
}
if(!empty($input['cate_id'])){
$cate_model = new CateConnect();
$service_model = new ServiceCoach();
$id = $cate_model->where(['cate_id'=>$input['cate_id']])->column('service_id');
$coach_id = $service_model->where('ser_id','in',$id)->column('coach_id');
$dis[] = ['id','in',$coach_id];
}
$dis[] = ['id','not in',$shield_coach];
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','=',2];
$dis[] = ['auth_status','=',2];
$dis[] = ['is_work','=',1];
if(!empty($input['coach_name'])){
$dis[] = ['coach_name','like','%'.$input['coach_name'].'%'];
}
if(!empty($input['city_id'])){
$dis[] = ['city_id','=',$input['city_id']];
}
if(isset($input['sex'])){
$dis[] = ['sex','=',$input['sex']];
}
if(!empty($input['work_time_start'])&&!empty($input['work_time_end'])){
$dis[] = ['work_time','between',"{$input['work_time_start']},{$input['work_time_end']}"];
}
$distance = !empty($input['distance'])?$input['distance']:100000;
$lat = !empty($input['lat'])?$input['lat']:0;
$lng = !empty($input['lng'])?$input['lng']:0;
$alh = 'ACOS(SIN(('.$lat.' * 3.1415) / 180 ) *SIN((lat * 3.1415) / 180 ) +COS(('.$lat.' * 3.1415) / 180 ) * COS((lat * 3.1415) / 180 ) *COS(('.$lng.' * 3.1415) / 180 - (lng * 3.1415) / 180 ) ) * 6378.137*1000 as distance';
$data = $this->coach_model->mapCoachList($dis,$alh,$distance);
return $this->success($data);
}
public function mapCoachList($dis,$alh,$distance=100000){
$data = $this->where($dis)->field(['id,coach_name,work_img,lng,lat',$alh])->having("distance<$distance")->select()->toArray();
return $data;
}
0x02 后台GETSHELL
位于 /app/massage/controller/AdminSetting.php 控制器的 base64ToPngClouds 通过_input 方法传入 img参数,实际调用到了位于 /app/common.php 的公共函数 base64ToPngClouds ,我们追踪一下.
public function base64ToPngClouds(){
$input = $this->_input;
$data = base64ToPngClouds($input['img'],$this->_uniacid,$this->_host);
if($data==false){
$this->errorMsg('生成图片失败');
}
return $this->success($data);
}
if(!function_exists('base64ToPngClouds')){
functionbase64ToPngClouds($v,$uniacid,$host){
$host = 'https://'.$_SERVER['HTTP_HOST'];
if(!empty($v)){
$base_path = 'image/' . $uniacid . '/' . date('y') . '/' . date('m');
$path = FILE_UPLOAD_PATH.$base_path;
if(!file_exists($path)){
mkdir ($path,0777,true);
}
preg_match('/^(data:s*image/(w+);base64,)/', $v, $res);
if(strstr($v,",")){
$v = explode(',',$v);
$v = $v[1];
}
if(empty($res)){
return false;
}
$imageName = "/25220_".date("His",time())."_".rand(1111,9999).'.'.$res[2];
file_put_contents($path.$imageName, base64_decode($v));
$uploda_model = new appCommonUpload($uniacid);
$data = $uploda_model->uploadFile($base_path.$imageName,2);
if(empty($data['status'])||$data['status']!=1){
return false;
}
$info = $uploda_model->fileInfo($base_path.$imageName ,$imageName ,1);
$config = longbingGetOssConfig($uniacid);
if($data['longbing_driver']=='aliyun'&&!empty($config['aliyun_base_dir'])){
$info['attachment'] = $config['aliyun_base_dir']. '/' . $info['attachment'];
}
$info['attachment_path'] = longbingGetFilePath($info['attachment'] , $host,$uniacid ,$data['longbing_driver']);
return $info;
}
return [];
}
}
我们去 /app/massage/route/route.php 搜索一下路由调用,直接搜索相关方法名字即可找到.
Route::post('AdminSetting/xxxxx', 'AdminSetting/base64ToPngClouds');
0x03 漏洞日报下载
标签:代码审计,0day,渗透测试,系统,通用,0day,闲鱼,转转
CVE漏洞日报关注公众号,发送 250415 获取!
开了个星悦安全公开交流6群,🈲发公众号,纯粹研究技术,还会拉一些大佬,希望大家多多交流.
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,文章作者和本公众号不承担任何法律及连带责任,望周知!!!
原文始发于微信公众号(星悦安全):【代码审计】某项目从前台SQL注入到后台GETSHELL
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论