当前位置:网站首页>网络安全——文件上传白名单绕过
网络安全——文件上传白名单绕过
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

回到首页关卡清空上传的文件。
实验结束,关闭虚拟机。
边栏推荐
- Data + AI Summit 2022 PPT 下载
- ESP32ADC
- Common OJ questions of stack and queue
- 汉字风格迁移篇---用于汉字多字体生成的多样性正则化StarGAN
- July training (day 24) - segment tree
- Make a fake! Science has exposed the academic misconduct of nature's heavy papers, which may mislead the world for 16 years
- Atcoder beginer contest 261e / / bitwise thinking + DP
- 网络安全——报错注入
- Chat room project
- Recommended idling tools | comprehensive comparison of 10 spatial transcriptome deconvolution tools
猜你喜欢

基于图正则化的贝叶斯宽度学习系统

Exploration of sustainable learning ability to support the application of ecological evolution of Pengcheng series open source large models

Network security - Web information collection

简易订单管理系统小练习

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

Modern data architecture selection: Data fabric, data mesh

网络安全——报错注入

Data + AI summit 2022 PPT download

基于典型相关分析的多视图学习方法综述

为什么函数式接口 Comparator 中有 “两个抽象方法”?
随机推荐
Icml2022 | branch reinforcement learning
How to quickly learn Embedded
Embedded problem troubleshooting methods, network problems, SD card problems, device startup problems, serial port problems, I2C problems, SPI problems, PCIe problems, etc
C代码规范
Number of palindromes in Li Kou question
flow
The MySQL select delay scenario corresponds to that all database query statements will be delayed. After the scenario injection, I executed one
Handler learning
Search engine based on boost library
从云原生到智能化,深度解读行业首个「视频直播技术最佳实践图谱」
Common OJ questions of stack and queue
群体知识图谱:分布式知识迁移与联邦式图谱推理
Chrome plug-in development tutorial
Collection collection framework
Dtcloud uses custom fonts
Sort method -- bubble sort (use an array to sort a string of numbers from large to small or from small to large)
Experience on how to improve the anti-interference of TTL (UART) communication
Writing browser plug-ins
Atcoder beginer contest 261 f / / tree array
如何用WebGPU流畅渲染百万级2D物体?