当前位置:网站首页>Principle of file upload vulnerability
Principle of file upload vulnerability
2022-07-23 11:25:00 【GSflyy】
File upload vulnerability introduction
File uploading is a common function of modern Internet ,
Allow users to upload pictures last time 、 video 、 And other types of documents , The more functions provided to users ,Web The greater the risk of attack .
When uploading files , If the uploaded files are not strictly verified and filtered , It's easy to upload files , Upload script file ( Include asp,aspx,php,jsp etc. )
Malicious upload behavior may cause the website and even the entire server to be controlled . Malicious script files are called WebShell,WebShell It has powerful functions , For example, check the server directory 、 Files in server 、 Execute system commands, etc .
JS Detection bypass ( Front end detection )
Detection principle
call Js Of selectFile() function , Detect file suffix
Bypass method :
1. Delete local browser js Method ( Ban js)
2. Modify file suffix
File suffix bypass
Detection principle
By function pathinfo() Get file suffix , Convert suffix to lowercase (strtolower) And judge whether it is php
Bypass method
Some middleware Allow parsing other file suffixes , If in httpd.conf In profile , Configure the following code , Can be resolved php、php3、phtml file . So upload a suffix named php3、phtml Is ok .

Bypass method 2
combination Apache File parsing mechanism , Parse the file suffix from back to front , If the suffix is not recognized, continue to judge until you encounter a resolvable suffix , for example 123.php.360,Apache The parsing mechanism will parse it into php Document and execute

ps: Upload is not allowed php file , Just upload php.360( laugh )
File types bypass ( White list bypass )
MIME Bypass :
Detection principle
utilize $_FILES['files'] ['type'] Determine whether the picture format is image/gif,image/jpeg,image/pjpeg, If not, upload is not allowed
Bypass method
$_FILES['files'] ['type'] This value is extracted from the request packet Content-Type In order to get , therefore burp Packet capturing and modifying this tag value can bypass
The upload file is php when ,Content-Type The value is application/octer-stream, The upload file is jpg Format file when Content-Type The value is image/jpeg.
File magic number detection bypasses :
Detection principle
utilize getimagesize() function , If you can't get the picture information ( Indicates that the file is not a picture ) You cannot upload this file
Bypass method
Add the corresponding header value of the picture at the beginning of the script file ( Such as add GIF89a)
89 50 4E 47 0D 0A 1A 0A (PNG Head ), Note that hexadecimal to ascii

File truncation bypasses
Detection principle :
because 00 Represents the Terminator , PHP Will be able to 00 The following characters are deleted
Cut off condition :PHP Version less than 5.3.4.magic_quotes_gpc( Magic quotes ) be in off state
Application :
The uploaded file has been renamed , Unable to find the file you uploaded
Bypass method :
GET Add... To the method %00 truncation
POST Method passed in %00 And decoding
ps: Truncation bypass can control the upload path of files
File content bypass
Detection principle :
Some website file detection logic allows uploading arbitrary files first , Then check whether the contents of the file contain executable scripts , Delete if included . Use here sleep() Function to simulate the time required to determine whether there is a script
<?php
fputs(fopen('./shell.php','w'),'<?php phpinfo();?>')
?>
Bypass method :
Take advantage of the time difference between successfully uploading to the deleted file , Upload a .php file , Access this before deleting php File makes it run to generate a new php file , New files will not be deleted .
边栏推荐
- 命令执行漏洞及防御
- Application of higher-order functions: handwritten promise source code (III)
- Pytorch white from zero uses North pointing
- Precautions for realizing "real-time data response" on the page
- Pyspark learning notes
- 如何自定义Jsp标签
- Clear the buffer with getchar (strongly recommended, C language is error prone, typical)
- Inheritance mode of JS
- Framework introduction Mvt
- Request data acquisition and response
猜你喜欢

机器学习零散笔记:一些概念和注意

The attribution of branch and loop statements in C language
D2DEngine食用教程(1)———最简单的程序

基于el-table的树形表格及js-xlsx实现下载excel功能(二)

Fun code rain, share it online~-

页面实现 “实时数据响应” 的注意事项

自定义公式输入框
![[监控部署实操]基于granfana展示Prometheus的图表和loki+promtail的图表](/img/34/b7a05bff05e1d3a1daef4fb2b98a92.png)
[监控部署实操]基于granfana展示Prometheus的图表和loki+promtail的图表
![[Doris]配置和基本使用contens系统(有时间继续补充内容)](/img/74/21c5c0866ed6b1bb6f9a1e3755b61e.png)
[Doris]配置和基本使用contens系统(有时间继续补充内容)

systemctl-service服务添加环境变量及模板
随机推荐
Error when PLSQL creates Oracle Database: when using database control to configure the database, it is required to configure the listener in the current Oracle home directory. You must run netca to co
Precautions for realizing "real-time data response" on the page
Rice mall registration
Fun code rain, share it online~-
js的call、apply、bind
Solve the problem that the time format of manually querying Oracle database is incorrect (date type)
Web Component-自定義元素的生命周期
$attrs中的对象没有变化,但触发了watch监听?
js中类数组对象以及类数组转换的方法(ES6, ES5)
TypeScript 高级类型
pyspark学习笔记
Clear the buffer with getchar (strongly recommended, C language is error prone, typical)
gbk编解码器无法解码的问题,有可能出题出在文件名上
[flink]flink on yarn之flink-conf最简单配置
Constructor, prototype chain, instanceof
高阶函数的应用:手写Promise源码(四)
uni-app小程序中v-show与display:flex一起使用时v-show不生效!
Error handling of "listener not started or database service not registered" in Oracle database creation
js的闭包的理解
通用查询&分页代码