上傳漏洞總結-upload-labs

介紹:

Upload-labs是一個全部類型的上傳漏洞的靶場php

項目地址:https://github.com/c0ny1/upload-labshtml

 

思惟導圖:

 

 

小試牛刀:

Pass-01

客戶端js檢查前端

 

思路將PHP後綴的文件,改成.jpg格式的,而後上傳抓包,將後綴名改回去,改爲.php後綴的格式,便可繞過前端JS的校驗git

 getshellgithub

 

Pass-02 

直接上產PHP腳本文件,提示以下:web

繞過思路類型繞過: image/jpegshell

getshellapache

 

pass-03

黑名單繞過,禁止上傳.asp|.aspx|.php|.jsp後綴文件!服務器

繞過思路:上傳:.php3 .phtmlapp

具體原理

<IfModule php5_module>

    PHPIniDir "C:/phpStudy-01/PHP/"

    AddType application/x-httpd-php .php .phtml

    AddType application/x-httpd-php .php .phtml .php3

    AddType application/x-httpd-php-source .phps

</IfModule>

 

getshell

 

pass-04

黑名單繞過

 

 getshell

原理:

先來看一下apache的主配置文件httpd.conf,搜索「DefaultType」,就能夠看到這麼一段註釋和默認配置:

#
# DefaultType: the default MIME type the server will use for a document
# if it cannot otherwise determine one, such as from filename extensions.
# If your server contains mostly text or HTML documents, "text/plain" is
# a good value. If most of your content is binary, such as applications
# or images, you may want to use "application/octet-stream" instead to
# keep browsers from trying to display binary files as though they are
# text.
#10DefaultType text/plain

DefaultType存在的意義是告訴apache該如何處理未知擴展名的文件,好比f4ck.xxx這樣的文件,擴展名是xxx,這確定不是一個正常的網頁或腳本文件,這個參數就是告訴apache該怎麼處理這種未知擴展名的文件。

參數DefaultType的默認值是「text/plain」,也就是遇到未知擴展名的文件,就把它看成普通的txt文本或html文件來處理。

測試一

好比我將如下代碼保存爲f4ck.xxx  默認解析成文本

測試二

那麼,對於文件內容爲php代碼的未知擴展名文件來講也是解析成文本

對於f4ck.php.xxx,那麼就會被以module方式運行php的apache解析,由於Apache認爲一個文件能夠擁有多個擴展名,哪怕沒有文件名,也能夠擁有多個擴展名。Apache認爲應該從右到左開始判斷解析方法的。若是最右側的擴展名爲不可識別的,就繼續往左判斷,直到判斷到文件名爲止。

解決方案一

在httpd.conf或httpd-vhosts.conf中加入如下語句,從而禁止文件名格式爲*.php.*的訪問權限:

<FilesMatch ".(php.|php3.|php4.|php5.)">
Order Deny,Allow
Deny from all
</FilesMatch>

解決方案二

若是須要保留文件名,能夠修改程序源代碼,替換上傳文件名中的「.」爲「_」:

$filename = str_replace('.', '_', $filename);

 

還能夠上傳:.htaccess

內容爲:SetHandler application/x-httpd-php

而後更改PHP的後綴爲:.gif 便可

 

pass-05

黑名單繞過 本pass禁止上傳.php|.php5|.php4|.php3|.php2|php1|.html|.htm|.phtml|.pHp|.pHp5|.pHp4|.pHp3|.pHp2|pHp1|.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後綴文件!

貌似沒有.PHP結尾的文件,能夠嘗試下

getshell

pass-06

黑名單機制,查看源碼:

$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 = $_FILES['upload_file']['name'];

        $file_name = deldot($file_name);//刪除文件名末尾的點

        $file_ext = strrchr($file_name, '.');

        $file_ext = strtolower($file_ext); //轉換爲小寫

        $file_ext = str_ireplace('::$DATA', '', $file_ext);//去除字符串::$DATA

       

        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 . '文件夾不存在,請手工建立!';

    }

}

 沒有對文件的末尾的空格進行處理,因此能夠嘗試繞過

getshell

pass-07

黑名單機制

