c0ny1/upload-labs文件上传漏洞之NTFS文件系统$DATA漏洞Pass-08


本文记录Pass-08,看起来比较完整,但是后端没有删除文件名中的::$DATA

查看代码

$is_upload = false;
$msg = null;
if (isset($_POST['submit'])) {
    if (file_exists(UPLOAD_PATH)) {
        $deny_ext = array(".php",".php5",".php4",".php3",".php2",".html",".htm",".phtml",".pht",".pHp",".pHp5",".pHp4",".pHp3",".pHp2",".Html",".Htm",".pHtml",".jsp",".jspa",".jspx",".jsw",".jsv",".jspf",".jtml",".jSp",".jSpx",".jSpa",".jSw",".jSv",".jSpf",".jHtml",".asp",".aspx",".asa",".asax",".ascx",".ashx",".asmx",".cer",".aSp",".aSpx",".aSa",".aSax",".aScx",".aShx",".aSmx",".cEr",".sWf",".swf",".htaccess");
        $file_name = trim($_FILES['upload_file']['name']);
        $file_name = deldot($file_name);//删除文件名末尾的点
        $file_ext = strrchr($file_name, '.');
        $file_ext = strtolower($file_ext); //转换为小写
        $file_ext = trim($file_ext); //首尾去空
        
        if (!in_array($file_ext, $deny_ext)) {
            $temp_file = $_FILES['upload_file']['tmp_name'];
            $img_path = UPLOAD_PATH.'/'.date("YmdHis").rand(1000,9999).$file_ext;
            if (move_uploaded_file($temp_file, $img_path)) {
                $is_upload = true;
            } else {
                $msg = '上传出错!';
            }
        } else {
            $msg = '此文件类型不允许上传!';
        }
    } else {
        $msg = UPLOAD_PATH . '文件夹不存在,请手工创建!';
    }
}

NTFS文件系统为了和其他文件系统兼容,默认留了一个数据流,在windows系统中,此数据流被称为$DATA,因此,只要是windows的系统就可以在后缀名后加::$DATA,来试试能否绕过。
上传时将后缀名改为cmd.php::$DATA。
将后缀名改为cmd.php::$DATA

上传成功。
当前环境是linux,发现不能执行。
查看上传文件夹之后发现,在linux下,文件名还是cmd.php::$DATA

声明:物博网|版权所有,违者必究|如未注明,均为原创|本网站采用BY-NC-SA协议进行授权

转载:转载请注明原文链接 - c0ny1/upload-labs文件上传漏洞之NTFS文件系统$DATA漏洞Pass-08


喜欢安全与WEB开发