Skip to content
Tutorials Center
My learning

Topics

Lesson 14 of 37 ยท Exploits and Payloads

Exploit Modules Explained: Targets, Ranks, Check and Run

Understand how Metasploit exploit modules work conceptually: vulnerability classes, targets, ranks, the check method, safe use in a lab, and what defenders see and patch.

An exploit module takes advantage of a specific weakness in a specific piece of software. In an authorized test its job is to prove that a vulnerability is real and demonstrate its impact, so the owner can fix it. This lesson explains how exploit modules are organised and used, and why patching defeats them, without describing how to attack any real product.

Use exploit modules only against lab machines you own or systems you are explicitly authorized to test. Many exploits crash the target service, so never run one on a production system without a written plan. See scope and law.

What an exploit is

Software has bugs; a vulnerability is a bug that lets someone make the program do something its designer did not intend. An exploit is the technique (and code) that triggers it. A payload is what you ask the program to do once it is triggered. Metasploit keeps these separate.

flowchart LR
    V["Vulnerability: a flaw in software"] --> E["Exploit: triggers the flaw"]
    E --> P["Payload: runs afterwards"]
    P --> S["Session or command output"]

One exploit can carry many payloads, and one payload can ride on many exploits.

Common vulnerability classes

You do not need exploitation skills to understand the categories. They explain why patches and configuration matter.

Kinds of flaws

Memory corruption Unsafe memory handling.
Injection Input treated as commands.
Broken access Missing or weak checks.
Misconfiguration Dangerous defaults left on.

Different flaws, different fixes.

1 / 2
  • Memory corruption (buffer overflows and relatives): a program writes outside the memory it should. Modern operating systems add protections (ASLR, DEP, stack protections) that make reliable exploitation hard; the fix is a patch.
  • Injection: user-controlled input ends up interpreted as a command or query (SQL, shell, template). Fix: parameterised queries and strict input handling.
  • Authentication and access control flaws: missing checks, default passwords, logic errors.
  • Deserialization and parsing flaws: unsafe handling of structured data.
  • Misconfiguration: a service exposed on the wrong network, debug mode left on.

Anatomy of an exploit module in use

A real exploit module exposes the familiar options plus a target list and a payload.

TEXT
msf6 > use exploit/example/vulnerable_service
[*] No payload configured, defaulting to a generic reverse payload
msf6 exploit(example/vulnerable_service) > show options
msf6 exploit(example/vulnerable_service) > show targets
   Id  Name
   --  ----
   0   Automatic
   1   Example Service 2.0 on Linux x64
msf6 exploit(example/vulnerable_service) > set RHOSTS 10.10.10.20
msf6 exploit(example/vulnerable_service) > check
[+] 10.10.10.20:8080 - The target appears to be vulnerable.

(Example output for an invented module.) The important commands:

  • show targets lists the product versions or operating systems the exploit supports; set TARGET n picks one. "Automatic" tries to detect it.
  • show payloads lists payloads compatible with this exploit (see payloads).
  • check tests for the flaw without exploiting it where the module supports it. It is the right first step on any real engagement because it is gentler and shows whether the module's assumption holds.
  • exploit (or run) launches the attack. exploit -j runs it as a background job; exploit -z does not interact with the session immediately.

Rank: how risky is it for the target?

Rank describes the expected reliability and impact on the target. Higher is safer to run.

Rank Meaning
Excellent Never crashes the service; reliable
Great Has a default target and detects the target automatically
Good Has a default target and is a common case
Normal Reliable but depends on version or configuration
Average Unreliable, often needs more than one try
Low Very unreliable
Manual Needs manual intervention, may crash easily

The framework can refuse to run low-ranked exploits unless you opt in. Rank is the author's estimate, not a guarantee; always rehearse in a lab copy.

Python Safety gate on exploit rank

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.

This policy gate is a way to encode the rule "no risky exploits against production" into your own tooling. It is not a Metasploit feature, just a good practice.

The check-before-exploit workflow

flowchart TD
    A["Candidate flaw from recon"] --> B{"Does the module have check?"}
    B -- "yes" --> C["Run check in scope"]
    B -- "no" --> D["Read module notes and rehearse in lab"]
    C --> E{"Reported vulnerable?"}
    E -- "yes" --> F["Get written approval for exploitation"]
    E -- "no" --> G["Record result and move on"]
    D --> F

Many findings can be reported from a positive check alone, without exploitation.

Python Interpret check results

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.

What defenders see, and how they stop it

  • Patch the affected software; the module's check then reports "not vulnerable".
  • Application logs show the crafted request or crash that preceded the intrusion.
  • Endpoint detection shows an unusual child process spawned by a service (for example a web server starting a shell).
  • Network controls (segmentation, egress filtering) stop a successful exploit from calling back to the attacker.
  • Exploit protections in the operating system break many memory-corruption exploits.

An exploit that works in the lab against an unpatched copy and fails against the patched version is the cleanest way to prove a patch works. Keep both results in the report.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the relationship between an exploit and a payload?

    Metasploit separates the delivery (exploit) from the action (payload).
  2. 2. What does check do?

    A check is a gentler first step that shows whether the flaw seems present.
  3. 3. Which rank is the safest for the target service?

    Excellent exploits are reliable and do not crash the service.
  4. 4. Which defence directly removes an exploit's effect?

    Patching removes the flaw, so the module fails.

Summary

  • A vulnerability is the flaw, an exploit triggers it, a payload runs afterwards.
  • Use show targets, show payloads and check before exploit.
  • Rank estimates reliability and target risk; encode safety rules for production.
  • Patches, logging, endpoint detection and egress filtering defeat or reveal exploits.

Next: Payloads: Singles, Stagers and Stages