Security Testing Tool

Understanding
Metasploit.

Metasploit is the world's most used tool for testing computer security. It lets you act like an attacker to see if your defenses actually work.

The Building Analogy

Think of a computer network like a massive office building with thousands of doors and windows.

If you own this building, you want to make sure every door is locked. But how can you be sure? You hire a security guard to walk around and physically push on every single door handle.

Metasploit is the ultimate toolkit for that security guard.

Instead of pushing on doors with their hands, the guard uses Metasploit. It is a giant collection of digital tools designed to check if a computer system has open doors, weak locks, or broken windows.

The 3 Words You Must Know

1. Vulnerability

The Broken Lock

A vulnerability is a mistake or a bug in a computer system. It is the exact spot where the defense is weak. It is the broken lock on the back door of the building.

2. Exploit

The Skeleton Key

An exploit is a specific piece of code used to break through that exact vulnerability. If the vulnerability is the broken lock, the exploit is the tool used to pick it.

3. Payload

The Package

The payload is what you do *after* you break the lock. It is the code that runs inside the system once the door is open. It might give you control of the computer or let you look around.

How A Test Works

1

Find the Target

Scan the network to see which computers are turned on and what software they are running.

2

Pick the Exploit

Look in Metasploit's giant list to find an exploit that matches the software the target is running.

3

Pick the Payload

Decide what you want to happen when you get in. Do you want a command screen? Do you want to add a user?

4

Fire!

Run the test. Metasploit sends the exploit, opens the door, and drops the payload inside.

The Giant List of Bugs

Metasploit is powerful because it comes with a built-in library. It knows about thousands of past mistakes made by software companies.

Type
Name
Status
exploit
windows/smb/ms17_010_eternalblue
Ready
exploit
linux/http/apache_struts_struts2
Ready
payload
windows/meterpreter/reverse_tcp
Ready

* Users can search this database instantly to find the exact tool they need.

The Ultimate Payload

Meet "Meterpreter"

We talked about payloads earlier. The most famous payload in Metasploit is called Meterpreter.

When you use an exploit to break into a system, normal tools leave a messy trail. Meterpreter is different. It is a special, invisible command screen.

  • It runs entirely in the computer's memory.
  • It never writes files to the hard drive.
  • It is very hard for antivirus programs to see.
meterpreter > sysinfo
Computer        : TARGET-SERVER-01
OS              : Windows Server
Architecture    : x64
Meterpreter     : x64/windows

meterpreter > getuid
Server username : NT AUTHORITY\SYSTEM
                    

Post-Exploitation: You are inside. Now what?

Getting in is only the first step. Metasploit has a whole section dedicated to what you do next. This is called "Post-Exploitation". Here is what testers do to prove the system is at risk:

Gather Users

Download a list of everyone who uses that computer to see if any passwords are weak.

Take Pictures

Take a secret screenshot of the screen to prove you have full access to the machine.

Pivot to Others

Use the compromised computer as a bridge to attack other computers hidden deep inside the building.

Hide Tracks

Erase the system logs so the computer has no record that the tester was ever there.

The Tools in the Box

Exploits

The battering rams. Programs that take advantage of a specific weakness to break into a system.

Payloads

The cargo. The code that actually runs on the target system after the exploit opens the door.

Auxiliary

The binoculars. Scanners and tools used to look around and gather information without actually attacking.

Encoders

The disguises. Tools that mix up the code so that antivirus programs cannot recognize it as bad.

A Real-World Example

Imagine a hospital hires a security tester to check their systems. Here is how they use Metasploit:

1. The Scan

The tester uses an Auxiliary module to scan the hospital's network. They find an old computer running a very old version of Windows.

2. The Setup

They search Metasploit for an Exploit that works on that old Windows version. They attach a Meterpreter Payload to it.

3. The Action

They fire the attack. The exploit works, and the tester gets a command screen on their laptop. They are inside the old computer.

