Results 1 to 19 of 19

Thread: metasploit and postgresql help

  1. #1

    metasploit and postgresql help

    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

  2. #2
    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

  3. #3
    How do I use the correct password if Its randomly created?

  4. #4
    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:[email protected]/msf3 for example...

    Kind regards dee

  5. #5
    Did that. When I do db_connect msf3assword 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

  6. #6
    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:[email protected]/msf3

  7. #7
    Yup, I've checked all of this and I've reinstalled postgresql multiple times. Everything is correct

  8. #8
    it says the "metasplot web server is not running ... failed!"

  9. #9
    Quote Originally Posted by Lordx19 View Post
    it says the "metasplot web server is not running ... failed!"
    service metasploit start

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

  10. #10
    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.

  11. #11
    Quote Originally Posted by Lordx19 View Post
    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
    Last edited by pentest09; 2013-05-10 at 16:47.

  12. #12
    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

  13. #13
    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!

  14. #14
    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.

  15. #15
    Join Date
    2013-Mar
    Posts
    11
    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
    Last edited by johnjohnsp1; 2013-05-27 at 12:51. Reason: correction text

  16. #16
    Quote Originally Posted by pentest09 View Post
    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:[email protected]/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.
    Last edited by xerxes; 2013-08-02 at 07:55.

  17. #17
    Join Date
    2014-Feb
    Posts
    4
    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 !

  18. #18
    Join Date
    2014-Mar
    Posts
    1
    Quote Originally Posted by FUSHIA View Post
    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.

  19. #19
    Join Date
    2014-Mar
    Posts
    1
    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

Similar Threads

  1. Postgresql and Metasploit
    By Noob123 in forum NetHunter General Questions
    Replies: 9
    Last Post: 2015-08-23, 14:17
  2. Problems with metasploit and postgresql
    By brut3impact in forum TroubleShooting Archive
    Replies: 1
    Last Post: 2014-10-22, 11:33

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •