TEC-004-php文件下载任意文件读取漏洞修复
更新:HHH   时间:2023-1-7


    修改download?u参数值,将/public/files/14842030529.txt,替换为../../../../../../../../../../etc/passwd
    function download() {
        $u =$_GET['u'];
        // 描述: 任意文件读取漏洞修复  date: 2017年4月28日 下午4:13:39  bylwy
        $lenth=strrpos($u,'.');
        $string = substr($u,0,$lenth);
        $end=substr($u,$lenth);
        $string = str_replace ( array ('.'), array ('╭(⊙^⊙)╮'), $string );
        $string .=$end;        
        // 描述: 任意文件读取漏洞修复  date: 2017年4月28日 下午4:13:39  bylwy
        if (file_exists($file)){
          header('Content-Description: File Transfer');
          header('Content-Type: application/octet-stream');
          header('Content-Disposition: p_w_upload; filename='.basename($file));
          header('Content-Transfer-Encoding: binary');
          header('Expires: 0');
          header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
          header('Pragma: public');
          header('Content-Length: ' . filesize($file));
          ob_clean();
          flush();
          readfile($file);
          exit;
        }else{
          echo "文件下载错误!";
        }
    }

返回web开发教程...