题目
直接上来就提醒flag在flag.php,而且题目提醒文件包含。直接F12看源码
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
<br />
<b>Notice</b>: Undefined index: language in <b>/var/www/html/index.php</b> on line <b>9</b><br />
Please choose the language you want : English or Chinese
<h1>Hi,EveryOne,The flag is in flag.php</h1><html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
<?php
if( !ini_get('display_errors') ) {
ini_set('display_errors', 'On');
}
error_reporting(E_ALL);
$lan = $_COOKIE['language'];
if(!$lan)
{
@setcookie("language","english");
@include("english.php");
}
else
{
@include($lan.".php");
}
$x=file_get_contents('index.php');
echo $x;
?>
</html></html>
<?php
if( !ini_get('display_errors') ) {
ini_set('display_errors', 'On');
}
error_reporting(E_ALL);
$lan = $_COOKIE['language'];
if(!$lan)
{
@setcookie("language","english");
@include("english.php");
}
else
{
@include($lan.".php");
}
$x=file_get_contents('index.php');
echo $x;
?>
得到php源码
源码分析
ini_get('display_errors')
:获取当前的 'display_errors' 配置值。这个配置项决定了是否直接在浏览器上显示 PHP 错误。ini_set('display_errors', 'On')
:如果当前的 'display_errors' 是关闭的(即!ini_get('display_errors')
为真),则将其设置为开启。error_reporting(E_ALL)
:设置 PHP 报告所有可能的错误,包括 E_NOTICE 级别的错误。$lan = $_COOKIE['language']
:从客户端的 cookie 中获取 'language' 的值,并将其存储在$lan
变量中。- 如果
$lan
没有值(即用户之前没有设置过语言 cookie),则执行以下操作:@setcookie("language","english")
:使用@
符号来抑制可能的错误,为客户端设置一个名为 'language' 的 cookie,其值为 'english'。@include("english.php")
:同样使用@
符号抑制错误,并包含(即执行)'english.php' 文件。
- 如果
$lan
有值(即用户之前已经设置了语言 cookie),则执行以下操作:@include($lan.".php")
:根据$lan
的值(如 'chinese'、'french' 等),包含并执行相应的语言文件(如 'chinese.php'、'french.php' 等)$x=file_get_contents('index.php')
:使用file_get_contents
函数读取当前目录下的 'index.php' 文件的内容,并将其存储在$x
变量中。echo $x
:输出$x
变量的内容,即 'index.php' 文件的内容。
本来想着直接将cookie:language=flag
但是不行,直接伪协议走起
language=php://filter/convert.iconv.UTF-8*.UTF-32LE*/resource=flag