Home  >  Article  >  Backend Development  >  Detailed explanation of filter protocol in PHP

Detailed explanation of filter protocol in PHP

小云云
小云云Original
2018-02-26 13:15:314698browse

This article mainly shares with you the detailed explanation of the filter protocol in PHP, hoping to help everyone.

php:// — 访问各个输入/输出流(I/O streams)php://input 是个可以访问请求的原始数据的只读流。
php://filter 是一种设计用来允许过滤器程序在打开时成为流的封装协议。这对于单独具有完整功能的文件函数非常有用,否则就没有机会在读取内容之前将过滤器应用于流之上。
该协议语法为:php://filter:/<action>=<name>
比如 php://filter:/resource=http://www.baidu.com

Use php://filter to obtain web page content:

<?php$url = 'http://www.phpfamily.cn';$data = file_get_contents('php://filter/resource=' . $url);
echo $data;  //输出结果我http://www.phpfamily.cn页面的内容

Parameter list of php://filter

##ParameterFunctionreadReadwriteWriteresourceData source##read parameter value can be

string.strip_tags: Clear all html tags in the data stream

string.toupper: Convert the content in the data stream to uppercase

string.tolower: Convert the content in the data stream to lowercase
convert. base64-encode: Convert the content in the data stream to base64 encoding convert.base64-decode: The corresponding decoding
above is a typical file inclusion vulnerability. We can view the code we want to see by constructing a statement containing the vulnerability: file=php://filter/convert.base64-encode/resource=index.php. Then decode the resulting base64 code.

The above is the detailed content of Detailed explanation of filter protocol in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn