文件上传 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 都可以用这种类似的方法来绕过检测

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值