上传漏洞--名单绕过
2015-07-07 10:57
218 查看
原文链接:https://www.geek-share.com/detail/2647237820.html
1、黑名单绕过
<title>图片上传</title> <body> <form action="blacklist.php" method="post" enctype="multipart/form-data"> <input type='file' name='file' id='file'><br /> <input type='submit' name='submit' value='提交'> </form> </body>
<?php $Blacklist = array('asp','php','jsp','php5','asa','aspx'); //黑名单 if(isset($_POST["submit"])){ $name = $_FILES['file']['name']; //接受文件名 $extension = substr(strrchr($name,"."),1); //得到扩展名 $boo = false; foreach($Blacklist as $key => $value){ if($value == $extension){ $boo = true; break; } } if(!$boo){ $size = $FILES['file']['size']; $tmp = $_FILES['file']['tmp_name']; move_uploaded_file($tmp,$name); echo "file uploaded success,the path is:".$name; } else{ echo "file is validate"; } } ?>
黑名单绕过的方式很多,我这里只介绍一种!
绕过方法:
找容易忽视的后缀:cer等等;
大小写绕过;只是在Windows中会被解析
文件名后面加 . 或者 空格 在Windows中也会被自动去掉从而解析为应用程序文件
上面这种只是一种,具体情况,还需要看具体环境;
2、白名单
<title>图片上传</title> <body> <form action="whitelist.php" method="post" enctype="multipart/form-data"> <input type='file' name='file' id='file'><br /> <input type='submit' name='submit' value='提交'> </form> </body>
<?php $Whitelist = array('rar','jpg','png','bmp','gif','doc','txt'); //黑名单 if(isset($_POST["submit"])){ $name = $_FILES['file']['name']; //接受文件名 $extension = substr(strrchr($name,"."),1); //得到扩展名 $boo = false; foreach($Whitelist as $key => $value){ if($value == $extension){ $boo = true; break; } } if($boo){ $size = $FILES['file']['size']; $tmp = $_FILES['file']['tmp_name']; move_uploaded_file($tmp,$name); echo "file uploaded success,the path is:".$name; } else{ echo "file is validate"; } } ?>
白名单绕过方式一般都是通过解析漏洞来构造,如IIS6.0 会解析1.asp;1.jpg,所以我们可以通过这种方式来修改上传
后续还有~~~
转载于:https://www.cnblogs.com/BloodZero/p/4626344.html
相关文章推荐
- 上传漏洞--名单绕过
- ASP上传漏洞之利用CHR(0)绕过扩展名检测脚本
- Web(2)-文件上传漏洞(绕过)
- 文件上传漏洞——JS绕过
- ASP上传漏洞之利用CHR(0)绕过扩展名检测脚本
- 文件上传漏洞—扩展名绕过
- 文件上传漏洞原理和绕过方式
- 文件上传漏洞(绕过姿势)
- 文件上传漏洞(绕过姿势) 转载防丢失
- 文件上传漏洞(绕过姿势)
- 文件上传漏洞(绕过姿势)
- 文件上传漏洞绕过手段
- 利用最新Apache解析漏洞(CVE-2017-15715)绕过上传黑名单
- 上传漏洞--前端绕过
- [基本实验] 利用Burp和FireBug绕过上传漏洞的前端防护
- U-Mail邮件服务系统任意文件上传+执行漏洞(runtime缺陷与验证绕过)
- [web安全] 上传漏洞之绕过上传漏洞
- 文件上传漏洞(绕过姿势)
- i春秋:警惕您站上的文件内容检测绕过类上传漏洞
- 文件上传漏洞绕过实验记录