upload-labs pass-09
Pass-09
先看一下源码(黑名单绕过–特殊字符::$DATA绕过):
$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 = trim($_FILES['upload_file']['name']);
$file_name = deldot($file_name);//删除文件名末尾的点
$file_ext = strrchr($file_name, '.');
$file_ext = strtolower($file_ext); //转换为小写
$file_ext = trim($file_ext); //首尾去空
if (!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.上传402.php文件失败,多种后缀不允许上传。
2.开启burpsuit抓包,直接在文件名后面增加一个”::$DATA”,点击forward,回到浏览器发现上传成功。
利用的是Windows下NTFS文件系统的一个特性,即NTFS文件系统的存储数据流的一个属性
D
A
T
A
,
当
我
们
访
问
a
.
a
s
p
:
:
DATA,当我们访问 a.asp::
DATA,当我们访问a.asp::DATA 时,就是请求 a.asp 本身的数据,如果a.asp 还包含了其他的数据流。比如 a.asp:lake2.asp,请求a.asp:lake2.asp::
D
A
T
A
”
,
则
是
请
求
a
.
a
s
p
中
的
流
数
据
l
a
k
e
2.
a
s
p
的
流
数
据
内
容
。
注
意
:
复
制
图
像
地
址
访
问
时
,
会
附
带
:
:
DATA”, 则是请求a.asp中的流数据lake2.asp的流数据内容。 注意:复制图像地址访问时,会附带::
DATA”,则是请求a.asp中的流数据lake2.asp的流数据内容。注意:复制图像地址访问时,会附带::DATA,要去掉后再连接,否则找不到文件。