Skip to content
Tutorials Center
My learning

Topics

Lesson 21 of 37 ยท Meterpreter and Post-exploitation

Post-exploitation Modules

Learn how Metasploit post modules work, how to run them against a session, which kinds of facts they gather, and how defenders limit what they can find.

After an authorized tester has a session, the next question is "what can this access reach?" That is the job of post modules. They run on top of an existing session instead of attacking a network service, and they gather facts: installed software, local users, patch level, network configuration, and so on.

This lesson covers how to find and run post modules, what categories exist, and how the same facts help defenders harden hosts. It builds on Meterpreter Commands and File System Work.

Run post modules only inside your own lab or a signed scope. They read sensitive information by design.

Where post modules live

Modules sit under post/ and are grouped by platform and purpose:

TEXT
post/windows/gather/...      enumerate local facts on Windows
post/linux/gather/...        enumerate local facts on Linux
post/multi/gather/...        work on any platform
post/windows/manage/...      change configuration (careful)
post/multi/recon/...         local reconnaissance

The gather modules mostly read, while manage modules change something and need extra care and a note in your log. Search by keyword with search type:post platform:linux and read details with info.

Running one

Every post module needs a SESSION option: the id of the session it should run in.

TEXT
msf6 > use post/linux/gather/enum_system
msf6 post(linux/gather/enum_system) > show options
Module options (post/linux/gather/enum_system):
   Name     Current Setting  Required  Description
   SESSION                   yes       The session to run this module on
msf6 post(linux/gather/enum_system) > set SESSION 2
SESSION => 2
msf6 post(linux/gather/enum_system) > run
[*] Running against lab-ubuntu
[+] Stored facts in the loot database

From inside a Meterpreter prompt, run post/path/to/module does the same. Results often go to the loot and notes tables of the database, so loot and notes bring them back later and hosts/services show what else was learned (see Information Gathering).

Typical fact groups

Group Example facts Why a defender cares
System OS build, patch list, uptime Missing patches show exposure
Software Installed programs and versions Outdated software is a prime target
Users Local accounts, group membership Unused admin accounts are risky
Network Interfaces, routes, ARP cache Shows what else is reachable
Credentials Stored configuration secrets Secrets in files must be removed

The point of an assessment is rarely the secret itself. It is the finding: "a service account with a password in a world-readable file allows lateral movement". Report the file and the fix, and redact the value.

How post modules are built

A post module is a Ruby class that includes helper mixins for the platform (file access, registry, process listing) and uses the session as its only connection. It makes no network call of its own. That explains why they are usually quiet on the wire and noticeable on the host.

Python Facts a post module might gather (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Turning facts into a report

Notice that the stand-in does what a good assessor does: converts raw facts into a statement with a recommended action. Add severity and evidence and you have a finding.

Python Rank findings by severity

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Limiting what post modules can find

  • Patch promptly and remove software nobody uses.
  • Disable or delete stale accounts; require MFA for admin roles.
  • Keep secrets in a vault, not in config files or shell history.
  • Segment the network so a single host does not see everything.
  • Log module-like behaviour: bursts of registry or file reads from a single process.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which option do nearly all post modules require?

    Post modules run through an existing session, so SESSION selects which one.
  2. 2. What is the difference between gather and manage modules?

    Gather modules collect facts, while manage modules alter the system and need extra care.
  3. 3. How should a stored password found in a file appear in a report?

    The finding is the weakness, not the secret, so redact the value.
  4. 4. Why are post modules often quiet on the network?

    All their work happens on the host through the session channel.

Summary

  • Post modules run through a session and gather or change local state.
  • gather is mostly read-only; manage changes things and must be logged.
  • Results land in the loot and notes tables.
  • A good report turns facts into findings with severity and a fix.
  • Defenders reduce the yield by patching, removing stale accounts and keeping secrets out of files.

Next: Pivoting and Routing Concepts