msfdb fails to init database if msfconsole hasn't been run
jhart-r7 opened this issue · 1 comments
Depending on how metasploit was installed, or what was run after install, the ~/.msf4
directory will not exist.
For example, if you use this installer and don't run msfconsole
, the ~/.msf4
directory will not exist (assuming an otherwise clean system). Normally this isn't a problem, because when you then run msfconsole
(as non-root
), it will prompt you to create the database, and at that point ~/.msf4
will have been created and all is well.
However, if you are attempting to run msfconsole
, say, with an RC file or other ~unattended fashion, the prompting may not happen or may not be desirable. In these situations, one could run msdb init
, but because ~/.msf4
doesn't exist, you will encounter the following:
/opt/metasploit-framework/embedded/framework/msfdb:210:in `initialize': No such file or directory @ rb_sysopen - /home/msf/.msf4/database.yml (Errno::ENOENT)
from /opt/metasploit-framework/embedded/framework/msfdb:210:in `open'
from /opt/metasploit-framework/embedded/framework/msfdb:210:in `init_db'
from /opt/metasploit-framework/embedded/framework/msfdb:315:in `<main>'
Until I read the code, I chased my tail a bit trying to find a database.yml
that would work, and was confused because there wasn't one that came with the installer. As it turns out, the issue is as I described above.
This is a simple fix. PR incoming.
My simple work around locally was to mkdir ~/.msf4
prior to msfdb init
, which #62 implements more officially.
$ sudo msfconsole