查看源碼

$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_ext = strrchr($file_name, '.');

        $file_ext = strtolower($file_ext); //轉換爲小寫

        $file_ext = str_ireplace('::$DATA', '', $file_ext);//去除字符串::$DATA

        $file_ext = trim($file_ext); //首尾去空

       

        if (!in_array($file_ext, $deny_ext)) {

            $temp_file = $_FILES['upload_file']['tmp_name'];

            $img_path = UPLOAD_PATH.'/'.$file_name;

            if (move_uploaded_file($temp_file, $img_path)) {

                $is_upload = true;

            } else {

                $msg = '上傳出錯!';

            }

        } else {

            $msg = '此文件類型不容許上傳!';

        }

    } else {

        $msg = UPLOAD_PATH . '文件夾不存在,請手工建立!';

    }

}

 

能夠嘗試.php.xxx的方式繞過

 

getshell

 

 

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 . '文件夾不存在,請手工建立!';

    }

}

進行繞過:

getshell

pass-09

黑名單繞過

分析源碼:

$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 = str_ireplace('::$DATA', '', $file_ext);//去除字符串::$DATA

        $file_ext = trim($file_ext); //首尾去空

       

        if (!in_array($file_ext, $deny_ext)) {

            $temp_file = $_FILES['upload_file']['tmp_name'];

            $img_path = UPLOAD_PATH.'/'.$file_name;

            if (move_uploaded_file($temp_file, $img_path)) {

                $is_upload = true;

            } else {

                $msg = '上傳出錯!';

            }

        } else {

            $msg = '此文件類型不容許上傳!';

        }

    } else {

        $msg = UPLOAD_PATH . '文件夾不存在,請手工建立!';

    }

}

繞過方式1

*.php.xxx

繞過方式2

*.php. . (點+空格+點)

pass-10

黑名單機制

源碼:

$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","jsp","jspa","jspx","jsw","jsv","jspf","jtml","asp","aspx","asa","asax","ascx","ashx","asmx","cer","swf","htaccess");

 

        $file_name = trim($_FILES['upload_file']['name']);

        $file_name = str_ireplace($deny_ext,"", $file_name); #將黑名單中的後綴替換爲空

        $temp_file = $_FILES['upload_file']['tmp_name'];

        $img_path = UPLOAD_PATH.'/'.$file_name;       

        if (move_uploaded_file($temp_file, $img_path)) {

            $is_upload = true;

        } else {

            $msg = '上傳出錯!';

        }

    } else {

        $msg = UPLOAD_PATH . '文件夾不存在,請手工建立!';

    }

}

嘗試雙寫後綴名繞過: c99.pphphp 替換了.後面的PHP就剩下了c99.php了

getshell

pass-11

備註:11 12管須要關閉magic_quotes_gpc=Off 函數

引用的過程當中只有在傳遞$_GET,$_POST,$_COOKIE時纔會發生做用

 

白名單

源碼:

$is_upload = false;

$msg = null;

if(isset($_POST['submit'])){

    $ext_arr = array('jpg','png','gif');

    $file_ext = substr($_FILES['upload_file']['name'],strrpos($_FILES['upload_file']['name'],".")+1);

    if(in_array($file_ext,$ext_arr)){

        $temp_file = $_FILES['upload_file']['tmp_name'];

        $img_path = $_GET['save_path']."/".rand(10, 99).date("YmdHis").".".$file_ext;

 

        if(move_uploaded_file($temp_file,$img_path)){

            $is_upload = true;

        } else {

            $msg = '上傳出錯!';

        }

    } else{

        $msg = "只容許上傳.jpg|.png|.gif類型文件!";

    }

}

看到imge_path是拼接的,因此能夠嘗試%00 截斷,關於截斷大體說下原理:

常見的截斷上傳有:0x00,%00,/00 截斷的核心在於chr(0)這個字符,這個函數表示返回以數值表達式值爲編碼的字符,舉個例,print chr(78) 結果是N,因此char(0)表示的ascll字符是null,當程序輸出包含chr(0)變量時,chr(0)後面的數據會被截斷,後面的數據直接忽略,致使漏洞產生。

