文章目录
- 前言
- 一、回顾上一关知识点
- 二、靶场第七关通关思路
- 1、看源代码
- 2、空格绕过
- 3、检查文件是否成功上传
- 总结
前言
此文章只用于学习和反思巩固文件上传漏洞知识,禁止用于做非法攻击。注意靶场是可以练习的平台,不能随意去尚未授权的网站做渗透测试!!!
一、回顾上一关知识点
前两关是利用window命名文件的后缀名特性,因为window对大小写不敏感。而且命名后缀名的时候,后缀名加空格或者是后缀名加点都是等效于不加东西的文件。比如1.php+空格也就是1.php
二、靶场第七关通关思路
- 1、看源代码
- 2、空格绕过
- 3、检查文件是否成功上传
1、看源代码
$is_upload = false;
$msg = null;
if (isset($_POST['submit'])) {if (file_exists(UPLOAD_PATH)) {$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",".ini");$file_name = $_FILES['upload_file']['name'];$file_name = deldot($file_name);//删除文件名末尾的点$file_ext = strrchr($file_name, '.');$file_ext = strtolower($file_ext); //转换为小写$file_ext = str_ireplace('::$DATA', '', $file_ext);//去除字符串::$DATAif (!in_array($file_ext, $deny_ext)) {$temp_file = $_FILES['upload_file']['tmp_name'];$img_path = UPLOAD_PATH.'/'.date("YmdHis").rand(1000,9999).$file_ext;if (move_uploaded_file($temp_file,$img_path)) {$is_upload = true;} else {$msg = '上传出错!';}} else {$msg = '此文件不允许上传';}} else {$msg = UPLOAD_PATH . '文件夹不存在,请手工创建!';}
}
看到源代码发现有了大小写过滤,上一关方法不管用了。但是发现和上一关不同的是它没有过滤首尾去空。如果我们上传1.php (空格)文件的话,是不是就能绕过黑名单了呢?而且还能被win服务器自动识别为1.php文件
2、空格绕过
这里我上传123.php文件,然后用bp工具在文件后缀名后加上空格后发包。
3、检查文件是否成功上传
发现上传成功,如果是一句话木马就可以连接菜刀了
总结
这一关和上一关方法类似,也是利用win特性绕过黑名单达到上传php文件