rapid7 / metasploit-framework

Metasploit Framework
https://www.metasploit.com/
Other
34.16k stars 13.98k forks source link

Failed to initialize database #15526

Closed Fulgurance closed 3 years ago

Fulgurance commented 3 years ago

Steps to reproduce

How'd you do it?

  1. start msfconsole
  2. db_status
  3. msfdb init

Result

msf6 > db_status
[*] postgresql selected, no connection
msf6 > msfdb init
[*] exec: msfdb init

[?] Would you like to init the webservice? (Not Required) [no]: 
Clearing http web data service credentials in msfconsole
Failed to run msfconsole
Running the 'init' command for the database:
Existing database found, attempting to start it
Starting database at /home/zohran/.msf4/db...failed
msf6 >

Sorry I'm a beginner with metasploit, but I'm actually learning. I'm a Gentoo Linux user, and I installed metasploit yet, I configured postgreql and others files. But impossible to connect to the database. And I don't understand what is the problem.

I give you the information about my metasploit version and my system:

Emerge info:

~ ❯❯❯ emerge --info
Portage 3.0.20 (python 3.9.6-final-0, default/linux/amd64/17.1/hardened/selinux, gcc-11.2.0, glibc-2.33-r5, 5.13.7-gentoo x86_64)
=================================================================
System uname: Linux-5.13.7-gentoo-x86_64-Intel-R-_Core-TM-_i7-6700HQ_CPU_@_2.60GHz-with-glibc2.33
KiB Mem:    16275108 total,   8085404 free
KiB Swap:   20971516 total,  20968444 free
Timestamp of repository gentoo: Sat, 07 Aug 2021 06:30:01 +0000
Head commit of repository gentoo: 54e4d24434fb84b7dd931ed3ac61dfc5b5083023
sh bash 5.1_p8
ld GNU ld (Gentoo 2.35.2 p1) 2.35.2
app-shells/bash:          5.1_p8::gentoo
dev-java/java-config:     2.3.1::gentoo
dev-lang/perl:            5.34.0-r1::gentoo
dev-lang/python:          3.9.6_p1::gentoo, 3.10.0_rc1_p1::gentoo
dev-lang/rust:            1.54.0::gentoo
dev-util/cmake:           3.21.1::gentoo
sys-apps/baselayout:      2.7-r3::gentoo
sys-apps/openrc:          0.43.3::gentoo
sys-apps/sandbox:         2.24::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r5::gentoo, 2.71-r1::gentoo
sys-devel/automake:       1.16.4::gentoo
sys-devel/binutils:       2.35.2::gentoo, 2.36.1-r2::gentoo
sys-devel/gcc:            10.3.0-r2::gentoo, 11.2.0::gentoo
sys-devel/gcc-config:     2.4::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.3::gentoo
sys-kernel/linux-headers: 5.13::gentoo (virtual/os-headers)
sys-libs/glibc:           2.33-r5::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-verify-jobs: 1
    sync-rsync-extra-opts: 
    sync-rsync-verify-metamanifest: yes
    sync-rsync-verify-max-age: 24

pentoo
    location: /var/lib/layman/pentoo
    masters: gentoo
    priority: 50