getshell

 

pass-12

截斷上傳

$is_upload = false;

$msg = null;

if(isset($_POST['submit'])){

    $ext_arr = array('jpg','png','gif');

    $file_ext = substr($_FILES['upload_file']['name'],strrpos($_FILES['upload_file']['name'],".")+1);

    if(in_array($file_ext,$ext_arr)){

        $temp_file = $_FILES['upload_file']['tmp_name'];

        $img_path = $_POST['save_path']."/".rand(10, 99).date("YmdHis").".".$file_ext;

 

        if(move_uploaded_file($temp_file,$img_path)){

            $is_upload = true;

        } else {

            $msg = "上傳失敗";

        }

    } else {

        $msg = "只容許上傳.jpg|.png|.gif類型文件!";

    }

}

分析:img_path依然是拼接的路徑,可是此次試用的post方式,仍是利用00截斷,但此次須要在二進制中進行修改,由於post不會像get對%00進行自動解碼

空格的十六進制是20 ,講0x20 改爲0x00 也就是00

getshell

pass-13

查看源碼,要求上傳圖片木馬

function getReailFileType($filename){

    $file = fopen($filename, "rb");

    $bin = fread($file, 2); //只讀2字節

    fclose($file);

    $strInfo = @unpack("C2chars", $bin);   

    $typeCode = intval($strInfo['chars1'].$strInfo['chars2']);   

    $fileType = '';   

    switch($typeCode){     

        case 255216:           

            $fileType = 'jpg';

            break;

        case 13780:           

            $fileType = 'png';

            break;       

        case 7173:           

            $fileType = 'gif';

            break;

        default:           

            $fileType = 'unknown';

        }   

        return $fileType;

}

 

$is_upload = false;

$msg = null;

if(isset($_POST['submit'])){

    $temp_file = $_FILES['upload_file']['tmp_name'];

    $file_type = getReailFileType($temp_file);

 

    if($file_type == 'unknown'){

        $msg = "文件未知,上傳失敗!";

    }else{

        $img_path = UPLOAD_PATH."/".rand(10, 99).date("YmdHis").".".$file_type;

        if(move_uploaded_file($temp_file,$img_path)){

            $is_upload = true;

        } else {

            $msg = "上傳出錯!";

        }

    }

}

 

經過讀文件的前2個字節判斷文件類型,所以直接上傳圖片馬便可,製做方法:

第一種方法:copy normal.jpg /b + shell.php /a webshell.jpg

第二種方法:exiftool -Comment='<?php echo "<pre>"; system($_GET['cmd']); ?>' 1.jpg

Pass-14

圖片頭繞過

具體操做以下:

將PHP木馬文件,改爲*.php;.jpg

抓包,給文件頭部加上:GIF89a 圖片頭標識

 

pass-15

php_exif模塊來判斷文件類型,仍是直接就能夠利用圖片馬就可進行繞過

 

Pass-16

查看源碼

$is_upload = false;

$msg = null;

