继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

TEC-004-php文件下载任意文件读取漏洞修复

慕用4979188
关注TA
已关注
手记 266
粉丝 63
获赞 531

    修改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 "文件下载错误!";
        }
    }

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP