metasploit can't use default msf3 to connect

xina1i picture xina1i · Sep 14, 2015 · Viewed 15k times · Source

I install metasploit v4 in ubuntu 14.04(LTS) in /opt/metasploit. And I install postgresql too. I am a very fresh to metasploit and postgresql. I start metasploit, but I can't connect to database, so I change this file /opt/metasploit/apps/pro/ui/config/database.yml, I just only change password to "testtest", and file content is:

development:
     adapter: "postgresql"
     database: "msf3"
     username: "msf3"
     password: "testtest"
     port: 7337
     host: "localhost"
     pool: 256
     timeout: 5

  production:
    adapter: "postgresql"
    database: "msf3"
    username: "msf3"
    password: "testtest"
    port: 7337
    host: "localhost"
    pool: 256
    timeout: 5

so I do this:

service postgresql restart
service metasploit restart

and those execute successfully. I run "msfconsole", then get "msf>", I run this:

msf> db_connect msf3:[email protected]/msf3
msf> db_stats
[*] postgresql selected, no connection

I don't know what happens, so I run msfconsole again, and I get this:

[-] Failed to connect to the database: FATAL:  password authentication failed for user "msf3"

I can use postgres to create new user and database, and then I use db_connect to connect. But every time, I must run db_connect again. So I think metasploit use msf3 as default as user and database. I want to connect to msf3. What should I do?

Answer

Sputnik picture Sputnik · Oct 16, 2016

Had the same error on Kali Rolling 2016.2 Open a terminal and type:

msfdb delete
msfdb init
msfconsole

In short, you need to recreate the db msf uses, by msf.