MYD网络安全实验室

[upload-labs] 学习

2019-01-19  本文已影响92人  2mpossible

一个帮你总结所有类型的上传漏洞的靶场

Pass-01

Pass-02

Pass-03

Pass-04

//.htaccess
SetHandler application/x-httpd-php

Pass-05

Pass-06

Pass-07

Pass-08

Pass-09

Pass-10

Pass-11

//%00截断适用条件
PHP 版本 < 5.3.4
php.ini 中 magic_quotes_gpc=off

Pass-12

Pass-13

Pass-14

Pass-15

Pass-16

Pass-17

Pass-18

Pass-19

image.png

Pass-20

$is_upload = false;
$msg = null;
if(!empty($_FILES['upload_file'])){
    //检查MIME
    $allow_type = array('image/jpeg','image/png','image/gif');
    if(!in_array($_FILES['upload_file']['type'],$allow_type)){
        $msg = "禁止上传该类型文件!";
    }else{
        //检查文件名
        $file = empty($_POST['save_name']) ? $_FILES['upload_file']['name'] : $_POST['save_name'];
        if (!is_array($file)) {
            $file = explode('.', strtolower($file));
        }

        $ext = end($file);
        $allow_suffix = array('jpg','png','gif');
        if (!in_array($ext, $allow_suffix)) {
            $msg = "禁止上传该后缀文件!";
        }else{
            $file_name = reset($file) . '.' . $file[count($file) - 1];
            $temp_file = $_FILES['upload_file']['tmp_name'];
            $img_path = UPLOAD_PATH . '/' .$file_name;
            if (move_uploaded_file($temp_file, $img_path)) {
                $msg = "文件上传成功!";
                $is_upload = true;
            } else {
                $msg = "文件上传失败!";
            }
        }
    }
}else{
    $msg = "请选择要上传的文件!";
}
上一篇 下一篇

猜你喜欢

热点阅读