web_php_include

web_php_include

web_php_include

代码审计

strstr()函数搜索字符串在另一字符串中是否存在,如果是,则返回str1字符串在str2第一次出现的位置,否则返回false。

str_replace()函数将参数中含php://替换为空

解题思路

第一种

因为不能利用php伪协议,可以利用其它伪协议。

data://也可以让用户控制输入流

此时的前提条件必须为allow_url_fopenallow_url_include为on状态

web_php_include

web_php_include

第二种

strstr()函数对大小写不敏感,可以大写绕过

web_php_include

web_php_include

知识点

伪协议

data:text/plain 或 data:text/plain;base64

php://input

php://filter

file://

zip://

web_php_include

web_php_include

  • data:text/plain

直接在对应url参数内输出:data:text/plain

  • php://input

可以访问请求的原始数据的只读流,将post请求中的数据作为php代码执行

  • php://filter

可以读取php文件代码以base64编码输出。

web_php_include

https://www.jianshu.com/p/3514f0fd79f7

  • file://

用于访问本地文件系统

  • zip://

可以访问压缩文件中的文件,但需要绝对路径

使用方法:zip://[压缩包绝对路径]#[压缩文件内的文件名]

注意:在url规则中,‘#’和url规则里的‘#’冲突了,所以需要使用编码%23的形式

使用方法:zip://[压缩包绝对路径]#[压缩文件内的文件名]

注意:在url规则中,‘#’和url规则里的‘#’冲突了,所以需要使用编码%23的形式