首页 > Web开发 > 详细

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

时间:2017-05-03 15:51:56      阅读:341      评论:0      收藏:0      [点我收藏+]

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

本文出自 “yanzi” 博客,请务必保留此出处http://daddysgirl.blog.51cto.com/1598612/1921597

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

原文:http://daddysgirl.blog.51cto.com/1598612/1921597

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!