rapid7 / metasploit-framework

Metasploit Framework
https://www.metasploit.com/
Other
34.06k stars 13.95k forks source link

Failed to connect to database #10573

Closed Fulgurance closed 6 years ago

Fulgurance commented 6 years ago

Hello, i have installed metasploit on my laptop on Gentoo yesterday (sudo emerge --ask metasploit). I have enabled postgresql service, add new user and restart my computer. When i start msfconsole, i have this error:

zohran@msi-gs73vr-6rf ~ $ msfconsole
[-] Failed to connect to the database: ActiveRecord::ConnectionNotEstablished

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%     %%%         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  %%  %%%%%%%%   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  %  %%%%%%%%   %%%%%%%%%%% http://metasploit.com %%%%%%%%%%%%%%%%%%%%%%%%%
%%  %%  %%%%%%   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  %%%%%%%%%   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%  %%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%    %%   %%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%  %%%%%
%%%%  %%  %%  %      %%      %%    %%%%%      %    %%%%  %%   %%%%%%       %%
%%%%  %%  %%  %  %%% %%%%  %%%%  %%  %%%%  %%%%  %% %%  %% %%% %%  %%%  %%%%%
%%%%  %%%%%%  %%   %%%%%%   %%%%  %%%  %%%%  %%    %%  %%% %%% %%   %%  %%%%%
%%%%%%%%%%%% %%%%     %%%%%    %%  %%   %    %%  %%%%  %%%%   %%%   %%%     %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%% %%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%          %%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

       =[ metasploit v4.14.16-dev                         ]
+ -- --=[ 1645 exploits - 945 auxiliary - 290 post        ]
+ -- --=[ 486 payloads - 40 encoders - 9 nops             ]
+ -- --=[ Free Metasploit Pro trial: http://r-7.co/trymsp ]

msf >

Uses flags:

zohran@msi-gs73vr-6rf ~ $ equery uses metasploit
[ Legend : U - final flag setting for installation]
[        : I - package is installed with flag     ]
[ Colors : set, unset                             ]
 * Found these USE flags for net-analyzer/metasploit-4.14.16-r1:
 U I
 + + java                : Add support for Java
 + + nexpose             : Enable the plugin to integrate with nexpose
 + + openvas             : Enable the plugin to integrate net-analyzer/openvas
 - - oracle              : Enable restricted oracle modules which have additional deps
 + + pcap                : Enable libpcap for packet sniffing
 + + ruby_targets_ruby23 : Build with MRI Ruby 2.3.x

I'm new user of metasploit, because i would like to learn ethical hacking. And sorry if i don't speak english very well, i'm french

Fulgurance commented 6 years ago

No idea ?

wvu commented 6 years ago

You might want to talk to the package maintainer. We don't maintain the Gentoo package.

Looks like @ZeroChaos- maintains https://packages.gentoo.org/packages/net-analyzer/metasploit. :wave:

~You could use the nightly: https://github.com/rapid7/metasploit-framework/wiki/Nightly-Installers. I'm not sure how well it works on Gentoo.~ Brain fart - only .deb, .rpm, and .pkg (OS X).

A development environment is pretty simple to set up with rbenv if you want to do that.

Best bet is to ask the package maintainer for their recommendation on your distro.

XSecr3t commented 5 years ago

Hello

I have same troublem

I try setting msfdb from termux wiki but why fail?

Mr.XSecr3t@localhost:/data/data/com.termux/files/usr/var/lib $ cd $HOME/metasploit-framework/config Mr.XSecr3t@localhost:~/metasploit-framework/config $ ls application.rb database.yml.travis boot.rb database.yml.vagrant cucumber.yml environment.rb database.yml environments database.yml.example Mr.XSecr3t@localhost:~/metasploit-framework/config $ initdb $PREFIX/var/lib/postgresql The files belonging to this database system will be owned by user "u0_a210". This user must also own the server process.

The database cluster will be initialized with locale "C.UTF-8". The default text search configuration will be set to "english".

Data page checksums are disabled.

creating directory /data/data/com.termux/files/usr/var/lib/postgresql ... ok creating subdirectories ... ok selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting dynamic shared memory implementation ... sysv creating configuration files ... ok running bootstrap script ... ok performing post-bootstrap initialization ... ok syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

pg_ctl -D /data/data/com.termux/files/usr/var/lib/postgresql -l logfile start

Mr.XSecr3t@localhost:~/metasploit-framework/config $ pg_ctl -D /data/data/com.termux/files/usr/var/lib/postgresql -l logfile start waiting for server to start.... done server started Mr.XSecr3t@localhost:~/metasploit-framework/config $ msfconsole [-] Failed to connect to the database: FATAL: role "msf" does not exist

db_status [] postgresql selected, no connection msf > createuser msf [] exec: createuser msf

createuser: could not connect to database postgres: could not connect to server: Connection refused Is the server running locally and accepting connections on Unix domain socket "/data/data/com.termux/files/usr/tmp//.s.PGSQL.5432"? msf >

Is this something wrong? Thank you if you reply my problems :(

bcoles commented 5 years ago

Termux is not supported. #11023