4. The Report

The tester takes a screenshot to prove they got in. They stop the test, write a report, and the hospital updates the old computer to fix the broken lock.

Where Did It Come From?

Metasploit was created in 2003 by a programmer named H.D. Moore. It started as a free, open-source project—meaning anyone in the world could help build it.

Eventually, a security company called Rapid7 purchased the project. However, they kept the core engine free. Today, a massive community of researchers still adds new exploits to it every single day.

2003

Year Created

Free vs. Paid

Metasploit Framework

100% Free

The original tool. It is controlled entirely by typing commands into a black terminal screen. It has no buttons or menus. You must know what you are doing.

> msfconsole

Metasploit Pro

Paid Enterprise Tool

The version used by large companies. It provides a visual website interface with buttons, graphs, and automatic report generators. It does the exact same things under the hood.

Click to Exploit

The Control Room

Professionals control Metasploit using a tool called msfconsole. It is a text-only screen where you type instructions. When you launch it, you see a summary of all the tools loaded and a flashing cursor waiting for your command.

  +-------------------------------------------------------+
  |  METASPLOIT FRAMEWORK                                 |
  +-------------------------------------------------------+
  =[ metasploit v6.3.5                                    ]
  + -- --=[ 2294 exploits - 1201 auxiliary - 409 payloads ]

msf6 > _
                

Finding the Right Tool

With thousands of exploits, you need a way to filter them. Metasploit has a built-in search engine.

Example Command:

search type:exploit name:windows

This tells Metasploit: "Show me all the tools that are exploits designed to attack a Windows system."

Giving Directions

When you load an exploit, you must tell it exactly where to go and where to report back. You do this by setting two crucial variables.

RHOST

Remote Host (Their Address)

This is the IP address of the computer you are testing. It tells the exploit exactly which building to attack.

set RHOST 192.168.1.50

LHOST

Local Host (Your Address)

This is your computer's IP address. When the door opens, the payload needs to know where to phone home.

set LHOST 192.168.1.10

Keeping Doors Open

A Session is an active connection to a target. If you break into 3 different computers, you have 3 sessions running.

You can put these sessions in the background, like minimizing a window on your desktop, and jump between them whenever you want without losing access.

msf6 > sessions -l

Id Type Connection
1 meterpreter x64 192.168.1.10 -> 192.168.1.50
2 shell linux 192.168.1.10 -> 192.168.1.88

Staying Organized

Hospital_Test

Workspace 1

Bank_Audit

* Active

Retail_Store

Workspace 3

If you are testing a hospital on Monday and a bank on Tuesday, you do not want the data to mix. Workspaces act like separate project folders to keep all your found bugs completely isolated.

The Video Game Map

Typing commands is hard for beginners. Because of this, developers built Armitage. It is an add-on tool that draws a visual map of the network on your screen.

Computers look like little monitor icons. When you successfully break into one, the monitor turns red and gets lightning bolts around it, showing you exactly what you control visually.

Compromised

Bypassing the Guards (Encoders)

Antivirus programs look for known patterns. If an exploit looks like a known threat, the antivirus blocks it. Metasploit uses Encoders to scramble the exploit like a secret code.

Raw Exploit

Blocked by Antivirus

#@*%!$

Scrambled by Encoder

Memory

Unscrambles & Runs Inside

How To Practice

Meet "Metasploitable"

You should never test systems you do not own. So how do you learn? The creators of Metasploit built a fake computer system called Metasploitable. It is a system built entirely out of broken locks. You download it, run it safely inside your own computer, and practice attacking it without breaking any laws.

The Golden Rule of Testing

Never attack a system you do not own.

Metasploit is a tool. Like a hammer, you can use it to build a house or break a window. Professionals use Metasploit for Ethical Hacking. This means they only test systems when the owner has given them strict, written permission. The goal is always to find the hole and fix it before the bad guys find it.