1、扫描工具的测试,记录请求记录。
2、托管远程下载服务,下载测试工具、shellcode等数据。
3、托管远程上传服务器,回传测试数据。
1、能够添加授权功能,防止未授权访问导致数据泄漏。
2、能够支持Curl、Wget等常见工具的上传和下载。
3、默认不开启目录浏览功能,防止绕过授权后,目录下所有数据泄漏。
4、打包运行、没有依赖、稳定运行,不容易崩溃。
5、支持中断继续上传、中断继续下载等功能。
6、能够兼容curl、wget程序的上传下载功能。
# Python >= 2.4
python -m SimpleHTTPServer 8000
# Python 3.x
python -m http.server 8000
import os
import time
from flask import Flask, request, send_file
ROOT_PATH = os.path.abspath(os.path.dirname(__file__))
BASE_PATH = None
basic_path = BASE_PATH if BASE_PATH else ROOT_PATH
upload_path = os.path.join(basic_path, 'uploads')
download_path = os.path.join(basic_path, 'download')
AUTH_PARAM = "auth" # 自定义认证参数
AUTH_CUSTOMS = "passpass" # 自定义认证参数值
AUTH_DEFAULT = time.strftime("%Y%m%d%H")
app = Flask(__name__)
def auth_check(request_context):
request_auth_info = str(request_context.args.get(AUTH_PARAM))
print(f"auth_info: {request_auth_info} <-> AUTH_PARAM:{AUTH_PARAM} <-> AUTH_VALUE:{AUTH_CUSTOMS} <-> AUTH_DEFAULT:{AUTH_DEFAULT}")
return request_auth_info == AUTH_DEFAULT if AUTH_CUSTOMS is None else request_auth_info == AUTH_CUSTOMS
def download_file(filename):
try:
# 获取查询参数
if not auth_check(request):
return "Unauthorized", 401
# Download ing
if not os.path.exists(download_path):
os.makedirs(download_path)
file_path = os.path.join(download_path, filename)
return send_file(file_path, as_attachment=True)
except Exception as e:
# return str(e)
return "error"
def upload_file():
try:
if not auth_check(request):
return "Unauthorized", 401
# Download ing
if not os.path.exists(upload_path):
os.makedirs(upload_path)
if 'file' not in request.files:
return "No file part"
file = request.files['file']
if file.filename == '':
return "No selected file"
if file:
filename = os.path.join(upload_path, file.filename)
file.save(f"{filename}.{time.time()}")
return "File Uploaded success!"
else:
return "File Uploaded failure!"
except Exception as e:
# return str(e)
return "error"
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8888)
AUTH_PARAM = "auth"
AUTH_CUSTOMS = "passpass"
# curl 下载
curl http://127.0.0.1/download/xxx?auth=passpass -o xxx
# 上传
curl -X POST -F '[email protected]' http://example.com/upload?auth=passpass
curl -F "[email protected]" http://example.com/upload?auth=passpass
UpDownFile是@jan-bar使用Go编写的简易上传下载文件服务器,经过这几天不断地Issue,目前已经很适合渗透测试小伙们的体质。
1、完美支持Curl、wget等常见工具的断点上传和断点下载。
2、-auth参数 支持http base 认证
3、-deny参数 支持关闭目录浏览功能
下载安装
# 项目地址
jan-bar/UpDownFile: 简易上传下载文件服务器
https://github.com/jan-bar/UpDownFile
# 安装
go install github.com/jan-bar/UpDownFile
# 编译 需要Go 1.22
build.bat
常用命令
# 启动服务
upDownFile.exe -s :8080
# 启动认证服务 且关闭目录浏览 (建议)
upDownFile.exe -s :8080 -auth "user:pass" -deny
# 下载文件
# upDownFile cli 下载
upDownFile cli -c -auth "user:pass" -o example.txt "http://xxx/example.txt"
# curl等程序下载
wget --user "user" --password "pass" --content-disposition "http://xxxx/example.txt"
curl -u "user:pass" -C - -OJ "http://xxxx/example.txt"
# 上传文件
# upDownFile.exe cli 上传
upDownFile.exe cli -c -auth "user:pass" -d @example.txt "http://xxxx/example.txt"
# curl等程序上传
curl -u "user:pass" -C - -T example.txt "https://xxxx/example.txt"
服务端启动时,会输出常用的命令和参数值,更多使用方式可以查看ReadMe文件。
原文始发于微信公众号(NOVASEC):基础设施推荐:HTTP上传下载服务器
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论