What Is Metasploit Framework and How To Use Metasploit
What Is Metasploit Framework and How To Use Metasploit
Hi everyone, this is a detailed practical blog on Metasploit Framework where I have discussed penetration testing from
scratch and end up with a most-requested practical.
In this blog, you will get to know about penetration testing, penetration testing tools, Installation of Metasploit tool,
Metasploitable OS setup and detailed information about Metasploit filesystem, Metasploit Commands, Meterpreter and
much more.
At the end of this blog, I have also included a video of Metasploit Framework for your ease that will show you how to
use Metasploit in real life.
If you want to know how to start your career in ethical hacking then you can check my blog on How to Become an
Ethical Hacker | Techofide where our IT professional thoughts and experiences are shared.
Note: We are teaching you just for an educational purpose and to increase your knowledge so that you can prevent
your system. As we know that these tools are used by both ethical and non-ethical hacker's so Techofide will not
responsible for any illegal activities done by you.
In this blog, you will see all about Metasploit with its usage. We will see how to do penetration testing using the
Metasploit framework. Metasploit is the most famous and powerful penetration testing tool that is used for both hacking
and preventing.
It is an open-source platform i.e, It is free and you can also use its code and modify this tool according to your
operating system. Hackers and Security professionals or white hats analyst always take advantage of that and
customize this tool according to their system. It is freely available for all platforms.
All In 1 Place
Metasploit's best thing is that it supports external cmds like nmap, ping dig etc.
So in 2003 M.D Moore created Metasploit project in Perl which was re-written by Rapid7 (Software Company) in Ruby
language with extra functionalities that helps to target more number of system to hack and prevent.
Before directly going to performs practical, you need to know how to install Metasploit in your system. So you can
install Metasploit on both Window and Linux System with the help of the Github Repository. It is also present in GUI
(Graphical User Interface) version but for full access to the licensed version, you have to purchase.
But we will use the CLI version because it is free and open-source also enables us to customise.
To know how to install Metasploit in Window you can check the installation steps by visiting my blog on How to Install
Metasploit in Windows
https://techofide.com/blogs/what-is-metasploit-framework-what-is-penetration-testing-how-to-use-metasploit/ 2/17
1/28/24, 11:07 PM What is Metasploit Framework and How to use Metasploit
All In 1 Place
To know how to install Metasploit in Linux you can check the installation steps by visiting my blog on How to Install
Metasploit in Linux
What is Metasploitable?
Metasploitable is a vulnerable machine that is very helpful to practice and learns the Metasploit. As we know that
doing hacking and attacking practices to any system or website without its owner permission is an illegal activity So
Metasploitable machine is made for this reason so that anyone who wants to learn penetration testing can
do practicals. We can use this OS to set up a penetration testing environment.
To install a Metasploitable OS you can follow my blog by clicking on How to Install Metasploitable Machine
So let's view the filesystem of MSF (Metasploit Framework) so that during practicals it will be easier for you to
understand how and from where things are working and coming.
All In 1 Place
Refer to the below image to see the filesystem of MSF, you can also open the same to go to /usr/share/metasploit-
framework path of your system.
https://techofide.com/blogs/what-is-metasploit-framework-what-is-penetration-testing-how-to-use-metasploit/ 3/17
1/28/24, 11:07 PM What is Metasploit Framework and How to use Metasploit
Data: This directory includes editable files which are used by Metasploit for storing binaries for certain exploits,
wordlist, images, templates, logos, meterpreter, detectors and much more.
Tools: It stores cmd (command) utilities like plugins, hardware, memdump etc. that we used during MSF.
Scripts: As its names, this folder contains various scripts like Meterpreter scripts, Resources, PowerShell etc. that
are required to run MSF functionalities.
Modules: It is the folder where you will find the actual MSF modules for exploits, nop generators, evasions,
auxiliary, post, payload, and encoder.
Plugins: Plugins are the additional extensions that help to automate manual tasks. The plugin works directly with
the API and only works in the MSF console.
Documentation: It contains documents like pdfs that are related to Metasploit Framework that help to understand
this tool in more depth. It has a developers.pdf file README.md file.
Lib: This folder also contains the needs of the framework for base i.e, everything that needs to run the
Metasploit from start to end. It consists of various MSF libraries that permit us to executes our exploits without
having to write additional code for certain tasks, like HTTP, REX, MSF::CORE, MSF::BASE.
Let's understand what is the actual model of the Metasploit Framework. I am referring to the above image.
Metasploit Framework is developed in the Ruby programming language. So here, all modules are Ruby classes.
Important Libraries
Any interaction is done by the user is always passes through many modules present in usr/share/metasploit-
framework/modules/ path. Primary module stores in the module's folder and custom stores in ~/.msf4/module/.
Exploits
An exploit executes a sequence of commands that target a specific vulnerability found in a victim's system. Hackers
used to take advantage of the weakness of the victim's system to hack them. For example, if the hacker's found any
port is open in your system they will try to use that port as a door to enter your system. Open ports always enhance the
risks of OS
Auxiliary
It is different as compare to exploits. We can use it for ports scanning, sniffing, DOS attacks and much more.
Payloads
It consists of code that runs remotely. So basically after exploitation, a code is run which is known as payload so you
can say that it is a second process, they help to take remote of the system and perform other tasks.
Encoders
Encoders convert your code in such format so that it cannot be detected by security devices (Antivirus, IDS, HIDS,
Firewalls etc.) They also confirms that the payload will reach its desired destination to achieve the given job.
Nops
Nops stands for no operations whose job is to maintain the size of the payload and ensure that they never crash
https://techofide.com/blogs/what-is-metasploit-framework-what-is-penetration-testing-how-to-use-metasploit/ 5/17
1/28/24, 11:07 PM What is Metasploit Framework and How to use Metasploit
Evasion
These new modules are designed for more efficiency and security that helps you to create a payload that can evade
detection device's like Antivirus and detection systems on the target. It prevents our payload from security device that
prevents unauthorized access.
Post
These are the post-exploitation modules that can be run on compromised targets to gather detailed information like
evidence, pivot, deeper into a victims network and system
Types of Payloads
A payload in Metasploit Framework is a module of an exploit. Metasploit Framework consists of various types of
payload, each plays a unique role within the framework.
Single Payload
It is a self-contained and standalone payload that is used to do a single operation or task like user creation on the
victim's system or transfer a file. but they can be caught with non-Metasploit handlers such as netcat.
Stagers Payload
It is also known as a stager payload that is used to upload bigger content on the victim's system. Stagers set up a
network connection between the attacker and victim and are designed to be small and reliable. It is difficult to achieve
both at the same time but with stagers it is possible.
Stages Payload
This is the payload that is downloaded by the stager payload on the victim's system. It also provides advanced features
like Meterpreter session, VNC injections and much more
Meterpreter
It is the most famous and useful payload that provides an interactive shell. As you know that if you want to run any
cmd (command) you need a shell, So Meterpreter provides you with that shell from where you can run multiple
cmds and multiple other functions
Passivex
It is mainly used on the victim's system when there is a firewall and it restricted outbound traffic. It can happen because
of an ActiveX control that creates a hidden instance of Internet Explorer. It uses the new ActiveX and communicates
with the attacker via HTTP requests and responses.
https://techofide.com/blogs/what-is-metasploit-framework-what-is-penetration-testing-how-to-use-metasploit/ 6/17
1/28/24, 11:07 PM What is Metasploit Framework and How to use Metasploit
IPV6
As the name indicates, Metasploit IPv6 payload is built to perform functions on IPv6 networks.
NONX
NONX stands for No eXecute bit that is a feature made for some CPUs to prevent code from running in certain areas
of memory. In Window, NX is implemented as Data Execution Prevention (DEP). The Metasploit NoNX payload is
made to bypass DEP.
ORD
It stands for Ordinal payload that are Windows stager based payloads that have different pros and cons. The pro is it
works on every flavour and languages of Window dating back to Window 9x without the explicit definition of a return
address and the con is it is not much stable and default option of an attacker.
Bind Shell
For binding shells, the listener runs on the destination and the attacker connects to the listener to get a remote shell.
However, there is a security issue with binding shells, and this is the fact that anyone can connect to the bind shell and
run the command. A malicious actor can simply take benefits of this.
Reverse Shell
Reverse shells run the headset on the attacker and the target is connected to the attacker using a shell. Reverse shells
solve many headaches that bind the shells that caused us.
Apart from this Meterpreter not start any new process because this payload uses DLL injection to perform tasks.
Don't worry you might be not aware of how Meterpreter works or what is DNL? Let's understand it in the working of
Meterpreter.
What is DNL?
Let's first understand what is DNL before directly going to understand the working concept of Meterpreter.
DNL stands for dynamic link libraries, these are the programs that help to run multiple programs to your system. DNL
are those files that are used by more than one program and those files are commonly pre-installed on the
Window operating system.
If you have used Window OS then you may have seen an error when you tried to run a newly install game or program
"DLL file is a missing" error because programs and applications need those files to provide proper functionalities, so
these are the files that automatically came with programs and software.
https://techofide.com/blogs/what-is-metasploit-framework-what-is-penetration-testing-how-to-use-metasploit/ 7/17
1/28/24, 11:07 PM What is Metasploit Framework and How to use Metasploit
Along with that Meterpreter provides various other features see examples like you can do multi-tasking, you can handle
multiple sessions and much more.
Metasploit Commands
So before going to practical it is good to familiar with some cmds that will be used in the practical demo. MSF Console
has many different cmd options to choose from. The following is a basic list of Metasploit cmds related to its output.
msfconsole: The MSFconsole is launched by simply running msfconsole from the CLI. It is used to go into the
Metasploit interface.
banner: It Simply shows a random generated banner (Just use for fun)
search: This cmd is used to search payloads, exploits, auxiliary etc. from the MSF.
connect: If you run that cmd with an IP address and port number, you can connect to a remote host from the MSF
console, just like Netcat or Telnet.
cd: It is a simple cmd use to switch from one directory to other.
back: If you are inside some exploit or auxilary you can use the back cmd to go to the one step back.
grep: The grep cmd is similar to Linux Grep. Corresponds to a specific pattern of the output of another
MSFConsole command.
jobs: The jobs cmd will show all running job which you can see and terminate.
kill: This cmd will kill running jobs
load: This cmd use when you want to load plugins from the Metasploit Framework directory.
info: The info cmd provides detailed information about a specific module, including all options, targets, and other
information.
show options: Once you have selected a particular module, you can run the show options cmd to see which
configurations are available and/or required for that specific module
set: The set cmd permits you to configure Framework options and parameters for the selected module you are
working with.
check: There aren't many vulnerabilities that support this, but there is also a scan option that checks if a victim is
vulnerable to a particular exploit, rather than actually exploiting it.
edit: The edit cmd will edit the current module using $VISUAL or $EDITOR. By default, this opens the current
module in Vim.
use: When you have chosen a specific module you want to use, run the use cmd to select it. The use command
changes the context to a specific module, which makes type-specific commands available.
exploit: This cmd is used to execute the exploit on the target system.
exit: This cmd will exit you from MSFconsole
help: A very helpful cmd that will show you all commands that are available in the MSF console with a short
description.
Metasploit Tutorial
Now we have learned everything thing that needs to do a practical or for a good beginning with the Metasploit
Framework.
Let's begin with our first practical where I will show you how you can use Metasploit to prevent your system from
attackers. You can also use this method to hack someone's system.
https://techofide.com/blogs/what-is-metasploit-framework-what-is-penetration-testing-how-to-use-metasploit/ 8/17
1/28/24, 11:07 PM What is Metasploit Framework and How to use Metasploit
The cmds you will see below are the same applied for other operating systems
Note: I am teaching you Metasploit Framework only for learning and to increase your knowledge. As I told above my
motive is to teach you the Metasploit Framework to prevent your system, you can do the same action to more secure
your system. Techofide is not responsible for any other illegal practices made by you.
Step 1: Open your terminal and let's first start our database "Postgres SQL" So that if in any case, we want to save
our data during pen-testing we can save it to our datastore. To start the database run the below-mentioned cmd.
Step 2: Now after starting the database we can go to our Metasploit tool interface with the help of msfconsole cmd.
msfconsole
Step 3: We have two machines, Kali, where our Metasploit tool present and the Metasploitable system which is
our (Victim's system). So now we will see how to hack our Metasploitable (victim system) from Kali (Attacker System)
https://techofide.com/blogs/what-is-metasploit-framework-what-is-penetration-testing-how-to-use-metasploit/ 9/17
1/28/24, 11:07 PM What is Metasploit Framework and How to use Metasploit
I have shown you the IP Address Of both Machines [ Attacker System = 10.0.2.15 and Victim's System =
192.168.1.7 ] so that we can see our results after exploitation. You can also see the IP of your system by running the
"ifconfig" cmd (For Linux) Window users can run "ipconfig"
So the first thing which every Cyber Security expert will do is "information gathering" i.e, we need to scan our
victim system to collect information about ports, software versions, vulnerabilities, and other weaknesses so that
we can decide which exploit is needed to access the victim's system.
To scan our victim's system, we can use various tools. but here I am using Nmap because it's most usable and freely
available.
Step 4: Now run the below cmd to scan the victim's OS.
Here nmap is the tool -s defines software and V defines versions of the software and then the IP_ADDRESS of the
victim's OS. So this cmd will scan all software versions and services that are running on our targeted system.
https://techofide.com/blogs/what-is-metasploit-framework-what-is-penetration-testing-how-to-use-metasploit/ 10/17
1/28/24, 11:07 PM What is Metasploit Framework and How to use Metasploit
Now we can see in the above image that it scans the targeted system's services, software versions and showing us the
states of ports.
Step 5: Now our next step is we have to choose a service from which we can access our targeted system. I am
choosing the first service "vsftpd 2.3.4" to exploit.
Step 6: After choosing a service now we have to find the exploit for that particular service that will help us to access the
victim's system, so for that, we will use the search cmd
search vsftpd
Step 7: Now we have got some exploits for our service which we can use. so just copy the name of the exploit and use
it next to the use cmd to go inside the exploit.
use exploit/unix/ftp/vsftpd_234_backdoor
Step 8: Now we are inside our exploit which looks like [ msf6 exploit(unix/ftp/vsftpd_234_backdoor) ] so we are very
near to access the system. so first we will use the show options cmd to check the exploit requirements.
show options
https://techofide.com/blogs/what-is-metasploit-framework-what-is-penetration-testing-how-to-use-metasploit/ 11/17
1/28/24, 11:07 PM What is Metasploit Framework and How to use Metasploit
Here in the above picture, you can see RHOSTS which means Remote Hosts IP and RPORT is a remote host port.
Step 9: Now we have to set remote host IP in this exploit so let's do this with the below cmd
Step 10: Now after setting the Remote host IP we can hack our targeted system so just run exploit cmd and wait for
few minutes.
exploit
Step 11: Now see we have entered into our targeted system. You can verify it by using ifconfog or ls cmd I displays
the result below.
https://techofide.com/blogs/what-is-metasploit-framework-what-is-penetration-testing-how-to-use-metasploit/ 12/17
1/28/24, 11:07 PM What is Metasploit Framework and How to use Metasploit
This is the hands-on of Metasploit Framework in real life. I have tried to cover all important things related to Metasploit
Framework, you can also watch the below video of this practical and if you face any difficulty you can give your
comment below I will definitely resolve your issue.
Please use Metasploitable OS or any other local OS for tests, So you can only deal with legal things
I hope you like this blog, In our next blog I will show you more practicals and that blog will only include practical with
Metasploit Framework.
Related Blogs
How to Become an Ethical Hacker | Techofide
How to Install Metasploit on Windows and Linux [Step by Step Guide]
How To Install Arch Linux 2021 [Installation Guide] | Techofide
Metasploit Unleashed | Offensive Security
CrateDB Learn M
3 0 1 0
Upvote Downvote Love Surprised
0 Comments
1 Login
Subscribe Us
* indicates required
Email Address *
Name
Subscribe
https://techofide.com/blogs/what-is-metasploit-framework-what-is-penetration-testing-how-to-use-metasploit/ 14/17
1/28/24, 11:07 PM What is Metasploit Framework and How to use Metasploit
kanav
Working in IT Industry for the past years and establish my expertise in Cyber Security, … readmore
Recent posts
@kartikhunt3r
How to Install OWASP ZAP on Windows and Linux
@kartikhunt3r
Snort - Intrusion Detection System & Prevention System | Installation & Use in Windows
@thedevsec
What is a Keylogger? | How to use Keylogger | Types of Keyloggers [ Practical Demo ]
@kartikhunt3r
OWASP ZAP | A Powerful Web Application Security Testing Tool
@kartikhunt3r
Mastering Snort | An Intrusion Detection and Prevention System | Step by Step Guide
@kartikhunt3r
Snort - Intrusion Detection System & Prevention System | Installation & Use in Linux
@thedevsec
What is Mobile Device Security | How to Hack a Phone | Practical Demo
@kartikhunt3r
What is Intrusion Detection System | What is Intrusion Prevention System | IDS vs IPS
@kartikhunt3r
Unlocking the Secrets of Advanced SQL Injection Attacks: Part 3 - Blind SQL Injection and Effective Prevention Strategies
@kartikhunt3r
Mastering Advanced SQL Injection Attacks: Part 2 - Practical Demo and Prevention of Blind SQL Injection
@kartikhunt3r
Advanced SQL Injection Attack (SQLi) | Blind SQL Injection And Prevention
@thedevsec
What is Digital Forensics | Practical Demo on Volatility
@kartikhunt3r
Decoding Website Hacking: A Beginner's Guide to Understanding How the Internet Works
@kartikhunt3r
What is Website Hacking | Web Application Penetration Testing | Lab Setup
@kartikhunt3r
Uncovering Vulnerabilities: Shodan, GitHub Dorks, and LinkedIn - OSINT Tools for Bug Hunting
@thedevsec
What is Digital Forensics | How to Use Digital Forensics Tools
@kartikhunt3r
Exploring OSINT Tools| DNS Dumpster and Netcraft for Bug Hunters
@kartikhunt3r
Mastering OSINT| A Comprehensive Guide to Intelligence Gathering for Bug Hunters
@thedevsec
What is Packet Sniffing? | How to Perform Packet Sniffing | Practical Demo on Wireshark
@kartikhunt3r
Unleashing the Power of OSINT| A Complete Guide to the OSINT Framework, Essential Tools, and Best Techniques
https://techofide.com/blogs/what-is-metasploit-framework-what-is-penetration-testing-how-to-use-metasploit/ 15/17
1/28/24, 11:08 PM What is Metasploit Framework and How to use Metasploit
@kartikhunt3r
What is Smurf Attack? | What is the Denial of Service Attack? | Practical DDoS Attack Step By Step Guide
@kanav
How to Use Metasploit | Metasploit Commands | Metasploit Tutorial
@kanav
How to Use Metasploit | Meterpreter | Reverse shell | Metasploit Tutorial
@Rudra_Sonkusare
How to use Aircrack-ng | Aircrack-ng tutorial [Practical demonstration]
@kanav
How to Use Wireshark | A Full Wireshark Tutorial |Techofide
@kanav
How to Install DVWA (Damn Vulnerable Web App) | DVWA SQL Injection
@kanav
SQL Injection Attack (SQLi) | SQL Injection Prevention | SQL Injection Cheat Sheet [Practical Demo]
@kanav
What is DoS Attack | How to do Denial of Service Attack [Practical Demo]
@kanav
How to Use John the Ripper | John the Ripper Password Cracker | Techofide
@kanav
Nmap Commands | How to Use Nmap Tool [Nmap Cheat Sheet]
@kanav
What is Tor | How to Use Tor Browser?
@kanav
How to Become an Ethical Hacker | Techofide
@kanav
How to Install Metasploit on Windows and Linux | [Step by Step Guide]
@kanav
What is Metasploit Framework | What is Penetration Testing | How to use Metasploit
Categories
Techofide
Rajpura Chungi, Jammu, Jammu and Kashmir 180001
Phone: +91 7006143431, 7087295862
Email:
Useful Links
Home
About us
Terms of service
Privacy policy
Refund policy
https://techofide.com/blogs/what-is-metasploit-framework-what-is-penetration-testing-how-to-use-metasploit/ 16/17
1/28/24, 11:08 PM What is Metasploit Framework and How to use Metasploit
Copyright policy
Our Services
Courses
Blogs
Technical Support
Write For Us
your@email.com Subscribe
https://techofide.com/blogs/what-is-metasploit-framework-what-is-penetration-testing-how-to-use-metasploit/ 17/17