Ravindra BagaleCourses & study guides

23. Exploitation with Metasploit

23.2 Starting msfconsole

Metasploit chi mukhya command line mhanje msfconsole.

sudo systemctl enable postgresql        # database makes search fast (enable is allowed for boot)
sudo msfdb init                          # set up the Metasploit database (first time)
msfconsole                               # start the console

Inside the console:

msf6 > help                 # list command categories
msf6 > version              # framework version
msf6 > db_status            # is the database connected?
msf6 > workspace -a lab     # keep your lab work separate
msf6 > db_nmap -sV 192.168.56.20   # run Nmap and store results in the database
msf6 > hosts                # show discovered hosts
msf6 > services             # show discovered services

db_nmap runs the Nmap you already know and saves the results, so search and modules can use them.

Ravindra Bagale's Tip

If db_status does not say "connected", hosts/services stay empty and students get confused. Run sudo msfdb init first. With the database in place, Metasploit becomes much faster and more organised.

Lab

Start msfconsole, confirm db_status shows connected, create a lab workspace, and run db_nmap -sV 192.168.56.20. Then run hosts and services and confirm your scan is stored.