if (isset($_POST['submit'])){

    // 得到上傳文件的基本信息,文件名,類型,大小,臨時文件路徑

    $filename = $_FILES['upload_file']['name'];

    $filetype = $_FILES['upload_file']['type'];

    $tmpname = $_FILES['upload_file']['tmp_name'];

 

    $target_path=UPLOAD_PATH.basename($filename);

 

    // 得到上傳文件的擴展名

    $fileext= substr(strrchr($filename,"."),1);

 

    //判斷文件後綴與類型,合法才進行上傳操做

    if(($fileext == "jpg") && ($filetype=="image/jpeg")){

        if(move_uploaded_file($tmpname,$target_path))

        {

            //使用上傳的圖片生成新的圖片

            $im = imagecreatefromjpeg($target_path);

 

            if($im == false){

                $msg = "該文件不是jpg格式的圖片!";

                @unlink($target_path);

            }else{

                //給新圖片指定文件名

                srand(time());

                $newfilename = strval(rand()).".jpg";

                $newimagepath = UPLOAD_PATH.$newfilename;

                imagejpeg($im,$newimagepath);

                //顯示二次渲染後的圖片(使用用戶上傳圖片生成的新圖片)

                $img_path = UPLOAD_PATH.$newfilename;

                @unlink($target_path);

                $is_upload = true;

            }

        } else {

            $msg = "上傳出錯!";

        }

 

    }else if(($fileext == "png") && ($filetype=="image/png")){

        if(move_uploaded_file($tmpname,$target_path))

        {

            //使用上傳的圖片生成新的圖片

            $im = imagecreatefrompng($target_path);

 

            if($im == false){

                $msg = "該文件不是png格式的圖片!";

                @unlink($target_path);

            }else{

                 //給新圖片指定文件名

                srand(time());

                $newfilename = strval(rand()).".png";

                $newimagepath = UPLOAD_PATH.$newfilename;

                imagepng($im,$newimagepath);

                //顯示二次渲染後的圖片(使用用戶上傳圖片生成的新圖片)

                $img_path = UPLOAD_PATH.$newfilename;

                @unlink($target_path);

                $is_upload = true;              

            }

        } else {

            $msg = "上傳出錯!";

        }

 

    }else if(($fileext == "gif") && ($filetype=="image/gif")){

        if(move_uploaded_file($tmpname,$target_path))

        {

            //使用上傳的圖片生成新的圖片

            $im = imagecreatefromgif($target_path);

            if($im == false){

                $msg = "該文件不是gif格式的圖片!";

                @unlink($target_path);

            }else{

                //給新圖片指定文件名

                srand(time());

                $newfilename = strval(rand()).".gif";

                $newimagepath = UPLOAD_PATH.$newfilename;

                imagegif($im,$newimagepath);

                //顯示二次渲染後的圖片(使用用戶上傳圖片生成的新圖片)

                $img_path = UPLOAD_PATH.$newfilename;

                @unlink($target_path);

                $is_upload = true;

            }

        } else {

            $msg = "上傳出錯!";

        }

    }else{

        $msg = "只容許上傳後綴爲.jpg|.png|.gif的圖片文件!";

    }

}

 

綜合判斷了後綴名、content-type,以及利用imagecreatefromgif判斷是否爲gif圖片,最後再作了一次二次渲染,繞過方法仍是上傳圖片木馬

 

pass-17

競爭條件:

 

$is_upload = false;

$msg = null;

 

if(isset($_POST['submit'])){

    $ext_arr = array('jpg','png','gif');

    $file_name = $_FILES['upload_file']['name'];

    $temp_file = $_FILES['upload_file']['tmp_name'];

    $file_ext = substr($file_name,strrpos($file_name,".")+1);

    $upload_file = UPLOAD_PATH . '/' . $file_name;

 

    if(move_uploaded_file($temp_file, $upload_file)){

        if(in_array($file_ext,$ext_arr)){

             $img_path = UPLOAD_PATH . '/'. rand(10, 99).date("YmdHis").".".$file_ext;

             rename($upload_file, $img_path);

             $is_upload = true;

        }else{

            $msg = "只容許上傳.jpg|.png|.gif類型文件!";

            unlink($upload_file);

        }

    }else{

        $msg = '上傳出錯!';

    }

}

這裏先將文件上傳到服務器,而後經過rename修更名稱,再經過unlink刪除文件,所以能夠經過條件競爭的方式在unlink以前,訪問webshell。

首先在burp中不斷髮送上傳webshell的數據包

 

pass-18

分析源碼:

$is_upload = false;

$msg = null;

if (isset($_POST['submit']))

{

    require_once("./myupload.php");

    $imgFileName =time();

    $u = new MyUpload($_FILES['upload_file']['name'], $_FILES['upload_file']['tmp_name'], $_FILES['upload_file']['size'],$imgFileName);

    $status_code = $u->upload(UPLOAD_PATH);

    switch ($status_code) {

        case 1:

            $is_upload = true;

            $img_path = $u->cls_upload_dir . $u->cls_file_rename_to;

            break;

        case 2:

            $msg = '文件已經被上傳,但沒有重命名。';

            break;

        case -1:

            $msg = '這個文件不能上傳到服務器的臨時文件存儲目錄。';

            break;

        case -2:

            $msg = '上傳失敗,上傳目錄不可寫。';

            break;

        case -3:

            $msg = '上傳失敗,沒法上傳該類型文件。';

            break;

        case -4:

            $msg = '上傳失敗,上傳的文件過大。';

            break;

        case -5:

            $msg = '上傳失敗,服務器已經存在相同名稱文件。';

            break;

        case -6:

            $msg = '文件沒法上傳,文件不能複製到目標目錄。';

            break;     

        default:

            $msg = '未知錯誤!';

            break;

    }

}

 

