MSF Postgres Problem on BT5

If you read this post then I bet you have the same problem with me. When I tried to run the msfconsole on my BT5 I have this buggy information.

[-] Failed to connect to the database: could not connect to server: Connection refused
        Is the server running on host “127.0.0.1” and accepting
        TCP/IP connections on port 7175?
 {“adapter”=>”postgresql”, “database”=>”msf3”, “username”=>”msf3”, “password”=>”7z878914”, “host”=>”127.0.0.1”, “port”=>7175, “pool”=>75, “timeout”=>5} [“/opt/framework3/msf3/lib/active_record/connection_adapters/postgresql_adapter.rb:968:in `initialize'”, “/opt/framework3/msf3/lib/active_record/connection_adapters/postgresql_adapter.rb:968:in `new'”, “/opt/framework3/msf3/lib/active_record/connection_adapters/postgresql_adapter.rb:968:in `connect'”, “/opt/framework3/msf3/lib/active_record/connection_adapters/postgresql_adapter.rb:217:in `initialize'”, “/opt/framework3/msf3/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `new'”, “/opt/framework3/msf3/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection'”, “/opt/framework3/msf3/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `new_connection'”, “/opt/framework3/msf3/lib/active_record/connection_adapters/abstract/connection_pool.rb:245:in `checkout_new_connection'”, “/opt/framework3/msf3/lib/active_record/connection_adapters/abstract/connection_pool.rb:188:in `block (2 levels) in checkout'”, “/opt/framework3/msf3/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `loop'”, “/opt/framework3/msf3/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `block in checkout'”, “/opt/framework3/ruby/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'”, “/opt/framework3/msf3/lib/active_record/connection_adapters/abstract/connection_pool.rb:183:in `checkout'”, “/opt/framework3/msf3/lib/active_record/connection_adapters/abstract/connection_pool.rb:98:in `connection'”, “/opt/framework3/msf3/lib/active_record/connection_adapters/abstract/connection_pool.rb:326:in `retrieve_connection'”, “/opt/framework3/msf3/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:in `retrieve_connection'”, “/opt/framework3/msf3/lib/active_record/connection_adapters/abstract/connection_specification.rb:115:in `connection'”, “/opt/framework3/msf3/lib/active_record/base.rb:1271:in `columns'”, “/opt/framework3/msf3/lib/active_record/base.rb:1284:in `column_names'”, “/opt/framework3/msf3/lib/active_record/base.rb:1297:in `column_methods_hash'”, “/opt/framework3/msf3/lib/active_record/base.rb:1986:in `block in all_attributes_exists?'”, “/opt/framework3/msf3/lib/active_record/base.rb:1986:in `each'”, “/opt/framework3/msf3/lib/active_record/base.rb:1986:in `all?'”, “/opt/framework3/msf3/lib/active_record/base.rb:1986:in `all_attributes_exists?'”, “/opt/framework3/msf3/lib/active_record/base.rb:1842:in `method_missing'”, “/opt/framework3/msf3/lib/msf/core/model/workspace.rb:69:in `default'”, “/opt/framework3/msf3/lib/msf/core/db.rb:189:in `default_workspace'”, “/opt/framework3/msf3/lib/msf/core/db_manager.rb:166:in `connect'”, “/opt/framework3/msf3/lib/msf/ui/console/driver.rb:186:in `initialize'”, “/opt/framework3/msf3/msfconsole:130:in `new'”, “/opt/framework3/msf3/msfconsole:130:in `

‘”]

Seems that the MSF could not connect to Postgres database server. I tried to install the Postgres server inside my BT5 and still have no luck. So I starting to search over the internet and found the solution for this problem. Here are the solution.

rm /opt/framework3/postgresql/data/postmaster.pid
rm /opt/framework3/postgresql/.s.PGSQL.7175
rm /opt/framework3/postgresql/.s.PGSQL.7175.lock

/etc/init.d/framework-postgres start 

Then, try to run the msfconsole again.

NOTICE:  CREATE TABLE will create implicit sequence “api_keys_id_seq” for serial column “api_keys.id”
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index “api_keys_pkey” for table “api_keys”
NOTICE:  CREATE TABLE will create implicit sequence “macros_id_seq” for serial column “macros.id”
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index “macros_pkey” for table “macros”
NOTICE:  CREATE TABLE will create implicit sequence “cred_files_id_seq” for serial column “cred_files.id”
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index “cred_files_pkey” for table “cred_files”
NOTICE:  CREATE TABLE will create implicit sequence “listeners_id_seq” for serial column “listeners.id”
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index “listeners_pkey” for table “listeners”
NOTICE:  CREATE TABLE will create implicit sequence “nexpose_consoles_id_seq” for serial column “nexpose_consoles.id”
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index “nexpose_consoles_pkey” for table “nexpose_consoles”
NOTICE:  CREATE TABLE will create implicit sequence “profiles_id_seq” for serial column “profiles.id”
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index “profiles_pkey” for table “profiles”

 ______________________________________________________________________________
|                                                                              |
|                   METASPLOIT CYBER MISSILE COMMAND V4                        |
|______________________________________________________________________________|
      \                                  /                      /
       \     .                          /                      /            x
        \                              /                      /
         \                            /          +           /
          \            +             /                      /
           *                        /                      /
                                   /      .               /
    X                             /                      /            X
                                 /                     ###
                                /                     # % #
                               /                       ###
                      .       /
     .                       /      .            *           .
                            /
                           *
                  +                       *

                                       ^
####      __     __     __          #######         __     __     __        ####
####    /    \ /    \ /    \      ###########     /    \ /    \ /    \      ####
################################################################################
################################################################################
# WAVE 4 ######## SCORE 31337 ################################## HIGH FFFFFFFF #
################################################################################

       =[ metasploit v4.0.1-dev [core:4.0 api:1.0]
+ — –=[ 732 exploits – 374 auxiliary – 82 post
+ — –=[ 227 payloads – 27 encoders – 8 nops
       =[ svn r13728 updated today (2011.09.13)

msf > quit

It will create the databases structure. Again run the msfconsole once again to make sure that it connect to the database correctly

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                                                      
%%     %%%         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                                                      
%%  %%  %%%%%%%%   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                                                      
%%  %  %%%%%%%%   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                                                      
%%  %%  %%%%%%   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                                                      
%%  %%%%%%%%%   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                                                      
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                                                      
%%%%%  %%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                                                      
%%%%    %%   %%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%  %%%%%                                                                                                      
%%%%  %%  %%  %      %%      %%    %%%%%      %    %%%%  %%   %%%%%%       %%                                                                                                      
%%%%  %%  %%  %  %%% %%%%  %%%%  %%  %%%%  %%%%  %% %%  %% %%% %%  %%%  %%%%%                                                                                                      
%%%%  %%%%%%  %%   %%%%%%   %%%%  %%%  %%%%  %%    %%  %%% %%% %%   %%  %%%%%                                                                                                      
%%%%%%%%%%%% %%%%     %%%%%    %%  %%   %    %%  %%%%  %%%%   %%%   %%%     %                                                                                                      
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%% %%%%%%%%%%%%%%                                                                                                      
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%          %%%%%%%%%%%%%%                                                                                                      
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                                                      
                                                                                                                                                                                   

       =[ metasploit v4.0.1-dev [core:4.0 api:1.0]
+ — –=[ 732 exploits – 374 auxiliary – 82 post
+ — –=[ 227 payloads – 27 encoders – 8 nops
       =[ svn r13728 updated today (2011.09.13)

msf >

Nice! Good luck to you.