PDA

View Full Version : metasploit and postgresql help



Lordx19
2013-05-09, 03:00
I can't get metasploit to connect to the DB. I run all the things that previous threads have said to do, such as start postgresql and metasploit and adding it to the startup, but when I run metasploit I get password auth failed, password failed for user msf3, and to make that better, I run db_status and it says postgresql is not connected. I'm not understanding this. I've reinstalled both metasploit and postgresql several times. I'm running the gnome 64bit of kali. so my questions are basically, how do I remove the password failed for msf3 and how can I connect the postgresql to metasploit since obviously nothing is working

pentest09
2013-05-09, 10:08
check you database.yml file located in :

/opt/metasploit/apps/pro/ui/config/database.yml

it may be corrupted but i reckon that your using the wrong password as its created randomly.

it should look like this:
database.yml:

development:
adapter: postgresql
database: "msf3"
username: "msf3"
password: "zFhyomTtRt4P8ZF868KUyhmKvqQkvjE" (changed)
host: localhost
port: 5432
pool: 5
timeout: 5
################################################
below that you should have the same for production.

service postgresql start

service metasploit start

Kind Regards Dee

Lordx19
2013-05-09, 12:05
How do I use the correct password if Its randomly created?

pentest09
2013-05-09, 19:28
Hi ,

Its in the databae.yml file. open it up and copy the password in the file .

for location see above post....earlier


db_connect msf:zFhyomTtRt4P8ZF868KUyhmKvqQkvjE@127.0.0.1/msf3 for example...

Kind regards dee

Lordx19
2013-05-09, 20:03
Did that. When I do db_connect msf3:password and the rest of the command, it tells me password auth fail. I'm copying and pasting the exact password from the .yml file. I'm not understanding why this isn't working

pentest09
2013-05-09, 21:15
Have you installed postgres yourself at all?

I know its been stated before but again ....

service postgreql status
service metasploit status
msfconsole

cat /opt/metasploit/apps/pro/ui/config/database.yml

check your database name=msf3
check your user name=msf3
#########################################
development:
adapter: "postgresql"
database: "msf3"
username: "msf3"
password: "9hMj2yrZ62r3cynWh***************"
port: 5432
host: "localhost"
pool: 256
timeout: 5

production:
adapter: "postgresql"
database: "msf3"
username: "msf3"
password: "9hMj2yrZ62r3cynWh***************"
port: 5432
host: "localhost"
pool: 256
timeout: 5

=========================================

Make sure its just like that. I had errors before with armitage connecting due to this being changed somehow to below:

development:
adapter: "postgresql"
database: "msf3"
username: "msf3"
password: "9hMj2yrZ62r3cynWh***************"
port: 5432
host: "localhost"
pool: 256
timeout: 5


# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
#
# Note also, sqlite3 is totally unsupported by Metasploit now.
test:
adapter: sqlite3
database: "msf3"
pool: 5
timeout: 5


Also try using your ip instead of localhost or 127.0.0.1

db_connect msf:msf@192.168.0.5/msf3

Lordx19
2013-05-10, 01:21
Yup, I've checked all of this and I've reinstalled postgresql multiple times. Everything is correct

Lordx19
2013-05-10, 01:31
it says the "metasplot web server is not running ... failed!"

pentest09
2013-05-10, 02:08
it says the "metasplot web server is not running ... failed!"

service metasploit start

msfconsole............

Lordx19
2013-05-10, 03:08
I've done this................

I'm not an idiot.. I'm just saying, it says I have a password auth fail, yet it still loads msfconsole fine I guess; it takes like a minute or so to load it though after I stare at "password auth failed for user msf3" for a minute. I run service postgresql start and the same for metasploit. those run fine. Everything in the yml file is fine. It just makes no sense why I'm still getting this fatal error.

pentest09
2013-05-10, 10:08
I've done this................

I'm not an idiot.. I'm just saying, it says I have a password auth fail, yet it still loads msfconsole fine I guess; it takes like a minute or so to load it though after I stare at "password auth failed for user msf3" for a minute. I run service postgresql start and the same for metasploit. those run fine. Everything in the yml file is fine. It just makes no sense why I'm still getting this fatal error.

Behave fella im trying to help!

You say you have installed postgresql yourself multiple times!!! Could be your problem if you have installed it as its own instance and you havent issued a password and user.

Kali comes with postgresql in metaploit bundled.


BTW Metasploit and postgres work fine without the need to install separate instance of posgreqsl.

HOW ABT POST SOME COMMAND OUTPUT!!!


KindRegards
Dee

pentest09
2013-05-10, 10:39
I have just run the following after clean install:

METASPLOIT:

root@kali:~# service postgresql start
root@kali:~# service metasploit start (the first time this is run before msfconsole it creates the database)
Configuring Metasploit...
Creating metasploit database user 'msf3'...
Creating metasploit database 'msf3'...
insserv: warning: current start runlevel(s) (empty) of script `metasploit' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `metasploit' overrides LSB defaults (0 1 6).
[ ok ] Starting Metasploit rpc server: prosvc.
[ ok ] Starting Metasploit web server: thin

check services:[/I]

service postgresql status

service metasploit status

root@kali:~# msfconsole

AUTO-START SERVICES:
update-rc.d postgresql enable && update-rc.d metasploit enable

