Results 1 to 10 of 10

Thread: metasploit db_driver issues (or have i totally lost it?)

Hybrid View

  1. #1
    Just burned his ISO
    Join Date
    Jan 2010
    Posts
    6

    Default metasploit db_driver issues (or have i totally lost it?)

    Hi people,

    I'm having issues getting metasploit to work and the fact that noone else has written about this makes me think I'm about to make a fool of myself(!) but .. if anyone could shed some light then it would be appreciated .. if I'm being stupendously dense then flames are ok too

    tnx
    K

    Having read the threads http://www.backtrack-linux.org/forum...t-drivers.html, I expected that I would already be connected to the database but this was not the case:

    Code:
    msf > db_nmap 192.168.1.1-254 -n -P0
    [-] Database not connected
    msf >
    msf > db_create test
    [-] No database driver has been specified

    Ok, so then I went to the db_driver:

    Code:
    msf > db_driver[*] No Active Driver[*]        Available:
    [*]     DB Support: Enable the mysql driver with the following command:[*]                 $ gem install mysql[*]     This gem requires mysqlclient headers, which can be installed on Ubuntu with:[*]                 $ sudo apt-get install libmysqlclient-dev
    [*]     DB Support: Enable the postgresql driver with the following command:[*]                   * This requires libpq-dev and a build environment[*]                 $ gem install postgres[*]                 $ gem install pg # is an alternative that may work
    Fair enough. So then I went to do the postgres install ..

    Code:
    msf > apt-get install libpq-dev[*] exec: apt-get install libpq-dev
    <snip>

    Code:
    msf > gem install postgres[*] exec: gem install postgres
    
    Building native extensions.  This could take a while...
    ERROR:  Error installing postgres:
            ERROR: Failed to build gem native extension.
    
    /usr/bin/ruby1.9.2 extconf.rb
    extconf.rb:4:in `<main>': uninitialized constant Object::PLATFORM (NameError)
    
    
    Gem files will remain installed in /var/lib/gems/1.9.2/gems/postgres-0.7.9.2008.01.28 for inspection.
    Results logged to /var/lib/gems/1.9.2/gems/postgres-0.7.9.2008.01.28/ext/gem_make.out
    msf >
    Ok, so I try the pg:

    Code:
    msf >  gem install pg[*] exec:  gem install pg
    
    Building native extensions.  This could take a while...
    Successfully installed pg-0.11.0
    1 gem installed
    Installing ri documentation for pg-0.11.0...
    Installing RDoc documentation for pg-0.11.0...
    But:

    Code:
    msf > db_driver[*] No Active Driver
    Things seem ok, process and listening port-wise:

    Code:
    msf > ps aux | grep postg[*] exec: ps aux | grep postg
    
    postgres  1049  0.0  0.1  40288  3444 ?        S    17:20   0:00 /opt/framework3/postgresql/bin/postgres -D /opt/framework3/postgresql/data
    postgres  1090  0.0  0.0  40288  1016 ?        Ss   17:20   0:00 postgres: writer process
    postgres  1091  0.0  0.0  40288   784 ?        Ss   17:20   0:00 postgres: wal writer process
    postgres  1092  0.0  0.0  40420  1200 ?        Ss   17:20   0:00 postgres: autovacuum launcher process
    postgres  1093  0.0  0.0   8592   984 ?        Ss   17:20   0:00 postgres: stats collector process
    root      7962  0.0  0.0   4256  1172 pts/0    S+   17:46   0:00 sh -c ps aux | grep postg
    root      7965  0.0  0.0   3372   748 pts/0    S+   17:46   0:00 grep postg
    
    msf > netstat -pant | grep -i list[*] exec: netstat -pant | grep -i list
    
    tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1178/sshd
    tcp        0      0 127.0.0.1:7175          0.0.0.0:*               LISTEN      1049/postgres
    tcp        0      0 0.0.0.0:35465           0.0.0.0:*               LISTEN      654/rpc.statd
    tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      580/portmap
    tcp6       0      0 :::22                   :::*                    LISTEN      1178/sshd
    tcp6       0      0 ::1:7175                :::*                    LISTEN      1049/postgres

  2. #2
    Senior Member ghostdog67's Avatar
    Join Date
    Sep 2008
    Posts
    180

    Default Re: metasploit db_driver issues (or have i totally lost it?)

    Hi
    I had the same problem, looks like the 3.8 version got some bugs, i fixed it this way: deleted metasploit totally, then downloaded 3.7 minimal version, downloaded postgresql and libpgsql-ruby.
    then ,

    root@bt:~$ postgres

    postgres@bt:~$ createuser " your user" -P
    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

    THEN

    postgres@bt:~$ createdb --owner=bt metasploit3
    postgres@bt:$ exit

    THEN

    msf > db_driver postgresql
    msf > db_connect bt:[password]@127.0.0.1:5432/metasploit3
    msf > db_workspace -a MyProject

    THEN TRY AUTOPWN

    msf > db_nmap 192.168.1.1
    msf > db_autopwn -p -e -q

    root@bt:~$ cat > ~/.msf3/msfconsole.rc
    db_driver postgresql
    db_connect bt:[password]@127.0.0.1:5432/metasploit3
    db_workspace -a MyProject
    ^D

    *** it toke me long time to figure this out, but it works and updated itself to 3.8 ! hope it works for you as well, the 3.8 full version dosnt seem to work for me.

    Hope this helps
    GD

  3. #3
    Just burned his ISO
    Join Date
    Jan 2010
    Posts
    6

    Default Re: metasploit db_driver issues (or have i totally lost it?)

    Nice one GD, thanks for the reply, that'll be the way forward then

    I considered doing this but thought there must be something wrong with my install as otherwise everyone would have had the same problem and there would have been multiple forum postings on the subject ..

    I'm also pretty sure that I got exactly the same issue before I updated it to 3.8 too.

  4. #4
    Senior Member fnord0's Avatar
    Join Date
    Jul 2008
    Posts
    144

    Default Re: metasploit db_driver issues (or have i totally lost it?)

    no need to uninstall/reinstall metasploit! if you want to go with postgres, here's a howto for http://www.backtrack-linux.org/forum...ostgresql.html

    -fnord0
    Last edited by fnord0; 05-13-2011 at 09:39 AM.
    'see the fnords!'

  5. #5
    Just burned his ISO
    Join Date
    May 2011
    Posts
    1

    Default Re: metasploit db_driver issues (or have i totally lost it?)

    thenkyou

  6. #6
    Just burned his ISO
    Join Date
    Jan 2010
    Posts
    6

    Default Re: metasploit db_driver issues (or have i totally lost it?)

    Hi fnord0,

    thanks for the reply. I read that thread as well but it didn't seem relevant to me as the instructions in the thread deal with installing the database server and connecting to it - there is already a postgres server running, the problem is that there is no db_driver available and the instructions in that thread do not address this.

    tnx
    K

  7. #7
    Just burned his ISO
    Join Date
    May 2011
    Posts
    3

    Default Re: metasploit db_driver issues (or have i totally lost it?)

    Hey guys

    I've found out that the problem is related to the installed ruby version. the start script of msfconsole uses /usr/bin/env ruby as Parser. But metasploit seems to have an own version of ruby which you can use by changing msfconsole:
    Code:
    #!/usr/bin/env ruby
    to
    Code:
    #!../ruby/bin/ruby
    afterwards the db_drivers appear correctly and you'll be able to connect.

    But now the next problem seems that the included nmap version in /opt/framework3/bin/nmap has some compiling errors because it gives me:
    Code:
    msf > db_nmap example.com[*] Nmap: Starting Nmap 5.51SVN ( http://nmap.org ) at 2011-05-13 16:40 CEST[*] Nmap: 'nmap: relocation error: /lib/libnss_mdns4_minimal.so.2: symbol strlen, version GLIBC_2.0 not defined in file libc.so.6 with link time reference'
    I did test it with the 32 and 64 Bit KDE version of bt5 on virtualbox

    Who ever has made the KDE versions of backtrack5 definatly didn't test it with virutalbox 4.0.6

  8. #8
    Just burned his ISO
    Join Date
    May 2011
    Posts
    4

    Default Re: metasploit db_driver issues (or have i totally lost it?)

    Quote Originally Posted by Nexxor View Post
    Hey guys

    I've found out that the problem is related to the installed ruby version. the start script of msfconsole uses /usr/bin/env ruby as Parser. But metasploit seems to have an own version of ruby which you can use by changing msfconsole:
    Code:
    #!/usr/bin/env ruby
    to
    Code:
    #!../ruby/bin/ruby
    afterwards the db_drivers appear correctly and you'll be able to connect.
    Change of ruby version solved db_driver problem, but I got new issues. Meterpreter payloads does not work with changed ruby version. It seems mfs 3.8 is buggy.

  9. #9
    Just burned his ISO
    Join Date
    Jan 2010
    Posts
    6

    Default Re: metasploit db_driver issues (or have i totally lost it?)

    I created a workaround script, its not pretty but it works, I've stuck comments in too, hope it helps someone!

    This is pieced together from all the other bits and pieces I've read so credit to those.

    If I've missed something / typo let me know. Please reboot when done just to make sure your database server restarts properly.

    You will need the following packages installed before running the script:

    apt-get install postgresql-client libpq-dev

    Copy the script into a file e.g script.sh, chmod +x script.sh, ./script.sh

    Code:
    #!/bin/sh
    
    ## Kill database process
    echo "Killing database process .."
    kill $(pgrep postgres)  > /dev/null 2>&1
    
    ## replace the md5 auth with trust for local ipv4 connections
    echo "Allowing all local IPV4 connections .."
    cp /opt/framework3/postgresql/data/pg_hba.conf /opt/framework3/postgresql/data/pg_hba.conf.bak
    cat /opt/framework3/postgresql/data/pg_hba.conf | sed -e 's/host    all         all         127.0.0.1\/32          md5/host    all         all         127.0.0.1\/32          trust/' > /opt/framework3/postgresql/data/tmp.conf
    mv /opt/framework3/postgresql/data/tmp.conf /opt/framework3/postgresql/data/pg_hba.conf
    
    ## restart postgres server (only necessary during this process, on reboot it will start automatically)
    echo "Restarting postgres server (only necessary during this process, on reboot it will start automatically) .."
    su postgres -c "/opt/framework3/postgresql/bin/postgres -D /opt/framework3/postgresql/data -p 7175 &" 
    # wait for server to start
    sleep 5
    
    ## Now we can access via psql we can change user for database
    echo "Changing postgres user postgres's password to 'postgres_password' .."
    su postgres -c "psql -h 127.0.0.1 -p 7175 -c \"ALTER USER postgres WITH PASSWORD 'postgres_password'\";" > /dev/null 2>&1
    
    ## Create a database for usage with msf
    echo "Creating database 'msf_db' for use with metasploit .."
    su postgres -c "psql -h 127.0.0.1 -p 7175 -c \"CREATE DATABASE msf_db\";"  > /dev/null 2>&1
    
    ## change back to md5 auth 
    echo "Changing back to md5 auth .."
    cat /opt/framework3/postgresql/data/pg_hba.conf | sed -e 's/host    all         all         127.0.0.1\/32          trust/host    all         all         127.0.0.1\/32          md5/' > /opt/framework3/postgresql/data/tmp.conf
    mv /opt/framework3/postgresql/data/tmp.conf /opt/framework3/postgresql/data/pg_hba.conf
    
    ###############################
    
    ## msfconsole
    
    ## change ruby version
    echo "##################################"
    echo "Changing Ruby version - please choose the '0' option .."
    echo "##################################"
    update-alternatives --config ruby
    
    ## install postgres gem
    gem install postgres
    
    # go into msfconsole and choose the db_driver
    echo "Updating msf .."
    /opt/framework3/msf3/msfupdate
    
    echo
    echo "#######################################################################################################"
    echo "starting msfconsole .."
    echo "now enter 'db_driver postgresql' and then 'db_connect postgres:postgres_password@127.0.0.1:7175/msf_db'"
    echo "#######################################################################################################"
    
    /opt/framework3/msf3/msfconsole
    Last edited by krrunch; 06-30-2011 at 01:24 PM.

  10. #10
    Junior Member 5cardcharlie's Avatar
    Join Date
    Sep 2010
    Location
    Ohio
    Posts
    45

    Default Re: metasploit db_driver issues (or have i totally lost it?)

    Nexxor, I was able to get everything working by replacing the version of nmap you mentioned with the one in /usr/local/sbin (I think that's where it was anyway. Not on bt right now).

Similar Threads

  1. Replies: 1
    Last Post: 05-07-2011, 01:35 PM
  2. Lost in Metasploit 3.3
    By Israel213 in forum Beginners Forum
    Replies: 1
    Last Post: 05-06-2010, 07:39 PM
  3. metasploit , db_driver: command not found
    By Justs in forum Beginners Forum
    Replies: 2
    Last Post: 03-30-2010, 03:44 AM
  4. Metasploit issues!
    By imported_Joes100 in forum OLD Pentesting
    Replies: 9
    Last Post: 10-21-2009, 11:33 PM
  5. Weird update issues on metasploit
    By fastboi in forum OLD Newbie Area
    Replies: 5
    Last Post: 11-17-2008, 10:54 AM

Posting Permissions

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