在日常渗透测试中会发现有的上传功能的地方会限制上传大小,例如15M,如果绕过前端的这个提示,使用BURP抓包超大包 BURP会特别卡,导致无法发送,因此写了个小html和py来传输数据。
如下图所示可能会遇到这类功能
前端HTML代码
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>文件上传演示(代理版)</title>
<style>
/* 样式保持不变 */
body {
font-family: Arial, sans-serif;
max-width: 600px;
margin: 20px auto;
padding: 20px;
}
.upload-box {
border: 2px dashed #ccc;
padding: 30px;
text-align: center;
margin: 20px 0;
}
#status {
margin-top: 15px;
padding: 10px;
border-radius: 4px;
}
.input-group {
margin: 10px 0;
text-align: left;
}
.input-group label {
display: block;
margin-bottom: 5px;
color: #666;
}
.input-group input {
width: 100%;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
}
.success { background: #dff0d8; color: #3c763d; }
.error { background: #f2dede; color: #a94442; }
</style>
</head>
<body>
<h2>文件上传演示</h2>
<div class="upload-box">
<!-- 新增:Authorization输入框 -->
<div class="input-group">
<label for="authInput">Authorization:</label>
<input type="text" id="authInput" placeholder="Bearer token (可选)">
</div>
<!-- 新增:Cookie输入框 -->
<div class="input-group">
<label for="cookieInput">Cookie:</label>
<input type="text" id="cookieInput" placeholder="Cookie值 (可选)">
</div>
<input type="file" id="fileInput" accept=".pdf,.doc,.docx">
<button onclick="uploadFile()">上传文件</button>
<div id="status"></div>
</div>
<script>
async function uploadFile() {
const fileInput = document.getElementById('fileInput');
const statusDiv = document.getElementById('status');
const authInput = document.getElementById('authInput');
const cookieInput = document.getElementById('cookieInput');
if (!fileInput.files.length) {
showStatus('请先选择文件', 'error');
return;
}
// +++ 修复1: 确保FormData初始化 +++
const formData = new FormData();
formData.append('dir', 'user_pri');
formData.append('file', fileInput.files[0]);
// 构建动态Header
const headers = {};
if (authInput.value) headers['Authorization'] = authInput.value;
if (cookieInput.value) headers['Cookie'] = cookieInput.value;
try {
const response = await fetch('http://localhost:5000/upload', {
method: 'POST',
headers: headers,
body: formData // 使用已初始化的formData
});
if (response.ok) {
const result = await response.json();
showStatus(`文件上传成功!文件名:${result.filename}`, 'success');
} else {
showStatus(`上传失败:${response.statusText}`, 'error');
}
} catch (error) {
showStatus(`网络错误:${error.message}`, 'error');
}
}
function showStatus(message, type) {
const statusDiv = document.getElementById('status');
statusDiv.className = type;
statusDiv.textContent = message;
setTimeout(() => {
statusDiv.className = '';
statusDiv.textContent = '';
}, 3000);
}
</script>
</body>
</html>
python代
from flask import Flask, request
from flask_cors import CORS
import requests
app = Flask(__name__)
app.config['MAX_CONTENT_LENGTH'] = 100 * 1024 * 1024 # 允许100MB文件
CORS(app)
@app.route('/upload', methods=['POST'])
def upload():
try:
# 获取请求头
auth_header = request.headers.get('Authorization', '')
cookie_header = request.headers.get('Cookie', '')
file = request.files['file']
# 转发请求到目标API
response = requests.post(
'https://test.digifttest.com/api/file/upload',
files={'file': (file.filename, file.stream)},
headers={
'Authorization': auth_header,
'Cookie': cookie_header
},
data={'dir': 'user_pri'}
)
# 打印完整的返回包信息到控制台
print("="*50 + " 响应详情 " + "="*50)
print(f"状态码: {response.status_code}")
print("\n响应头:")
for key, value in response.headers.items():
print(f" {key}: {value}")
print("\n响应体:")
try:
print(response.json()) # 尝试解析JSON
except:
print(response.text) # 纯文本或二进制内容
print("="*110 + "\n")
# 返回完整响应信息
return (
response.content,
response.status_code,
dict(response.headers) # 携带原始响应头
)
except Exception as e:
print(f"! 错误: {str(e)}")
return {
"error": str(e),
"message": "代理服务器内部错误"
}, 500
if __name__ == '__main__':
app.run(port=5000, debug=True) # 启用debug模式显示详细错误
填写凭据
上传成功,这里我选择了一个20M的PDF文件上传成功,绕过了前端的限制,但是我还是上传不了更大的文件,例如200M
应该是Spring boot或者Nginx层再次进行了限制
那么这里有什么作用呢,其实这里是一个类似攻击链,例如可以上传大包给OSS存储,OSS存储被访问是需要流量收费的,如果原本是15M,那麽攻击者就得刷流量刷到死,那如果攻击者上传的文件是是100M呢 ,1G的文件被刷流量呢,这个的危害就比较大了。
我们可以通过以下案例学习
也就是说一个照片大小大概在1570G/2554=600M左右
我们可以查看阿里云的OSS收费详情
阿里云OSS
https://www.aliyun.com/price/product?spm=5176.8465980.console-base_help.4.4e701450EnmFQ6#/oss/detail/ossbag
流入(上传不用钱)
流出(访问需要收费约0.5/G)
如果公司主要做海外服务的,那么配合这个大文件进行访问攻击,可以造成较大的金钱损失
网络安全系统学习资源推荐
网络安全作为数字时代的核心技术基石,已成为国家与企业发展的战略优先级。构建完整的安全能力体系,需从基础理论到实战对抗层层深化。以下为核心学习资源汇总:
- 网络安全完整学习路线图(覆盖全领域知识点);
- 20份渗透测试专业电子书;
- 357页安全攻防实战笔记;
- 50份安全攻防面试指南(含头部企业真题);
- 安全红队渗透工具包;
- 网络安全必读书籍清单;
- 100个漏洞实战案例解析;
- 安全大厂内部培训视频资源;
- 历年CTF夺旗赛题深度解析。
ps:网上虽然也有很多的学习资源,但基本上都残缺不全的,这是我们和网安大厂360共同研发的网安视频教程,之前都是内部资源,专业方面绝对可以秒杀国内99%的机构和个人教学!全网独一份,你不可能在网上找到这么专业的教程。
内容涵盖了入门必备的操作系统、计算机网络和编程语言等初级知识,而且包含了中级的各种渗透技术,并且还有后期的CTF对抗、区块链安全等高阶技术。总共200多节视频,200多G的资源,不用担心学不全。