文件上传绕过

html代码

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form action="./upload.php" enctype="multipart/form-data" multiple="" method="POST" >
< input type="file" name="img[]" multiple>
<button>提交</button>
</form>
</body>
</html>

php代码

<?php
echo '<pre>';
$img = $_FILES['img'];
if(!empty($img))
{
$img_desc = reArrayFiles($img);
#print_r($img_desc);
foreach($img_desc as $val)
{
$newname = date('YmdHis',time()).mt_rand().'.'.$img["name"][0];
move_uploaded_file($val['tmp_name'],'C:\phpstudy_pro\WWW\upload\\'.$newname);
echo $newname;
}
}

function reArrayFiles($file)
{
$file_ary = array();
$file_count = count($file['name']);
$file_key = array_keys($file);

for($i=0;$i<$file_count;$i++)
{
foreach($file_key as $val)
{
$file_ary[$i][$val] = $file[$val][$i];
}
}
return $file_ary;
}
?>

 主要思路是打破正则匹配规则,或者填充垃圾数据绕过正则检测。

1.后缀名绕过

上传php时 

(1)filename换行绕过

 

 

 2.filename用多用=

 

 3.用两个filename

 

 4.文件名处填充垃圾数据

 5.文件名加特殊字符;:'  如 test;:.php(此处测试失败)

6.上传配置文件后上传jpg,如htacess文件。

 

 主要思路:

Content-Disposition绕过:

1.对Content-Disposition进行换行,大小写,对当中的key=value进行污染,如添加新的AAAAAAAAAAAAA="QQQQQQQQQQQ",或者删除一些配对。

filename绕过:

换行,%00,;,名字填充非常见字符,双写,多用/\,去除双引号或者添加单引号(filename=1.php" filename='1.php"),filename大小写转化等(尝试绕过waf的匹配规则,而后端能解释出来filename);

 

posted @ 2020-12-01 21:17  yzcxld  阅读(269)  评论(0)    收藏  举报