TEC-004-php文件下載任意文件讀取漏洞修復

    修改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: attachment; 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 "文件下載錯誤!";
        }
    }wKiom1kJhuWSx6VoAADEcBUlkIE081.png-wh_50

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章