Working with Metasploit Database
How to use metasploit database effectively
Setting it up
Metasploit has a database function to simplify project management and avoid confusion when setting up parameter values.
You will first need to start the PostgreSQL database, which Metasploit will use with the following command:
systemctl start postgresql
Then you will need to initialize the Metasploit Database using the msfdb init
command.
To check if the database has been initiated properly we can troubleshoot using db_status
command in msfconsole.
Workspace management
The database feature will allow you to create workspaces to isolate different projects. When first launched, you should be in the default workspace. You can list available workspaces using the workspace
command.
Adding a new workspace
Add a workspace using the -a
parameter.
Deleting a workspace
Delete a workspace using the -d
parameter, respectively.
Switching workspaces
You can switch workspaces using the workspace name
List all hosts
Adding new hosts
The hostname can also be left blank, which can be auto-populated by commands like db_nmap
.
Deleting hosts
Nmap scanning with db_nmap
The db_nmap command can be useful for scanning hosts and services
Database Commands cheatsheet
Command | Description |
---|---|
analyze | Analyze database information about a specific address or address range |
db_connect | Connect to an existing data service |
db_disconnect | Disconnect from the current data service |
db_export | Export a file containing the contents of the database |
db_import | Import a scan result file (filetype will be auto-detected) |
db_nmap | Executes nmap and records the output automatically |
db_rebuild_cache | Rebuilds the database-stored module cache (deprecated) |
db_remove | Remove the saved data service entry |
db_save | Save the current data service connection as the default to reconnect on startup |
db_status | Show the current data service status |
hosts | List all hosts in the database |
klist | List Kerberos tickets in the database |
loot | List all loot in the database |
notes | List all notes in the database |
services | List all services in the database |
vulns | List all vulnerabilities in the database |
workspace | Switch between database workspaces |
Last updated