Metasploit Framework € A Beginner’s Guide For Penetration Testing, Exploit Development And Vulnerability Research

Metasploit Framework is a collection of exploits, shellcodes, fuzzing tools, payloads, encoders etc. Moreover, we can regard it as a collection of exploitation tools bundled into a single framework. It is available in all major Linux, Windows, OS X platforms. Its main objective is to test your/company’s/organization’s defenses by attacking them. Something like “Offense for Defense”.

This is actually where a penetration tester/Security Analyst begins attacking the victim after a huge recon. Metasploit has a wide range of tools & utilities to perform attacks against all operating systems including Android & iOS.

Metasploit Framework History :

Metasploit was first written in Perl by H.D.Moore. Initially, it was intended to be a maintainable framework which automates the process of exploiting rather than manually verifying it. The first version was released in 2003 which consisted of 8-11(exact number not sure) no of exploits.

Then more contributors collaborated & contributed to it a major release was 2.7 in 2006 which consisted of 150+ exploits. Then a major change was in version 3. It was reprogrammed in Ruby & was made cross-platform.

Also, the coolest thing is that new exploits & modules can be downloaded and added with ease by the release of this version. In 2009 Rapid7 acquired the project and still owns & maintains it. Still, now the basic architecture of Metasploit is not changed & basic versions are free.

Modules & Interfaces :

Metasploit Framework comes in a variety of interfaces

  • msfconsole – An interactive curses like a shell to do all tasks.
  • msfcli – Calls msf functions from the terminal/cmd itself. Doesn’t change the terminal.
  • msfgui – the Metasploit Framework Graphical User Interface.
  • Armitag – Another graphical tool written in Java to manage pentest performed with MSF.
  • Metasploit Community(or above) Web Interface – The web-based interface provided by rapid7 for easy pentesting.
  • CobaltStrike – Yet another GUI with some added features for post-exploitation, reporting etc.

Modules :

Exploit An exploit is a method by which the attacker takes advantage of a flaw within a system, service, application etc. The attacker generally uses this to do something with the particular system/service/application which he/she is attacking which the developer/implementer never intended to do. Kind of like misusing. This is the thing which an attacker uses to gain access to a system. Exploits are always accompanied by payloads

Source : “Metasploit- A pentester’s Guide”

Payload A payload is the piece of code which is run in the successfully exploited system. After an exploit works successfully, the framework injects the payload through the exploited vulnerability(flaw) and makes it run it within the target system. Thus an attacker gets inside the system or can get data from the compromised system using the payload.

Auxiliary Provides additional functionality like fuzzing, scanning, recon, dos attack etc. Auxiliary scans for banners or OSes fuzzes or does a DOS attack on the target. It doesn’t inject a payload like exploits. Means you won’t be able to gain access to a system using an auxiliary

Encoders Encoders are used to obfuscate modules to avoid detection by a protection mechanism such as an antivirus or a firewall. This is widely used when we create a backdoor. The backdoor is encoded (even multiple times) and sent to the victim.

Shellcode Shellcode is a set of instructions used as a payload when exploitation occurs. Shellcode is typically written in assembly language. In most cases, a command shell or a Meterpreter shell will be provided after the series of instructions have been performed by the target machine, hence the name.

Listener A listener listens for connections from a payload injected into a compromised system.

Post As the name suggests, these modules are used for post-exploitation. After a system is been compromised, we can dig deeper into the system or set it as a pivot to attack other systems using these modules

Nops Nop is No Operation popularly known for x86 processors. This is related to shellcode & machine language instructions. Briefly, it prevents a program(here the payload) from crashing while using jump statements in its shellcode.

Nops kind of loops the machine language instructions from the beginning if it lands into an invalid memory location after issuing a jump statement. Thus prevents the payload from crashing. This is somewhat of an advanced concept and you must understand shell coding in order to understand & use nops.

Okay, that’s enough of the blah blah…Let’s have some fun. For now let’s proceed with a tutorial. I will keep you posted on the basics & commands of msfconsole in upcoming posts.

Gather publicly available email-ids from search engines.

In this lab, we are gonna try to gather email ids from a specific domain. Here we use an auxiliary module through the msfconsole.

Step 1 :- Prerequisites :

Start & enable PostgreSQL service, check your IP, start Metasploit service & msfconsole

service postgresql start
update-rc.d postresql enable
ip a | grep inet
service metasploit start
Metasploit Prerequisites
Metasploit Command Shell

Step 2 :- Take Initial steps :

Check & Connect db to msfconsole.


The above command checks whether there is a database connection. I will explain this in detail in upcoming posts.

If the Metasploit service is started correctly, there will be a connection. Else, open a new terminal, start the service(command given above) and follow these :

  • db_connect msf3 : msf3@localhost/msf3

Step 3 :-

Let’s proceed. There is an auxiliary module which gathers all emailIDs found publically through a company’s website, social profiles etc. The module works by searching them in search engines like google, bing & yahoo.

In the msf prompt type :

search email

Metasploit search mail

Type in :

info auxiliary/gather/search_email_collector

This displays some information on the module.

Metasploit  auxiliary search

Step 4 :- Let’s Proceed to use the module

use auxiliary/gather/search_email_collector

Then there are certain options for this module, we can view this by using the following command

show options

We are gonna search for publicly available Gmail ids. so we set domain as Gmail, and save the output to gmails.txt.

  • set DOMAIN
  • set OUTFILE /root/gmails.txt
Metasploit Module

All set, we can run the auxiliary now but it’s always better to view all options set before running.

  • show options
  • run
Metasploit run

After successful completion, the result will be in the file we specified. Verify it by going to the home folder or just opening a new terminal and type :

cat gmails.txt | less <replace with the filename you gave>
Metasploit Email ID's

Reading the outfile

Press q to exit.


This is a very-very basic demo of the Metasploit Framework & made exclusively for beginners. Also, this module is useful for collecting email IDs of a company during penetration tests. You can set the domain option to your target domain and run.

#bookofnetwork #book_of_network #network_book #hacking #hack #metasploit #metasploit_tutorial #hackign_using_metasploit #step_by_step_hacking_tutorial_of_metasploit #email_id_hacking_using_metasploit #Metasploit_Framework_History #metasploit_modules_&_interfaces

(New page will open, for Comment)

Not yet commented...