Introduction To Metasploit

Author : Jyoti Agarwal

What is Metasploit?

Metasploit, an open-source pen-testing framework. It comes by default with kali linux, but you can also download it separately at the Metasploit website. The Metasploit Framework source code is available on GitHub.

We will discuss the following topics:

  1. Metasploit modules
  2. Core commands
  3. Starting shell

Metasploit modules



The Metasploit framework consists of different kinds of modules, these modules help the penetration tester in making there exploit modular. The important modules are:

Exploit This module is most exciting part of the framework for a new learner. This module holds all of the scripts which exploit popular vulnerabilities.
Payload As the name implies, it has payloads which runs when an exploit module successfully exploits a vulnerability.
Auxiliary module This module is mostly used in scanning, fuzzing, and whatnot. The major purpose of this module is to give a wide range of scripts that can help penetrate the target efficiently.
Post This module helps in looting and pivoting after the exploitation had taken place.
Encoder This module is basically scripts which tend to cloak the exploits and payloads in such a manner that they don’t get detected easily
Load As not every module is loaded by default, we can load different modules by this command.

Core commands

If you are a beginner, then you’ll have to do few things before you dive into it. To start, first thing you need to initialize database, which can be done by command- msfdb init



Before completely diving into it:

msfconsole -h : we can check some of the advanced options by using this command.


msfconsole : Now, we will start the Metasploit.


db_status : We can check that we’ve connected to the database using and what database we are using. As you can see, we’re using postgresql.


Help : We can now explore about all the commands using this command.


Some other important commands:

? /help To show above window which show all other commands information
Search Search module names and description
Use Interact with a module by name or search term/index
Indo Display information about one or more modules
Connect It is a netcat like feature present in Metasploit
Banner Display an awesome Metasploit banner
set Sets a context-specific variable
steg Sets a global variable to a value
get Gets the value of a context-specific variable
unset Unsets one or more context-specific variable
save Saves the active datastores
back Move back from the current context
handler Start a payload handler as job
jobs Display and manage jobs
vulns List all vulnerabilities in the database


Starting shells

Now, we will start the shell and understand how to search payloads and set them. Here, in your mind come a question how we will know what payload to set? So, answer to this question is simple we can find it easily by using a command db_nmap -sV -vv <ip> :

-sV Shows the versions of services of target machine
-vv Does the most verbose scanning
db_nmap Command by which we can use Nmap in Metasploit

Now we know the vulnerability we can search payload according to that by using use <payload name> . For example, use icecast




As we can see the path where the payload is present in our machine

set PAYLOAD <payload path> we can select the payload using this command.
set LHOST YOUR_IP we have to enter the <ip_address> of your machine, you can know it by typing ifconfig



set RHOST MACHINE_IP we have to enter the target machine <ip_address>
Run/exploit To run the exploit