当前位置:网站首页>[file upload vulnerability 06] server file content detection and bypass experiment + image horse production method (based on upload-labs-14 shooting range)
[file upload vulnerability 06] server file content detection and bypass experiment + image horse production method (based on upload-labs-14 shooting range)
2022-06-11 11:31:00 【Fighting_ hawk】
Catalog
1 summary
1.1 Purpose
For security , The server also needs to detect the contents of the file .
1.2 test method
- For picture files ,PHP There's a function in getimagesize(), This function itself detects the size of the picture , However, before detection, it will also determine whether the target file is an image , therefore , You can use this function to detect whether the file content outputs the picture type .
- Because the header content of the same type of file is the same , The server also often judges according to the header content of the file .
2 How to make a picture horse
Purpose : When you ask the server to detect the contents of the file , Judge the file as .
2.1 Method 1 : Direct editing
Create a new file and name it info.gif, The contents of the document are as follows . The file is in the function getimagesize() When testing , Will be identified as gif picture , However, the file cannot execute the code directly on the server side , Other vulnerabilities are needed to execute .
GIF89a
<?php
phpinfo();
?>
2.2 Method 2 : Merge files
- Prepare a picture , For example, the file name here is fighting_hawk.png.

- Prepare one php In a word, Trojan files , The file name here is
info.php, The content is<?php phpinfo(); ?>. - Merge files . stay windows Under the system , function cmd, Enter the command
copy fighting_hawk.png/b+info.php/a muma.jpg. It should be noted that you need to cd Go to the path where the two files are located and execute the command .
- Open the generated file in Notepad , You can see that it contains php Code statements .

2.3 Method 3 : Using the hex editor
- What we need to know is , The file headers of various pictures are the same , For example, all jpg The header of the file is consistent ; The header file is different between pictures in different formats .
- function getimagesize() Unrecognized file generated by file illusion .
- Common image file types are as follows :
| File format | Head |
|---|---|
| .gif | 47 49 46 38 39 61 F1 00 2C 01 F7 00 00 64 32 33 |
| .jpg | FF D8 FF E0 00 10 4A 46 69 46 00 01 01 01 01 2C |
| .png | 89 50 4E 47 0D 0A 1A 0A 00 00 00 0D 49 48 44 52 |
- New file , Name it 16.png, The contents of the document are as follows , Need to be in 16 Convert the first line to... In the binary editor ASCII code .
89 50 4E 47 0D 0A 1A 0A 00 00 00 0D 49 48 44 52
<?php phpinfo(); ?>
3 Introduction to the experiment
3.1 The experiment purpose
Master methods to bypass content detection , Verify the existence of file upload vulnerability .
3.2 Experimental environment
- shooting range : be based on WAMP Environmental upload-labs shooting range , Refer to the article for the construction process 《 be based on WAMP Environmental upload-labs Vulnerability test platform construction process 》.
- attack : install BurpSuite Software .
3.3 Preparation before experiment
- Prepare a picture of the horse , The file may be a Trojan horse , It can also be any other file , In this experiment, we used php The probe is used as a test file , To verify whether there are file upload vulnerabilities and methods to bypass vulnerability detection .
- Use the file generated by the above method 1 to test , The file named :
info.gif.
4 Experimental process
- Test sequence : front end JS→MIME type → file extension → The contents of the document . Because the content of the file needs to be modified , The related workload is large .
- Select the prepared picture horse to upload .

- You can see that the file is uploaded successfully , Because the specific content of the document is not a picture , Therefore, the picture content cannot be displayed here .

- The files that need to be studied later contain vulnerabilities 、 Server parsing vulnerability, etc , To make the file execute successfully . Now go directly to the server to find and type the uploaded picture horse , Open... In Notepad , You can see that the malicious code inside has not been deleted , Description file uploaded successfully .

- Conclusion : Although the server cannot run the code in the file ( To execute, you need to cooperate with the server to resolve the vulnerability 、 The file contains vulnerabilities and other vulnerabilities to achieve , For example, save the file as php Format files and so on ), However, this should still be recorded in the penetration test report , There is an arbitrary file upload vulnerability .
5 summary
- Understand the content of the file header and how the server checks the content and type of the file ;
- Master the making method of picture horse ;
- Master the method of bypassing server-side content detection .
边栏推荐
- 测试cos-html-cache静态缓存插件
- 外观模式--在各种套餐中早就用到啦!
- Shi Yigong: I was not interested in research until I graduated from my doctor's degree! I'm confused about the future, and I don't know what to do in the future
- 【碎碎念】关于波长|波速|周期的想法
- Liufan, CFO of papaya mobile, unleashes women's innovative power in the digital age
- Test cos HTML cache static cache plug-in
- Exploration of kangaroo cloud data stack on spark SQL optimization based on CBO
- 命令模式--进攻,秘密武器
- Smart sidebar plug-in: Mo widgets
- An introduction to creating VOC datasets or Yolo datasets using labelimg
猜你喜欢

CAP理论听起来很高大上,其实很简单

Interpretation of cube technology | past and present life of cube Rendering Design

AI security and Privacy Forum issue 11 - stable learning: finding common ground between causal reasoning and machine learning

The application of the spingboot+quartrz production environment supports distributed, custom corn, reflective execution of multiple tasks

Use yolov5 to train your own data set and get started quickly

Method of converting VOC format data set to Yolo format data set

MYCAT sub database and sub table

Typeerror: argument of type "Int 'is not Iterable

Application of volatile in single chip microcomputer

Command mode - attack, secret weapon
随机推荐
发布WordPress数据库缓存插件:DB Cache Reloaded 3.1
Method of converting VOC format data set to Yolo format data set
Using domestic MCU (national technology n32g031f8s7) to realize pwm+dma control ws2812
Summary of information of main account of Chia Tai futures on Wednesday in advance
Characteristics and classification of creation mode (single case, factory)
The application of the spingboot+quartrz production environment supports distributed, custom corn, reflective execution of multiple tasks
Learn 02 - slice, morphological change and dimension exchange of numpy multidimensional array
WordPress database cache plug-in: DB cache Reloaded
nft数字藏品app系统搭建
[fragmentary thoughts] thoughts on wavelength, wave velocity and period
普通人应当如何挑选年金险产品?
修改 WordPress 管理账号名称插件:Admin renamer extended
WordPress landing page customization plug-in recommendation
Tu ne peux pas être libre sans richesse?
Use yolov3 to train yourself to make datasets and get started quickly
What is the latest popular annuity insurance product with higher income in 202?
my.cnf中 [mysql]与[mysqld] 的区别 引起的binlog启动失败的问题
Études à la fin de l'enseignement 03
使用Yolov5训练自己制作的数据集,快速上手
Application of volatile in single chip microcomputer