//myupload.php

class MyUpload{

......

......

......

  var $cls_arr_ext_accepted = array(

      ".doc", ".xls", ".txt", ".pdf", ".gif", ".jpg", ".zip", ".rar", ".7z",".ppt",

      ".html", ".xml", ".tiff", ".jpeg", ".png" );

 

......

......

...... 

  /** upload()

   **

   ** Method to upload the file.

   ** This is the only method to call outside the class.

   ** @para String name of directory we upload to

   ** @returns void

  **/

  function upload( $dir ){

   

    $ret = $this->isUploadedFile();

   

    if( $ret != 1 ){

      return $this->resultUpload( $ret );

    }

 

    $ret = $this->setDir( $dir );

    if( $ret != 1 ){

      return $this->resultUpload( $ret );

    }

 

    $ret = $this->checkExtension();

    if( $ret != 1 ){

      return $this->resultUpload( $ret );

    }

 

    $ret = $this->checkSize();

    if( $ret != 1 ){

      return $this->resultUpload( $ret );   

    }

   

    // if flag to check if the file exists is set to 1

   

    if( $this->cls_file_exists == 1 ){

     

      $ret = $this->checkFileExists();

      if( $ret != 1 ){

        return $this->resultUpload( $ret );   

      }

    }

 

    // if we are here, we are ready to move the file to destination

 

    $ret = $this->move();

    if( $ret != 1 ){

      return $this->resultUpload( $ret );   

    }

 

    // check if we need to rename the file

 

    if( $this->cls_rename_file == 1 ){

      $ret = $this->renameFile();

      if( $ret != 1 ){

        return $this->resultUpload( $ret );   

      }

    }

   

    // if we are here, everything worked as planned :)

 

    return $this->resultUpload( "SUCCESS" );

 

  }

......

......

......

};

 

對文件後綴名作了白名單判斷,而後會一步一步檢查文件大小、文件是否存在等等,將文件上傳後,對文件從新命名,一樣存在條件競爭的漏洞。能夠不斷利用burp發送上傳圖片馬的數據包,因爲條件競爭,程序會出現來不及rename的問題,從而上傳成功

pass-19

源碼:

$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","jsp","jspa","jspx","jsw","jsv","jspf","jtml","asp","aspx","asa","asax","ascx","ashx","asmx","cer","swf","htaccess");

 

        $file_name = trim($_POST['save_name']);

        $file_name = deldot($file_name);//刪除文件名末尾的點

        $file_ext = pathinfo($file_name,PATHINFO_EXTENSION);

        $file_ext = strtolower($file_ext); //轉換爲小寫

        $file_ext = str_ireplace('::$DATA', '', $file_ext);//去除字符串::$DATA

        $file_ext = trim($file_ext); //首尾去空

 

        if(!in_array($file_ext,$deny_ext)) {

            $temp_file = $_FILES['upload_file']['tmp_name'];

            $img_path = UPLOAD_PATH . '/' .$file_name;

            if (move_uploaded_file($temp_file, $img_path)) {

                $is_upload = true;

            }else{

                $msg = '上傳出錯!';

            }

        }else{

            $msg = '禁止保存爲該類型文件!';

        }

 

    } else {

        $msg = UPLOAD_PATH . '文件夾不存在,請手工建立!';

    }

}

 

此漏洞屬於截斷上傳,上傳的文件名用0x00繞過。改爲*.php【二進制00】.1.jpg,上傳文件名改爲要本身定義

 

 

參考:

https://xz.aliyun.com/t/2435

相關文章
相關標籤/搜索