Databases

Setting up the Database

# Start PostgreSQL
$sudo service postgresql status
$sudo systemctl start postgresql

# Initiate a Database
$sudo msfdb init 
<...>
    # Error may occur after Fresh installation.
<...>
$sudo msfdb status
[+] ...
[+] Creating configuration file '/usr/share/metasploit-framework/config/database.yml'
[+] ...

# Connect to the initiated Database
$sudo msfdb run

# If something goes wrong 
$msfdb reinit
$cp /usr/share/metasploit-framework/config/database.yml ~/.msf4/
$sudo service postgresql restart
$msfconsole -q

msf6 > db_status

[*] Connected to msf. Connection type: PostgreSQL.

msf6 > help database

Using the Database

Workspaces

msf6 > workspace
    -> Lists the available workspaces
msf6 > workspace -a <Workspaace-name-to-add>
msf6 > workspace <Workspace-name>
[*] Workspace: Target_1 # Selected

Importing the scan results

msf6 > db_import <nmap.xml>
msf6 > hosts
msf6 > services

Nmap inside Metasploit

msf6 > db_nmap -sV -sS 10.10.10.8

Exporting Data

msf6 > db_export -f xml backup.xml

Creds & Loot

msf6 > creds
msf6 > loot 

Last updated