Working with Metasploit Modules
Overview of Metasploit Modules
Metasploit's modules are pre-built scripts designed for specific tasks such as vulnerability scanning, exploitation, post-exploitation, and evasion. They are a cornerstone of the framework, enabling penetration testers to streamline their workflows and automate tasks.
Purpose of Modules:
Automate repetitive processes.
Enhance manual testing by providing reusable functionality.
Organize tools and exploits into categorized scripts.
Types of Metasploit Modules
Auxiliary Modules:
Non-exploit modules for scanning, fuzzing, sniffing, and information gathering.
Example:
Encoders:
Modify payloads to bypass detection mechanisms like antivirus (AV).
Example:
Exploits:
Exploit vulnerabilities in systems or applications.
Example:
NOPs (No-Operation):
Maintain payload stability by filling memory with NOP instructions.
Example:
Payloads:
Code delivered to the target, often used to establish remote access.
Example:
Post-Exploitation Modules:
Perform tasks after gaining access, such as lateral movement or data extraction.
Example:
Plugins:
Extend Metasploit's functionality with additional features.
Example:
Module Structure
Modules are organized hierarchically based on their type, target OS, service, and functionality.
General Format:
Example:
Components Explained:
Type: Module category (e.g.,
exploit
,auxiliary
).Operating System: Target OS (e.g.,
windows
,linux
).Service: Vulnerable application or protocol (e.g.,
http
,smb
).Name: Descriptive identifier of the module.
Searching for Modules
Use the search
command to locate modules based on specific criteria.
Syntax:
Examples:
Search for modules related to MS17-010:
Filter by CVE ID:
Exclude specific platforms (e.g., Linux):
Search Options:
-h
Displays help for the search
command.
-o <file>
Saves search results to a file.
-S <regex>
Applies a regex filter to results.
-s <column>
Sorts results by a specific column.
-r
Reverses the sort order.
Using Modules: Practical Example
Scenario: Exploiting MS17-010 using the EternalRomance module.
Search for the Exploit:
Select the Module:
View Module Information:
Configure Options:
Execute the Exploit:
Post-Exploitation:
After gaining access, use payload commands (e.g., Meterpreter) to perform further actions such as privilege escalation or credential harvesting.
Command Cheatsheet
search <keyword>
Locate modules matching the keyword.
use <module_path>
Load a module into the console.
info
Display detailed information about a module.
show options
List configurable parameters for a module.
set <option> <value>
Configure a specific option.
run
or exploit
Execute the module.
show payloads
View payloads compatible with the module.
show targets
List targets supported by the module.