Catalog / Metasploit Cheatsheet
Metasploit Cheatsheet
A comprehensive cheat sheet covering essential Metasploit commands, modules, and techniques for penetration testing and vulnerability exploitation.
Core Commands
Basic Commands
|
Displays help menu. |
|
Displays the Metasploit banner. |
|
Shows the current Metasploit version. |
|
Exits the Metasploit console. |
|
Searches for modules related to a keyword. |
|
Displays information about a specific module. |
Module Interaction
|
Loads a module. |
|
Displays available options for the loaded module. |
|
Sets a value for a module option. |
|
Unsets a previously set option. |
|
Executes the loaded module. |
|
Returns to the main Metasploit console. |
Database Backend Commands
|
Checks the status of the database connection. |
|
Connects to a database. |
|
Lists discovered hosts. |
|
Lists discovered services. |
|
Lists discovered vulnerabilities. |
|
Lists discovered credentials. |
Meterpreter Commands
System Commands
|
Displays information about the target system. |
|
Gets the user ID of the current process. |
|
Attempts to escalate privileges to SYSTEM. |
|
Prints the current working directory. |
|
Changes the current directory. |
|
Searches for files on the target system. |
File System Commands
|
Lists files and directories in the current directory. |
|
Downloads a file from the target system. |
|
Uploads a file to the target system. |
|
Displays the contents of a file. |
|
Creates a directory. |
|
Deletes a file. |
Networking Commands
|
Displays network configuration. |
|
Forwards a port from the attacker machine to the target machine. |
|
Adds a route to the routing table. |
|
Displays network connections. |
|
Resolve hostname to IP address |
|
Displays network interface configuration (Linux). |
Post-Exploitation
Credential Gathering
|
Dumps password hashes from the SAM database (Windows). |
|
Migrates Meterpreter to another process. |
|
Starts capturing keystrokes. |
|
Dumps captured keystrokes. |
|
Takes a screenshot of the target’s desktop. |
|
Takes a snapshot from the target’s webcam. |
Pivoting
|
Adds a route to the routing table for pivoting. |
|
Backgrounds the current session. |
|
Lists active sessions. |
|
Interacts with a specific session. |
|
Displays the current routing table. |
|
Enters meterpreter shell. |
Persistence
|
Sets up persistence on the target system (Windows). |
|
Execute commands from autorun script. |
|
Uploads and runs Meterpreter as a Windows service. |
|
Enumerates registry keys. |
|
Uses a specific persistence exploit module. |
|
Creates a scheduled task. |
Advanced Techniques
Evasion Techniques
|
Enables stage encoding to evade antivirus. |
|
Sets the encoder for the stager. |
|
Verifies checksums of stager components. |
|
Generates payloads in different formats (e.g., exe, raw). |
|
Uses the shikata_ga_nai encoder for evasion. |
|
Sets exit function to thread for stealth. |
Module Development
Creating Auxiliary Modules |
Use the |
Creating Exploit Modules |
Exploit modules are designed to take advantage of vulnerabilities in target systems. |
Creating Post Modules |
Post modules are executed on a compromised target system after successful exploitation. |
Essential parameters |
|
Documenting Modules |
Provide clear descriptions, usage instructions, and notes for each module. |
Testing Modules |
Thoroughly test modules against various target environments and configurations. |
Resource Scripts
Creating a Resource Script |
Resource scripts are simple text files with a list of Metasploit commands to execute. |
Running a Resource Script |
|
Example |
|
Variables |
You can use variables in resource scripts to make them more flexible. |
Comments |
Add comments to your resource scripts to document what each command does. |
Automation |
Automate repetitive tasks, such as scanning a network for vulnerabilities or setting up a reverse shell. |