文件上传 02 服务端检测绕过(MIME类型检测)

本文记录文件上传学习过程,教程为 《Upload Attack Framework V1.0》

文件上传检测

  1. 客户端javascript 检测(通常为检测文件扩展名)
  2. 服务端MIME 类型检测(检测Content-Type 内容)
  3. 服务端目录路径检测(检测跟path 参数相关的内容)、
  4. 服务端文件扩展名检测(检测跟文件extension 相关的内容)
  5. 服务端文件内容检测(检测内容是否合法或含有恶意代码)

服务端检测绕过(MIME类型检测)

  1. 简介

    检测上传到服务器的文件类型,在 burp 抓包可以看到类似于 Content-Type: image/gif

    检测内容:

    实例:

    地址是: http://www.heibai.net/articles/hacker/ruqinshili/2011/0325/13735.html

  2. 源代码

    <?php
    if($_FILES['userfile']['type'] != "image/gif") { //检测Content-type
    echo "Sorry, we only allow uploading GIF images";
    exit;
    }
    $uploaddir = 'uploads/';
    $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
    if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
    echo "File is valid, and was successfully uploaded.\n";
    } else {
    echo "File uploading failed.\n";
    }
    ?>
    
  3. 绕过

    使用 burp 抓包

    上传本地文件 2012.asp

    在 burp 的 request 包里可以看到

    Content-Type: text/plain

    修改:Content-Type: text/plain -> Content-Type: image/gif

    像这种服务端检测http 包的Content-Type 都可以用这种类似的方法来绕过检测

猜你喜欢

转载自blog.csdn.net/Kevinhanser/article/details/81592885