Metasploit-framework: Ubuntu installation

Created on 4 Jan 2018  路  3Comments  路  Source: rapid7/metasploit-framework

Steps to reproduce

How'd you do it?

I am trying to install Metasploit framework on my Ubuntu machine.

On Wiki is the following installation information:

Metaploit framework installers are built nightly for those wanting to track the bleeding edge, or those who would like a simplified Metasploit framework setup experience. These packages are built for OS X (64-bit), Windows (32-bit) and various Linux distributions (i386, amd64, armhf and arm64 Deb-based systems, x86_64 RPM-based systems), including a complete bundled Ruby environment, PostgreSQL database, and anything else needed to run Metasploit. The installers integrate with your system package manager, making them easy to install and update.

Is this true? PostreSQL doesn't seem to be installed (log above) I can't either launch ruby command itself (it's not installed).

So after a

curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall && \
  chmod 755 msfinstall && \
  ./msfinstall

I launched msfconsole it asked to create a new database, I choosed yes, but MSF does not starts properly:

$ msfconsole
LOG:  skipping missing configuration file "/home/whoami/.msf4/db/postgresql.auto.conf"
pg_ctl: directory "/home/whoami/.msf4/db" is not a database cluster directory
Found a database at /home/whoami/.msf4/db, checking to see if it is started
Starting database at /home/whoami/.msf4/db...failed
/opt/metasploit-framework/embedded/framework/msfdb:68:in `readlines': No such file or directory @ rb_sysopen - /home/whoami/.msf4/db/log (Errno::ENOENT)
    from /opt/metasploit-framework/embedded/framework/msfdb:68:in `tail'
    from /opt/metasploit-framework/embedded/framework/msfdb:119:in `start_db'
    from /opt/metasploit-framework/embedded/framework/msfdb:190:in `init_db'
    from /opt/metasploit-framework/embedded/framework/msfdb:310:in `<main>'
[-] 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 5433?

OS

What OS are you running Metasploit on?

Ubuntu 16.04.3 LTS \n \l

Most helpful comment

Hey @adrianmihalko, thank you for the clarification and pastebin, helpful stuff. I notice there are installation errors around the setting of the locale:

.
.
.
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = "en_US:en",
    LC_ALL = (unset),
    LC_CTYPE = "UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
.
.
.

I believe these could result in the DB not properly setting up, leading to the errors you see when attempting to run msfconsole. This article describes the issue, with a link to another article on how you might fix it in your Ubuntu installation.

FWIW, I installed a fresh Ubuntu 16.04.03 LTS (64-bit) VM instance and ran the same install commands you used, it worked fine for me (see below). I'm closing this issue since it appears to be a system-specific issue, but feel free to join us on IRC or visit the Rapid7 Knowledge Base for support.

pbarry@ubuntu-16:~$ curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall && \
>   chmod 755 msfinstall && \
>   ./msfinstall
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5394  100  5394    0     0   5043      0  0:00:01  0:00:01 --:--:--  5041
Switching to root user to update the package
[sudo] password for pbarry: 
Adding metasploit-framework to your repository list..OK
Updating package cache..OK
Checking for and installing update..
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  metasploit-framework
0 upgraded, 1 newly installed, 0 to remove and 93 not upgraded.
Need to get 185 MB of archives.
After this operation, 429 MB of additional disk space will be used.
Get:1 http://downloads.metasploit.com/data/releases/metasploit-framework/apt lucid/main amd64 metasploit-framework amd64 4.16.29+20180104114028~1rapid7-1 [185 MB]
Fetched 185 MB in 1min 48s (1,697 kB/s)                                                                                                                                               
Selecting previously unselected package metasploit-framework.
(Reading database ... 59734 files and directories currently installed.)
Preparing to unpack .../metasploit-framework_4.16.29+20180104114028~1rapid7-1_amd64.deb ...
Unpacking metasploit-framework (4.16.29+20180104114028~1rapid7-1) ...
Setting up metasploit-framework (4.16.29+20180104114028~1rapid7-1) ...
update-alternatives: using /opt/metasploit-framework/bin/msfbinscan to provide /usr/bin/msfbinscan (msfbinscan) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/msfconsole to provide /usr/bin/msfconsole (msfconsole) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/msfd to provide /usr/bin/msfd (msfd) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/msfdb to provide /usr/bin/msfdb (msfdb) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/msfelfscan to provide /usr/bin/msfelfscan (msfelfscan) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/msfmachscan to provide /usr/bin/msfmachscan (msfmachscan) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/msfpescan to provide /usr/bin/msfpescan (msfpescan) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/msfrop to provide /usr/bin/msfrop (msfrop) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/msfrpc to provide /usr/bin/msfrpc (msfrpc) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/msfrpcd to provide /usr/bin/msfrpcd (msfrpcd) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/msfupdate to provide /usr/bin/msfupdate (msfupdate) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/msfvenom to provide /usr/bin/msfvenom (msfvenom) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/metasploit-aggregator to provide /usr/bin/metasploit-aggregator (metasploit-aggregator) in auto mode
Run msfconsole to get started
W: --force-yes is deprecated, use one of the options starting with --allow instead.
pbarry@ubuntu-16:~$ 
pbarry@ubuntu-16:~$ 
pbarry@ubuntu-16:~$ msfconsole

 ** Welcome to Metasploit Framework Initial Setup **
    Please answer a few questions to get started.


Would you like to use and setup a new database (recommended)? yes
Creating database at /home/pbarry/.msf4/db
Starting database at /home/pbarry/.msf4/db...success
Creating database users
Creating initial database schema

 ** Metasploit Framework Initial Setup Complete **



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

                                       ^
####      __     __     __          #######         __     __     __        ####
####    /    \ /    \ /    \      ###########     /    \ /    \ /    \      ####
################################################################################
################################################################################
# WAVE 4 ######## SCORE 31337 ################################## HIGH FFFFFFFF #
################################################################################
                                                           https://metasploit.com


       =[ metasploit v4.16.29-dev-                        ]
+ -- --=[ 1716 exploits - 984 auxiliary - 300 post        ]
+ -- --=[ 507 payloads - 40 encoders - 10 nops            ]
+ -- --=[ Free Metasploit Pro trial: http://r-7.co/trymsp ]

msf > db_status
[*] postgresql connected to msf
msf > exit
pbarry@ubuntu-16:~$ uname -a
Linux ubuntu-16 4.4.0-87-generic #110-Ubuntu SMP Tue Jul 18 12:55:35 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
pbarry@ubuntu-16:~$ cat /etc/issue
Ubuntu 16.04.3 LTS \n \l

All 3 comments

Is your username on that system really and truly named 'whoami'? It appears the installation believes that's the case, but if it's not (i.e. if you do NOT really have a user called 'whoami'), perhaps one of the install scripts' attempt to execute the command whoami is, instead, setting the username as the string "whoami" during installation. Do you happen to have the output from when you ran the installation command (msfinstall)?

No, I just changed here.

Fortunately I have the installation log (I leaved my name at this time):

https://pastebin.com/Mr2c4wT2

Hey @adrianmihalko, thank you for the clarification and pastebin, helpful stuff. I notice there are installation errors around the setting of the locale:

.
.
.
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = "en_US:en",
    LC_ALL = (unset),
    LC_CTYPE = "UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
.
.
.

I believe these could result in the DB not properly setting up, leading to the errors you see when attempting to run msfconsole. This article describes the issue, with a link to another article on how you might fix it in your Ubuntu installation.

FWIW, I installed a fresh Ubuntu 16.04.03 LTS (64-bit) VM instance and ran the same install commands you used, it worked fine for me (see below). I'm closing this issue since it appears to be a system-specific issue, but feel free to join us on IRC or visit the Rapid7 Knowledge Base for support.

pbarry@ubuntu-16:~$ curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall && \
>   chmod 755 msfinstall && \
>   ./msfinstall
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5394  100  5394    0     0   5043      0  0:00:01  0:00:01 --:--:--  5041
Switching to root user to update the package
[sudo] password for pbarry: 
Adding metasploit-framework to your repository list..OK
Updating package cache..OK
Checking for and installing update..
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  metasploit-framework
0 upgraded, 1 newly installed, 0 to remove and 93 not upgraded.
Need to get 185 MB of archives.
After this operation, 429 MB of additional disk space will be used.
Get:1 http://downloads.metasploit.com/data/releases/metasploit-framework/apt lucid/main amd64 metasploit-framework amd64 4.16.29+20180104114028~1rapid7-1 [185 MB]
Fetched 185 MB in 1min 48s (1,697 kB/s)                                                                                                                                               
Selecting previously unselected package metasploit-framework.
(Reading database ... 59734 files and directories currently installed.)
Preparing to unpack .../metasploit-framework_4.16.29+20180104114028~1rapid7-1_amd64.deb ...
Unpacking metasploit-framework (4.16.29+20180104114028~1rapid7-1) ...
Setting up metasploit-framework (4.16.29+20180104114028~1rapid7-1) ...
update-alternatives: using /opt/metasploit-framework/bin/msfbinscan to provide /usr/bin/msfbinscan (msfbinscan) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/msfconsole to provide /usr/bin/msfconsole (msfconsole) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/msfd to provide /usr/bin/msfd (msfd) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/msfdb to provide /usr/bin/msfdb (msfdb) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/msfelfscan to provide /usr/bin/msfelfscan (msfelfscan) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/msfmachscan to provide /usr/bin/msfmachscan (msfmachscan) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/msfpescan to provide /usr/bin/msfpescan (msfpescan) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/msfrop to provide /usr/bin/msfrop (msfrop) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/msfrpc to provide /usr/bin/msfrpc (msfrpc) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/msfrpcd to provide /usr/bin/msfrpcd (msfrpcd) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/msfupdate to provide /usr/bin/msfupdate (msfupdate) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/msfvenom to provide /usr/bin/msfvenom (msfvenom) in auto mode
update-alternatives: using /opt/metasploit-framework/bin/metasploit-aggregator to provide /usr/bin/metasploit-aggregator (metasploit-aggregator) in auto mode
Run msfconsole to get started
W: --force-yes is deprecated, use one of the options starting with --allow instead.
pbarry@ubuntu-16:~$ 
pbarry@ubuntu-16:~$ 
pbarry@ubuntu-16:~$ msfconsole

 ** Welcome to Metasploit Framework Initial Setup **
    Please answer a few questions to get started.


Would you like to use and setup a new database (recommended)? yes
Creating database at /home/pbarry/.msf4/db
Starting database at /home/pbarry/.msf4/db...success
Creating database users
Creating initial database schema

 ** Metasploit Framework Initial Setup Complete **



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

                                       ^
####      __     __     __          #######         __     __     __        ####
####    /    \ /    \ /    \      ###########     /    \ /    \ /    \      ####
################################################################################
################################################################################
# WAVE 4 ######## SCORE 31337 ################################## HIGH FFFFFFFF #
################################################################################
                                                           https://metasploit.com


       =[ metasploit v4.16.29-dev-                        ]
+ -- --=[ 1716 exploits - 984 auxiliary - 300 post        ]
+ -- --=[ 507 payloads - 40 encoders - 10 nops            ]
+ -- --=[ Free Metasploit Pro trial: http://r-7.co/trymsp ]

msf > db_status
[*] postgresql connected to msf
msf > exit
pbarry@ubuntu-16:~$ uname -a
Linux ubuntu-16 4.4.0-87-generic #110-Ubuntu SMP Tue Jul 18 12:55:35 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
pbarry@ubuntu-16:~$ cat /etc/issue
Ubuntu 16.04.3 LTS \n \l
Was this page helpful?
0 / 5 - 0 ratings

Related issues

0x27 picture 0x27  路  3Comments

mdisec picture mdisec  路  3Comments

wvu-r7 picture wvu-r7  路  3Comments

bugshere picture bugshere  路  3Comments

Funeoz picture Funeoz  路  3Comments