File Inclusion

原理:通过对url的操作,越权访问文件

Low

?page=../flag.txt

Medium

?page=..././flag.php

1
2
3
4
5
6
7
8
9
10
<?php

// The page we wish to display
$file = $_GET[ 'page' ];

// Input validation
$file = str_replace( array( "http://", "https://" ), "", $file );
$file = str_replace( array( "../", "..\\" ), "", $file );

?>

str_replace( array( "http://", "https://" ), "", $file );

该字符串或数组是将 subject 中全部的 search 都被 replace 替换之后的结果。只进行一次。

High

!fnmatch( "file*", $file )

fnmatch() checks if the passed filename would match the given shell wildcard pattern.

*:0~任意多个字符

[ ]:仅括号里的一个字符

!:非括号里的所有字符

:仅一个字符

\:仅斜线后面的当字符(精准)

file://协议

Impossible

fi-i

in_array($file, $configFileNames)

Searches for needle in haystack using loose comparison unless strict is set.(如果设置了,则会检查变量类型)

其他-

in_array绕过