Metasploit Service
You no longer can run 'service metasploit start', as in Kali 1, to start up the Metasploit service before using the framework. Trying to do so will result in the following error message.
Code:
root@kali:~# service metasploit start
Failed to start metasploit.service: Unit metasploit.service failed to load: No such file or directory.
root@kali:~# /etc/init.d/metasploit start
bash: /etc/init.d/metasploit: No such file or directory
root@kali:~#
This is because:
- The Metasploit package is no longer included - only metasploit-framework (which is just the command line version - rather than web UI)
- Kali now uses 'systemd' rather than 'init' for service control.
At the request of Rapid7, we have removed the Metasploit Community / Pro package from Kali Linux and now host the open-source metasploit-framework package only. For all of you who require Community or Pro, you will now need to download it from Rapid7 and then register and submit your personal details in order to get a license.
Source: kali.org/releases/kali-linux-20-released/
So how do I start up Metasploit for the first time?
You first need to run 'msfdb init' to setup the database.
The first time that you run msfconsole, Metasploit needs to build up an index. This will take between 2-5 minutes (on average) depending on the speed of your computer.
Code:
root@kali:~# systemctl start postgresql
root@kali:~# msfdb init
Creating database user 'msf'
Enter password for new role:
Enter it again:
Creating databases 'msf' and 'msf_test'
Creating configuration file in /usr/share/metasploit-framework/config/database.yml
Creating initial database schema
root@kali:~#
root@kali:~# msfconsole [*] The initial module cache will be built in the background, this can take 2-5 minutes...
...SNIP...
msf >
Note, the first two commands will not return any feedback to the terminal (systemd uses log files when giving feedback regarding service status).
Please see the following page on the Kali documentation site: docs.kali.org/general-use/starting-metasploit-framework-in-kali
So how do I start up Metasploit every time after?
Code:
root@kali:~# systemctl start postgresql
root@kali:~# msfdb start
root@kali:~# msfconsole
...SNIP...
msf >
How do I troubleshoot if something goes wrong?
First, make sure the database is started correctly:
Code:
root@kali:~# systemctl status postgresql
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; disabled)
Active: active (exited) since Sat 2015-08-29 12:29:51 BST; 4min 58s ago
Process: 1561 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 1561 (code=exited, status=0/SUCCESS)
root@kali:~#
If it doesn't start for whatever reason, check the log file(s): '/var/log/postgresql/*' as a starting point.
If you need to, you are able to wipe the database and re-create it again with 'msfdb reinit' (make sure Metasploit or any other service isn't using PostgreSQL).
Code:
root@kali:~# msfdb
Manage a metasploit framework database
msfdb init # initialize the database
msfdb reinit # delete and reinitialize the database
msfdb delete # delete database and stop using it
msfdb start # start the database
msfdb stop # stop the database
root@kali:~#
root@kali:~#
root@kali:~# msfdb reinit
Creating database user 'msf'
Enter password for new role:
Enter it again:
Creating databases 'msf' and 'msf_test'
Creating configuration file in /usr/share/metasploit-framework/config/database.yml
Creating initial database schema
root@kali:~#
You can find Metasploit's log files here: '/root/.msf4/logs/*'.