发布时间:2022-09-23 09:30
upload-labs靶场 是PHP环境运行的,所以我准备了一个PHP脚本和一张图片
图片好准备,PHP脚本如果不想写的话可以用我的这个获取当前时间的PHP脚本
header("content-type:text/html;charset=utf-8");
date_default_timezone_set("PRC");//设置时区
echo "当前时间为:";
$today = date("Y-m-d D h:i:s A ");
echo $today;
?>
图片默认不清楚放大看!!!
$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");
$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 . '文件夹不存在,请手工创建!';
}
}
看提示和代码可以看出用前几关的方法是行不通的了
仔细看代码可以看出,它没有将多余的点
去掉,可以在扩展名后面加上点
来绕过验证
我这里还是分两种情况:可以直接改和不可以直接改两种
通关完成!