文件下载
概念
网站由于业务需求提供文件查看或下载功能时,如果对用户请求的文件未做充分限制和验证,恶意用户就能够利用此漏洞查看或下载服务器上的任意敏感文件。这些文件可能包括源代码文件、系统配置文件、密码文件等。通过此漏洞,攻击者可以获取系统敏感信息,进而对服务器进行更深层次的入侵
文件下载的实现方式
1、直接下载
<a href="http://www.example.com/files/xxx.rar">下载文件</a>
2、通过服务端脚本处理
<?php
$filename = $_GET['filename'];
// 安全检查缺失
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $filename . '"');
header('Content-Length: ' . filesize($filename));
readfile($filename);
?>
漏洞挖掘方法
1、页面信息分析
- 查看网页源代码,寻找文件下载相关的功能点
- 查找可能存在的危险函数:
- ==
readfile()== - ==
file_get_contents()== - ==
fopen()+fread()== - ==
file()==
- ==
2、URL参数分析
常见的文件下载参数:
download.php?path= download.php?file= down.php?file= data.php?file= readfile.php?file= read.php?filename=
或者包含参数:
&url= &file_name= &Filepath= &Path= &Data=
3、代码审计
- 审计服务端代码,检查文件下载功能的安全性
- 验证输入参数是否经过严格过滤
- 检查文件路径限制机制
输入readme.txt,点击下载,提示flag路径
输入1.txt,显示文件不存在!,同时发现存在文件下载漏洞
利用目录遍历,不断尝试构造payload,成功下载,找到flag
评论区
评论加载中...