Upload-labs Pass-01 前端JS限制
1 | function checkFile() { |
getElementsByName()方法可返回带有指定名称的对象的集合,由于是数组(所有名称叫做upload_file的文件),[0]代表取数组中的第一个元素。
lastIndexOf()是从右向左查某个指定的字符串在字符串中最后一次出现的位置。
substring()方法用于提取字符串中介于两个指定下标之间的字符。这里就写了一个数字,即最后一个.后面的字符,即后缀名。
用burpsuite更改前端JS,png改为php
Pass-02 MIME检测-Content-Type
1 | $is_upload = false; |
直接用burpsuite改
只允许上传image/jpeg、image/png、image/gif三种图片类型,这里要注意大小写
Pass-03 黑名单限制
1 | $is_upload = false; |
禁止上传.asp|.aspx|.php|.jsp后缀文件
直接上传.phtml
Pass-04 .htaccess文件上传
1 | $is_upload = false; |
test.php.xxxx.yyy这种不认识的后缀名会从右往左依次解析,不认识就往左移一个,像这个就会当作test.php处理
Pass-05 大小写绕过
1 | $is_upload = false; |
直接用大小写绕过就好了,Php
Pass-06 空格绕过
1 | $is_upload = false; |
缺少了$file_ext = trim($file_ext); //首尾去空这行码,导致可以空格绕过
Pass-07 .
绕过
1 | $deny_ext = array(".php",".php5",".php4",".php3",".php2",".html",".htm",".phtml",".pht",".pHp",".pHp5",".pHp4",".pHp3",".pHp2",".Html",".Htm",".pHtml",".jsp",".jspa",".jspx",".jsw",".jsv",".jspf",".jtml",".jSp",".jSpx",".jSpa",".jSw",".jSv",".jSpf",".jHtml",".asp",".aspx",".asa",".asax",".ascx",".ashx",".asmx",".cer",".aSp",".aSpx",".aSa",".aSax",".aScx",".aShx",".aSmx",".cEr",".sWf",".swf",".htaccess"); |
只是换了一行代码,把去掉首尾空的代码加上,把去掉结果的.代码去掉了,所以传入后缀为.php.
Pass-08 Windows文件流特性绕过
1 | $deny_ext = array(".php",".php5",".php4",".php3",".php2",".html",".htm",".phtml",".pht",".pHp",".pHp5",".pHp4",".pHp3",".pHp2",".Html",".Htm",".pHtml",".jsp",".jspa",".jspx",".jsw",".jsv",".jspf",".jtml",".jSp",".jSpx",".jSpa",".jSw",".jSv",".jSpf",".jHtml",".asp",".aspx",".asa",".asax",".ascx",".ashx",".asmx",".cer",".aSp",".aSpx",".aSa",".aSax",".aScx",".aShx",".aSmx",".cEr",".sWf",".swf",".htaccess"); |
少了这么一行$file_ext = str_ireplace(‘::$DATA’, ‘’, $file_ext);//去除字符串::$DATA
改为.php::$data
可以直接绕过检查
Pass-09 双写后缀特殊符号绕过
1 | $deny_ext = array(".php",".php5",".php4",".php3",".php2",".html",".htm",".phtml",".pht",".pHp",".pHp5",".pHp4",".pHp3",".pHp2",".Html",".Htm",".pHtml",".jsp",".jspa",".jspx",".jsw",".jsv",".jspf",".jtml",".jSp",".jSpx",".jSpa",".jSw",".jSv",".jSpf",".jHtml",".asp",".aspx",".asa",".asax",".ascx",".ashx",".asmx",".cer",".aSp",".aSpx",".aSa",".aSax",".aScx",".aShx",".aSmx",".cEr",".sWf",".swf",".htaccess"); |
后缀名为info.php. .,这样构造就可以成功绕过了
Pass-10 双写后缀名绕过
1 | $is_upload = false; |
典型双写绕过的例子
pphphp