2

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:testtest@127.0.0.1/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?

xina1i
  • 748
  • 4
  • 9
  • 21
  • Have you tried starting the two services before changing the **databse.yml's** content? –  Sep 27 '15 at 16:46
  • try db_connect -y /opt/metasploit/apps/pro/ui/config/database.yml –  Mar 24 '16 at 22:09

6 Answers6

13

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.

Sputnik
  • 133
  • 1
  • 5
3
sudo /opt/metasploit/postgresql/scripts/ctl.sh start postgresql

this will start postgresql server with metasploit 4.14.8 .

Skatox
  • 4,237
  • 12
  • 42
  • 47
史毅力
  • 41
  • 1
  • Thank you! Just because after upgrading my os,the postgresql was also installed with default configuration somsf cannot connect to the new configuration. Just stop stand service and start with your command :) – tuantm Jul 08 '17 at 23:25
0

You should try running db_connect without any options.

It might also be that you need to grab the hashed value of the password and pass that as the password argument. That is the way you have to pass the password when using the msfrpc api module.

Draken
  • 3,134
  • 13
  • 34
  • 54
0

You can pass the file directly to db_connect like this :

db_connect -y /usr/share/metasploit-framework/config/database.yml
0

I know this is old thread, but I have found different solution that works fine for me. I checked postgresql.conf stored in /Users/*YourUserName/.msf4/db and default port was configured to 5433 bu Metasploit's web service was running on 5443 . So I edited config and now it works for me! Hopefully will help to someone.

JohnyMSF
  • 600
  • 4
  • 4
-1

try this its works for me:

 >  msfdb delete

    >  msfdb init

    >  msfconsole

on kali2017.2

samu22
  • 11
  • 3