Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: No connection to Database for metasploit after update - solution

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    1

    No connection to Database for metasploit after update - solution

    Hi there,

    Connection to the postgresql database doesn't work for metasploit after the last updates.
    You can check that from msfconsole by typing : db_status which shows : postgresql selected, no connection
    As a temporary solution (I hope ;-)), you can, from the msfconsole, type : db_connect -y /opt/metasploit/apps/pro/ui/config/database.yml

    This is automatically rebuild the cache and get you connected to the database.

    Hope that helps someone out there.

  2. #2
    Junior Member
    Join Date
    Mar 2013
    Posts
    9
    Hi Ulairi,

    Thanks for this temporary solution. it worked and helped me.

    Hope this issue will be fixed soon.

  3. #3
    Member
    Join Date
    Mar 2013
    Location
    Brazil
    Posts
    52
    Thx!

    I hope the solution comes this week.

  4. #4
    Senior Member
    Join Date
    Mar 2013
    Location
    milano
    Posts
    301

    Quote Originally Posted by Ulairi View Post
    Hi there,

    Connection to the postgresql database doesn't work for metasploit after the last updates.
    You can check that from msfconsole by typing : db_status which shows : postgresql selected, no connection
    As a temporary solution (I hope ;-)), you can, from the msfconsole, type : db_connect -y /opt/metasploit/apps/pro/ui/config/database.yml

    This is automatically rebuild the cache and get you connected to the database.

    Hope that helps someone out there.
    TNX! for fast-fix!!
    in one of my kali-machine(a week-ago i've created my-new-database && db_connect-to-it..&& worked) BUT your Fast-Fix ES MEJOR!!!!!
    http://www.imagestime.com/show.php/972630_1.PNG.html
    Last edited by zimmaro; 2014-09-08 at 09:11 AM.

  5. #5
    Junior Member
    Join Date
    Sep 2014
    Posts
    1
    I had this same error from a brand-new install (Kali 1.0.9 ISO image). I installed it a couple of times thinking that I must have done something to screw it up. When that didn't work, I did an "apt-get purge metasploit" followed by an "apt-get install metasploit", but that didn't fix it. I then tried Ulairi's solution, but got a "file not found" error message when I tried connecting. I then manually went to the folder "/opt/metasploit/apps/pro/ui/config/" and found that there weren't any YML files. However, there was the familiar looking file, "database.yml.example". I copied this file to "database.yml", and the db_connect worked and all seems well, now.

    I'm not sure where in the install/configuration steps this database is supposed to be created or renamed, but it's not happening.

  6. #6
    Junior Member
    Join Date
    Mar 2013
    Posts
    9
    Quote Originally Posted by phlucas View Post
    I had this same error from a brand-new install (Kali 1.0.9 ISO image). I installed it a couple of times thinking that I must have done something to screw it up. When that didn't work, I did an "apt-get purge metasploit" followed by an "apt-get install metasploit", but that didn't fix it. I then tried Ulairi's solution, but got a "file not found" error message when I tried connecting. I then manually went to the folder "/opt/metasploit/apps/pro/ui/config/" and found that there weren't any YML files. However, there was the familiar looking file, "database.yml.example". I copied this file to "database.yml", and the db_connect worked and all seems well, now.

    I'm not sure where in the install/configuration steps this database is supposed to be created or renamed, but it's not happening.
    it didn't work for me.
    Please could you post your database.yml?

    Thanks in advance,

  7. #7
    Senior Member
    Join Date
    Mar 2013
    Location
    milano
    Posts
    301
    Quote Originally Posted by oliv66 View Post
    it didn't work for me.
    Please could you post your database.yml?

    Thanks in advance,
    hi
    if this can be a possibily help && the "the-FIX" by Ulairi(tnx worked in my kali) not """worked""can try this:
    this is the OLD procedure USED in bt5-r3 to create a NEW database in postgresql to worked with metasploit...&& worked fine in ONE of my kali's machine

    root@bt:~# apt-get install postgresql ###optional or no need#######
    root@bt:~# sudo apt-get install libpgsql-ruby #####optional or no need#####
    root@bt:~# sudo su postgres
    sh-4.1$ createuser root -P
    could not change directory to "/root"
    Enter password for new role:
    Enter it again:
    Shall the new role be a superuser? (y/n) n
    Shall the new role be allowed to create databases? (y/n) n
    Shall the new role be allowed to create more new roles? (y/n) n
    sh-4.1$ createdb --owner=root metasploit
    could not change directory to "/root"
    exit
    sh-4.1$ exit
    exit
    root@bt:~# msfconsole
    msf > db_driver postgresql[*] Using database driver postgresql ####optional or no need##
    msf > db_connect root:toor@127.0.0.1:5432/metasploit
    db_workspace -a MyProject
    *] Added workspace: MyProject
    msf > db_nmap 192.168.1.165 -sS -O[*] Nmap: Starting Nmap .................................................. .................................................. ..........
    .................................................. .................................................. ......................
    ................................
    the work is perfect (FOR ME)
    bye
    Last edited by zimmaro; 2014-09-08 at 09:28 AM.

  8. #8
    This all came about with the release of 4.10. Rapid7 is aware of the 'aftermath' of it. For more information ~ https://community.rapid7.com/communi...ting-the-wheel
    In short, you need to tell Metasploit the database location if you upgrade. (If you do a fresh install, its been fixed).


    Method one - point to the database (you can copy or soft-link. I prefer to soft-link.).
    Code:
    ln -sf /opt/metasploit/apps/pro/ui/config/database.yml /root/.msf4/database.yml
    #cp /opt/metasploit/apps/pro/ui/config/database.yml /root/.msf4/database.yml
    OR

    Method two - use an alias when starting up msfconsole
    Code:
    file=/root/.bash_aliases; [ -e $file ]
    grep -q '^alias msfconsole' $file 2>/dev/null || echo -e '\n### Metasploit\nalias msfconsole="msfconsole db_connect -y /opt/metasploit/apps/pro/ui/config/database.yml"\n' >> $file
    source $file
    Last edited by g0tmi1k; 2014-09-16 at 10:17 AM.
    This is a Kali-Linux support forum - not general IT/infosec help.

    Useful Commands: OS, Networking, Hardware, Wi-Fi
    Troubleshooting: Kali-Linux Installation, Repository, Wi-Fi Cards (Official Docs)
    Hardware: Recommended 802.11 Wireless Cards

    Search: https://www.kali.org/search/
    Documentation: http://docs.kali.org/ (Offline PDF version)
    Bugs Reporting & Tool Requests: https://bugs.kali.org/
    Kali Tool List, Versions & Man Pages: http://tools.kali.org/

  9. #9
    Junior Member
    Join Date
    Mar 2013
    Posts
    9
    Thanks G0m1k. It worked for me by copying the database file.

  10. #10
    Junior Member
    Join Date
    Aug 2015
    Posts
    2
    "db_connect -y /etc/dradis/database.yml" it would be working for every kali 2.0 user.

Tags for this Thread

Posting Permissions

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