steam-overlay
    location: /var/lib/layman/steam-overlay
    masters: gentoo
    priority: 50

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=skylake -O2 -pipe -mmovbe -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mpopcnt -mavx -mavx2 -maes -mpclmul -mfsgsbase -mrdrnd -mfma -mbmi -mbmi2 -mf16c -mrdseed -madx -mprefetchwt1 -mclflushopt -mxsavec -mxsaves"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=skylake -O2 -pipe -mmovbe -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mpopcnt -mavx -mavx2 -maes -mpclmul -mfsgsbase -mrdrnd -mfma -mbmi -mbmi2 -mf16c -mrdseed -madx -mprefetchwt1 -mclflushopt -mxsavec -mxsaves"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-march=skylake -O2 -pipe -mmovbe -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mpopcnt -mavx -mavx2 -maes -mpclmul -mfsgsbase -mrdrnd -mfma -mbmi -mbmi2 -mf16c -mrdseed -madx -mprefetchwt1 -mclflushopt -mxsavec -mxsaves"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs candy config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch preserve-libs protect-owned qa-unresolved-soname-deps sandbox selinux sesandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-march=skylake -O2 -pipe -mmovbe -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mpopcnt -mavx -mavx2 -maes -mpclmul -mfsgsbase -mrdrnd -mfma -mbmi -mbmi2 -mf16c -mrdseed -madx -mprefetchwt1 -mclflushopt -mxsavec -mxsaves"
GENTOO_MIRRORS="http://www.mirrorservice.org/sites/distfiles.gentoo.org/ http://mirrors.aliyun.com/gentoo/ http://mirrors.soeasyto.com/distfiles.gentoo.org/"
LANG="fr_FR.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j9"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="X aac acl acpi alsa amd64 audit bluetooth btrfs bzip2 caps compat crypt cryptsetup custom-cflags custom-optimization dbus device-mapper dri dri3 elogind experimental ffmpeg git glamor gstreamer hardened iconv ipv6 jpeg kde libglvnd libtirpc lvm mp3 mp4 mtp multilib ncurses networkmanager nls nptl ogg open_perms opengl openmp pam pcre peer_perms phonon pie plasma png policykit pulseaudio readline seccomp selinux split-usr ssl ssp svg tiff ubac udev udisks unconfined unicode uvm v4l vorbis vulkan wayland wifi wireless x264 xattr xtpax zlib" ABI_X86="32 64" ADA_TARGET="gnat_2018" ALSA_CARDS="hda-intel" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt sse sse2 sse3 ssse3 sse4_1 sse4_2" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="efi-64" INPUT_DEVICES="libinput synaptics" KERNEL="linux" L10N="fr fr-FR" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LLVM_TARGETS="NVPTX" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-3 php7-4" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_9" PYTHON_TARGETS="python3_9" RUBY_TARGETS="ruby26" USERLAND="GNU" VIDEO_CARDS="intel i965 nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RUSTFLAGS

Metasploit informations:


[I] net-analyzer/metasploit [1]
     Available versions:  
     (6.0)  (~)6.0.50^s
     (9999) (**)9999*l^s
       {development +java nexpose oracle +pcap test RUBY_TARGETS="ruby26"}
     Installed versions:  9999(9999)*l^s(18:22:05 02/08/2021)(development java pcap -nexpose -oracle -test RUBY_TARGETS="ruby26")
     Homepage:            http://www.metasploit.org/
     Description:         Advanced framework for developing, testing, and using vulnerability exploit code
[1] "pentoo" /var/lib/layman/pentoo
``` (It's from pentoo overlay, last 9999 version)
jmartin-tech commented 3 years ago

pentoo installation packaging is not maintained by the Metasploit Framework team. Due to this support for configuration issues should be directed at the maintainers of the packaging system you are using.

Database configuration varies by distro, however metasploit framework places database service configuration in ~/.msf4/database.yml. You can find an example configuration file here.

If postgresql services are available and the credentials are known you can also initiate the connection in the framework CLI . Here are the help results for this command:

msf6 > db_connect -h
   USAGE:
      * Postgres Data Service:
          db_connect <user:[pass]>@<host:[port]>/<database>
        Examples:
          db_connect user@metasploit3
          db_connect user:pass@192.168.0.2/metasploit3
          db_connect user:pass@192.168.0.2:1500/metasploit3
          db_connect -y [path/to/database.yml]

      * HTTP Data Service:
          db_connect [options] <http|https>://<host:[port]>
        Examples:
          db_connect http://localhost:8080
          db_connect http://my-super-msf-data.service.com
          db_connect -c ~/cert.pem -t 6a7a74c1a5003802c955ead1bbddd4ab1b05a7f2940b4732d34bfc555bc6e1c5d7611a497b29e8f0 https://localhost:8080
        NOTE: You must be connected to a Postgres data service in order to successfully connect to a HTTP data service.

      Persisting Connections:
        db_connect --name <name to save connection as> [options] <address>
      Examples:
        Saving:     db_connect --name LA-server http://123.123.123.45:1234
        Connecting: db_connect LA-server

   OPTIONS:
       -l,--list-services List the available data services that have been previously saved.
       -y,--yaml          Connect to the data service specified in the provided database.yml file.
       -n,--name          Name used to store the connection. Providing an existing name will overwrite the settings for that connection.
       -c,--cert          Certificate file matching the remote data server's certificate. Needed when using self-signed SSL cert.
       -t,--token         The API token used to authenticate to the remote data service.
       --skip-verify      Skip validating authenticity of server's certificate (NOT RECOMMENDED).
github-actions[bot] commented 3 years ago

Hi!

This issue has been left open with no activity for a while now.

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 30 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request.

github-actions[bot] commented 3 years ago

Hi again!

It’s been 60 days since anything happened on this issue, so we are going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error please feel free to reopen this issue or create a new one if you need anything else.

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request.