BUUCTF刷题笔记(十六)

§ [GXYCTF2019]BabyUpload

§ [RoarCTF 2019]Easy Java

[GXYCTF2019]BabyUpload

<?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("上传类型也太露骨了吧!");
        }
    }
}
?>

上传 .htaccess

修改 Content-Type

上传 ba2in9a-asp.jpg

ba2in9a=show_source(‘/flag’);

[RoarCTF 2019]Easy Java

账号密码分别是 admin admin888

登陆后没有任何可用信息

查看 help 页面

抛出异常 java.io.FileNotFoundException:{help.docx}

请求方式改为 post

没有可用信息

查看别人的WP得知可以查看 WEB-INF/web.xml

servlet-class 存放在 /WEB-INF/classes 目录下

base64 解码即可得到 flag


BUUCTF刷题笔记(十六)
https://ba2in9a.top/298c959f
作者
ba2in9a
发布于
2022年5月14日
更新于
2022年5月14日
许可协议