RANDOM PASSWORD FOR POSTGRES DATABASE:
kate /opt/metasploit/apps/pro/ui/config/database.yml (copy password)


db_connect msf3:zIYTU8yvQ7aUUTQbXJt5MsQZxo3tD0ew@127.0.0.1/msf3


Hope this helps,

Kind Regards Dee

Lordx19
2013-05-10, 17:54
None of that worked ): so i did a fresh quick kali install (had nothing to lose) and everything is working perfect now. Thanks for your help though!

pentest09
2013-05-10, 19:04
No Problem
I know how frustrating it can be....believe me!

Kind Regards DEE

please note: running the msf update before creating the database for the first time corrupted mine.

johnjohnsp1
2013-05-27, 12:49
Hello,

look inside the file located at /etc/postgresql/9.1/main/pg_hba.conf

and modify those lines where METHOD can be indicated as "password","trust","md5"

I changed mine from password to trust and were able to login at db with that parameters

# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication postgres trust
host replication postgres 127.0.0.1/32 trust
host replication postgres ::1/128 trust

Should work with that, or at least it worked for me

xerxes
2013-08-02, 07:47
Have you installed postgres yourself at all?

I know its been stated before but again ....

service postgreql status
service metasploit status
msfconsole

cat /opt/metasploit/apps/pro/ui/config/database.yml

check your database name=msf3
check your user name=msf3
#########################################
development:
adapter: "postgresql"
database: "msf3"
username: "msf3"
password: "9hMj2yrZ62r3cynWh***************"
port: 5432
host: "localhost"
pool: 256
timeout: 5

production:
adapter: "postgresql"
database: "msf3"
username: "msf3"
password: "9hMj2yrZ62r3cynWh***************"
port: 5432
host: "localhost"
pool: 256
timeout: 5

=========================================

Make sure its just like that. I had errors before with armitage connecting due to this being changed somehow to below:

development:
adapter: "postgresql"
database: "msf3"
username: "msf3"
password: "9hMj2yrZ62r3cynWh***************"
port: 5432
host: "localhost"
pool: 256
timeout: 5


# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
#
# Note also, sqlite3 is totally unsupported by Metasploit now.
test:
adapter: sqlite3
database: "msf3"
pool: 5
timeout: 5


Also try using your ip instead of localhost or 127.0.0.1

db_connect msf:msf@192.168.0.5/msf3


Thanks I had connect_db error and after reading this rhread it's solved now.By the way what kind of hashing is being used for this password ?

Best,

Ok I got my response:MD5

Thank you All.

FUSHIA
2014-02-05, 11:19
After searching solution, that's my solution to this problem :

Facts :
Launched kali properly and without upadtes
Starting service postgresql
No msf3 user in database ...
No msf3 database exist ...
Starting metasploit -> database.yml created and the password is visible in this file but didn't work when trying to connect (db_connect msf3:*****@127.0.0.1/msf3)
Normal ... no user and no database ....

So,

I created the user and the database :

sudo -i -u postgresql

then go to psql application by typing "psql"

and now see that you don't have user "msf3" and databse to connect by these commands (you can have these commands typing \?) :

\du

\l

Let's create the user :

CREATE USER msf3 WITH PASSWORD 'yourpassword';

and create the database

CREATE DATABASE yourdatabse OWNER msf3;

Now you have your database and your user for metasploit.

Then modify the database.yml file about the user and password to the future connection with metasploit ...

Hope this can help you !

Have a nice day !

GilGalad
2014-03-01, 09:42
After searching solution, that's my solution to this problem :

Facts :
Launched kali properly and without upadtes
Starting service postgresql
No msf3 user in database ...
No msf3 database exist ...
Starting metasploit -> database.yml created and the password is visible in this file but didn't work when trying to connect (db_connect msf3:*****@127.0.0.1/msf3)
Normal ... no user and no database ....

So,

I created the user and the database :

sudo -i -u postgresql

then go to psql application by typing "psql"

and now see that you don't have user "msf3" and databse to connect by these commands (you can have these commands typing \?) :

\du

\l

Let's create the user :

CREATE USER msf3 WITH PASSWORD 'yourpassword';

and create the database

CREATE DATABASE yourdatabse OWNER msf3;

Now you have your database and your user for metasploit.

Then modify the database.yml file about the user and password to the future connection with metasploit ...

Hope this can help you !

Have a nice day !

Hello,
Same issue for me, but even with the previous explanation it was not working. Maybe be because my fat fingers.
But If you edit the file postgresql.conf somewhere in /etc/postgresql/ you can change the port to 5432. The port was set to 5433. Strange because you can find a sample of the "conf" file somewhere in /usr/share with the port set to 5432.
Anyway, problem solved.
:)

ttguy
2014-03-04, 14:00
The best solution to this problem is to edit /etc/postgresql/9.1/main/postgresql.conf BEFORE you start the postgresql and metasploit services to change the port from 5433 to 5432
If when you start the postgresql service and see that it is listening on port 5433 (using "ss -ant") then you should stop the service and edit /etc/postgresql/9.1/main/postgresql.conf to change the port. Then start postgresql again and then start metasploit.
metasploit will configure itself on the first run and create the users and datbases it needs and populate database.yml with the passwords for the accounts it created.

But it would seem if you have already started metasploit while postgresql was listening on the wrong port it will fail to configure itself properly the second time after you have changed the listening point. My solution for this was to restore a virtual machine snapshot