当前位置:网站首页>网络安全——文件上传白名单绕过
网络安全——文件上传白名单绕过
2022-07-24 13:32:00 【Beluga】
文件上传白名单绕过
第一步,打开网络拓扑,启动实验虚拟机。
第二步,打开桌面上的Chrome浏览器,在地址栏中输入http://127.0.0.1,进入upload-labs页面中,然后点击左侧的导航栏Pass-01进入关卡1,右键点击网页选择查看网页源代码(V)

关键部分源码为如下(位于网页的尾部)

发现有一个checkFile()函数,推测可能是这个函数进行判断的,第一种方法我们将前端的JavaScript脚本禁用掉之后再上传。具体步骤:打开一个新的窗口在地址栏中输入:chrome://settings/content/javascript,进入如下面板,然后点击已允许的开关,将该状态改为已屏蔽

然后构造文件内容为:<?php phpinfo(); ?>的文件,将其文件后缀名改为php,再上传

最后访问/upload/的目录,并访问已上传的文件shell.php


第三步,第二种方法,在进行下面的实验步骤之前,请先将js的禁用改为启用。由于这里只采用了前端验证文件后缀名的方式过滤, 所以可以通过抓包修改文件后缀绕过前端的过滤,具体方法如下:在浏览器中输入chrome://setting/system,在设置页面中点击打开代理

依照下图设置代理参数

双击打开桌面上的brupsuitepro,进入抓包软件,确保Intercept is on代理开启状态

然后将第二步中构造的shell.php改名为shell1.jpg然后Forward发送数据

回到浏览器观察,已经成功绕过js前端的过滤

访问http://127.0.0.1/upload/shell1.php

进行下面的操作之前,先清空上传文件,上传文件的按钮为关卡的右上角的位置
第四步,点击左侧导航栏窗口中的Pass-11进入关卡11,点击查看源代码按钮

在代码的第五行发现了白名单过滤:$ext_arr = array('jpg','png','gif'); 继续往下审计,发现在第九行的位置$img_path = $_GET['save_path']. "/".rand(10, 99).date("YmHis"). ".".$file_ext; 这段代码中save_path是可控的,因此我么可以采用00截断的方法来进行绕过,具体操作的过程:在上传文件的时候抓包,将上传的文件名写为1.jpg,save_path改成../upload/1.php%00,具体操作如下:首先上传文件名为1.jpg的文件,内容为<?php phpinfo(); ?>同时打开浏览器本地代理,使用burpsuite进行抓包,找到如下待修改的参数save_path

save_path改成../upload/1.php%00

点击Forward转发,点击Intercept is on关闭代理,访问http://127.0.0.1/upload/1.php

回到首页关卡清空上传的文件。
第五步,点击左侧导航栏窗口中的Pass-12进入关卡12,点击查看源代码按钮

与第十一关不同的是这次save_path是通过post传进来的,但依然存在00截断,但这次我们通过在二进制的方式来修改,因为post不会像get方法对%00进行自动解密,具体操作如下:上传文件2.jpg内容为<?php phpinfo(); ?>并抓包,得到下面的数据包

修改../upload/为../upload/22.php+,注意此处的+二进制为2b,是作为后面修改的文件的标志,点击Hex进入二进制模式

找到标记2b的位置

修改2b为00,点击Forward进行上传

点击Intercept is on关闭代理,访问http://127.0.0.1/upload/22.php

回到首页关卡清空上传的文件。
实验结束,关闭虚拟机。
边栏推荐
- Modification of EAS login interface
- Go redis pipeline application
- Aike AI frontier promotion (7.24)
- 网络安全——Cookie注入
- Redis (13) -- on master-slave replication of redis
- [paper reading] mean teachers are better role models
- An example of how to save various data types by using esp32 EEPROM library functions under Arduino framework
- Wang Ping, co-founder of Denglin Technology: Innovation + self research "dual core" drive, gpu+ enabling AI takes root | quantum bit · viewpoint sharing review
- Exploration of sustainable learning ability to support the application of ecological evolution of Pengcheng series open source large models
- Network security - Web penetration testing
猜你喜欢

I 用c I 实现 大顶堆

EAS environment structure directory
![[paper reading] temporary binding for semi-superior learning](/img/59/846d868cccad238267bd984f085218.png)
[paper reading] temporary binding for semi-superior learning

Outdoor billboards cannot be hung up if you want! Guangzhou urban management department strengthens the safety management of outdoor advertising

【论文阅读】TEMPORAL ENSEMBLING FOR SEMI-SUPERVISED LEARNING

简易订单管理系统小练习

Chinese character style migration --- diversity regularization stargan for Chinese character multi font generation

游戏思考04总结:针对帧、状态、物理同步的总结(之前写的太长,现在简略下)

The core capability of accelerating enterprise data application innovation flexibility

Kunyu installation details
随机推荐
Atcoder beginer contest 261 f / / tree array
指针进阶部分(1)
[acm/ two points] two points clear entry-level explanation
Relevant laws of animation movement (judge where to move according to parameters)
Queue (stack)
How to quickly learn Embedded
The use of two-dimensional array (including the definition of two-dimensional array, the declaration and initialization of two-dimensional array (dynamic initialization, static initialization), common
2022.07.21
AtCoder Beginner Contest 261E // 按位思考 + dp
网络安全——文件上传渗透测试
Dtcloud uses custom fonts
Embedded cognitive network card PHY self negotiation
Research and progress of traffic situation awareness based on social media data enhancement
Number of palindromes in Li Kou question
Easycvr platform security scanning prompt go pprof debugging information leakage solution
Interview question 01.02. determine whether it is character rearrangement
深入浅出边缘云 | 2. 架构
Modification of EAS login interface
【论文阅读】TEMPORAL ENSEMBLING FOR SEMI-SUPERVISED LEARNING
网络安全——报错注入