Skip to content
Tutorials Center
My learning

Topics

Lesson 4 of 37 ยท Getting Started

msfconsole Basics: Commands, Search and Help

Learn the msfconsole interface: help, search with filters, use, info, show options, back, tab completion, logging with spool, and reading the prompt.

msfconsole is where you will spend most of your time. It looks like a shell but is a Ruby program with its own commands, plus access to ordinary shell commands. Learning a small set of commands well is more useful than memorising modules, because every module is driven the same way.

All examples show typical output, labelled as an example; nothing here runs real attacks. Where a command needs a real console, the code block is read-only, and the Python stand-ins model what the console does.

The prompt tells you the context

TEXT
msf6 >                              # no module selected
msf6 auxiliary(scanner/example/version_scan) >   # a module is loaded

When you use a module its type and path appear in the prompt. back returns to the bare prompt. This is a built-in safety net: always read the prompt before you press Enter.

The core commands

Command What it does
help or ? List all commands; help search shows one command's help
search term Find modules by name, CVE, platform, type and more
use path or use N Select a module by path or by the number from the last search
info Show description, options, references and author of the current module
show options List the module's settings and which are required
set NAME value Set an option for this module
unset NAME Clear an option
back Leave the current module
exit Quit the console

Tab completion works for commands, module paths and option names. Press Tab twice to see choices.

Searching

search is the command you will use most. It accepts keywords and filters written as key:value.

TEXT
msf6 > search type:auxiliary name:version
msf6 > search cve:2021 type:exploit platform:linux
msf6 > search type:post platform:windows

Common keys are name, type, platform, cve, author, rank, check, date and path. The result is a numbered table (example output):

TEXT
Matching Modules
================
   #  Name                                   Disclosure Date  Rank    Check  Description
   -  ----                                   ---------------  ----    -----  -----------
   0  auxiliary/scanner/example/version_scan  2019-04-01      normal  No     Example service version scan
   1  exploit/example/vulnerable_service      2020-08-18      great   Yes    Example service remote exec

use 1 selects row 1. The Rank column estimates how reliable an exploit is (excellent, great, good, normal, average, low, manual), and Check says whether the module can test for the flaw without exploiting it. A check is a gentle, defender-friendly first step.

Looking inside a module

TEXT
msf6 > use auxiliary/scanner/example/version_scan
msf6 auxiliary(...) > info
msf6 auxiliary(...) > show options
msf6 auxiliary(...) > set RHOSTS 10.10.10.20
msf6 auxiliary(...) > run

RHOSTS ("remote hosts") is the target option in almost every module; RPORT is the target port. LHOST and LPORT are for your own side (listeners). run and exploit both start the module (run is the general name; exploit is the same thing for exploit modules), and check runs the vulnerability test if the module supports it.

flowchart LR
    S["search"] --> U["use"]
    U --> I["info / show options"]
    I --> SET["set options"]
    SET --> C["check"]
    C --> R["run"]
    R --> B["back"]

A typical module session: look before you set, check before you run.

Shell commands and logging

You can run normal operating-system commands from the console (ls, ping, nmap). Use that to keep your whole test in one window. To record everything for your report:

TEXT
msf6 > spool /home/lab/logs/session1.txt
msf6 > spool off

spool writes the console output to a file. Pair it with the timestamped log you started in the scope lesson.

Other useful helpers: history lists past commands, color false turns off colours for pasted logs, and makerc file saves your commands as a resource script (see datastore and resource scripts).

A model of search filters

The stand-in below holds an invented list of modules as records and filters them with type: and name: words like the console does. It shows why precise filters beat long scrolling lists.

Python Filter modules like msfconsole search

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.

Reading a rank

Rank tells you the risk to the target of running an exploit: higher ranks crash the service less often. In a client engagement, prefer a module that has a check, and test on a copy first when you can.

Python Sort modules by 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.

Habits that save you from mistakes

  • Read the prompt before running anything.
  • Use info to read the description, references and any warnings.
  • show options before run; confirm RHOSTS is in scope.
  • Use check where available.
  • Keep one workspace per engagement (next lesson).

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What does the prompt show when a module is loaded?

    The prompt includes the module type and path, reminding you what is selected.
  2. 2. Which command lists a module's required settings?

    show options prints each option, its current value and whether it is required.
  3. 3. What does RHOSTS hold?

    RHOSTS means remote hosts, the target(s) of the module.
  4. 4. What does the Check column mean in search results?

    Check Yes means a safe vulnerability test is available.
  5. 5. How can you save console output for a report?

    spool writes everything the console prints to a file.

Summary

  • The prompt shows the loaded module; back leaves it.
  • search with filters, use, info, show options, set, check, run is the standard flow.
  • Rank and Check help choose safer modules.
  • spool records the session; confirm scope in RHOSTS.

Next: Workspaces and the Database