Bugku:flag在index里

在这里插入图片描述
在这里插入图片描述

http://123.206.87.240:8005/post/index.php?file=show.php

题目提示我们flag在index中,通过url分析,这里发送了file为key,show.php为value的GET请求,应该是ctf常见套路–php文件包含漏洞,大致套路是这样滴:

<?php
	$file = $_GET["file"];
	... ...
	include($file);
?>

例如:test.php大致内容如上,通过访问http://xxx/xxx/test.php?file=xxx.php,则$file=xxx.php,也就是说:include(xxx.php),而对于php的include()函数,会获取指定文件的内容,在执行前将代码插入到test.php文件中。而如果被包含的文件中无有效的php代码,则会直接输出无效的文件内容。通常利用无效代码这一点来将文件内容输出。

通过以上分析,我们应该是需要获取index.php文件的内容进行下一步分析,那么就需要利用include(),包含index.php,并且是无效代码的index.php文件,尝试使用php伪协议php://filter,以base64编码格式读取文件(因为base64编码的index.php无法执行,将会被直接输出),构造:

php://filter/read=convert.base64-encode/resource=[文件路径]

文件路径这里采取相对路径,相对于/post/index.php文件所在目录下的index.php文件,即…/index.php(当前目录下的index.php文件)
在这里插入图片描述
再进行base64解码得到flag
在这里插入图片描述

发布了45 篇原创文章 · 获赞 15 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/baidu_41327283/article/details/83276918