💣The Metasploit Framework (MSF)
For this particular session, I did not create any detailed notes. Instead, I have listed the modules used in this session along with a one-line description of their usage. This is not a complete set of notes for this section only. As I am very familiar with The Metasploit Framework (MSF), for more details you can refer to the following documentation for The Metasploit Framework (MSF) by Rapid7.
Nmap Commands
Create a new workspace with the specified name:
workspace -a <workspace_name>Import the results of an Nmap scan into the Metasploit database:
db_import <nmap_scan_path>List the hosts stored in the Metasploit database:
hostsList the services associated with hosts in the Metasploit database:
servicesPerform an Nmap scan against a specific IP address, and update the Metasploit database with the scan results:
db_nmap -Pn -sV -O <ip>List the vulnerabilities identified and stored in the Metasploit database:
vulns
Enumeration
Port Scanning with Auxiliary Modules
Search for modules related to port scanning within the Metasploit framework:
search portscanUse
curlto make an HTTP request to the specified IP address:curl <ip>Run the
autoroutemodule to add routes for the specified IP range, allowing traffic to be routed through the compromised host:run autoroute -s <ip_range>
FTP Enumeration
Search for auxiliary modules related to FTP in the Metasploit framework:
search type:auxiliary name:ftpAuxiliary Modules:
Determine the FTP server version running on a target host:
auxiliary/scanner/ftp/ftp_versionPerform login attempts against an FTP server to validate credentials:
auxiliary/scanner/ftp/ftp_loginCheck if anonymous FTP login is allowed on the target FTP server:
auxiliary/scanner/ftp/ftp_anonymousEnumerate directories and files on an FTP server:
auxiliary/scanner/ftp/ftp_enumRetrieve a list of directories and files from an FTP server:
auxiliary/scanner/ftp/ftp_list
SMB Enumeration
Search for auxiliary modules related to SMB (Server Message Block) services in the Metasploit framework:
search type:auxiliary name:smbAuxiliary Modules:
Enumerate available shares on an SMB server:
auxiliary/scanner/smb/smb_enumsharesEnumerate user accounts on an SMB server:
auxiliary/scanner/smb/smb_enumusersDetermine the SMB version and OS information of an SMB server:
auxiliary/scanner/smb/smb_versionPerform login attempts against an SMB server to validate credentials:
auxiliary/scanner/smb/smb_loginEnumerate group names on an SMB server:
auxiliary/scanner/smb/smb_enumgroups
Web Server Enumeration
Search for auxiliary modules related to HTTP services in the Metasploit framework:
search type:auxiliary name:httpAuxiliary Modules:
Enumerate Apache user directories:
auxiliary/scanner/http/apache_userdir_enumPerform directory brute force attacks:
auxiliary/scanner/http/brute_dirsScan for directories on a web server:
auxiliary/scanner/http/dir_scannerCheck for directory listings on a web server:
auxiliary/scanner/http/dir_listingTest for the HTTP PUT method:
auxiliary/scanner/http/http_putCheck for files in web directories:
auxiliary/scanner/http/files_dirPerform HTTP login attempts:
auxiliary/scanner/http/http_loginRetrieve HTTP headers from web servers:
auxiliary/scanner/http/http_headerDetermine the version of HTTP used by web servers:
auxiliary/scanner/http/http_versionRetrieve and analyze the
robots.txtfile from web servers:auxiliary/scanner/http/robots_txt
MySQL Enumeration:
search type:auxiliary name:mysqlSearch for auxiliary modules related to MySQL services in the Metasploit framework.
Auxiliary Modules:
auxiliary/admin/mysql/mysql_enumEnumerate MySQL databases and tables.
auxiliary/admin/mysql/mysql_sqlExecute arbitrary SQL commands against a MySQL server.
auxiliary/scanner/mysql/mysql_file_enumEnumerate files on a MySQL server.
auxiliary/scanner/mysql/mysql_hashdumpDump password hashes from a MySQL server.
auxiliary/scanner/mysql/mysql_loginPerform login attempts against a MySQL server.
auxiliary/scanner/mysql/mysql_schemadumpDump database schemas from a MySQL server.
auxiliary/scanner/mysql/mysql_versionDetermine the version of MySQL running on a server.
auxiliary/scanner/mysql/mysql_writable_dirsIdentify writable directories on a MySQL server.
SSH Enumeration:
search type:auxiliary name:sshSearch for auxiliary modules related to SSH (Secure Shell) services in the Metasploit framework.
Auxiliary Modules:
auxiliary/scanner/ssh/ssh_versionDetermine the version of the SSH protocol used by an SSH server.
auxiliary/scanner/ssh/ssh_loginPerform login attempts against an SSH server.
SMTP Enumeration:
search type:auxiliary name:smtpSearch for auxiliary modules related to SMTP (Simple Mail Transfer Protocol) services in the Metasploit framework.
Auxiliary Modules:
auxiliary/scanner/smtp/smtp_enumEnumerate SMTP accounts on a mail server.
auxiliary/scanner/smtp/smtp_relayCheck if the SMTP server allows relaying.
auxiliary/scanner/smtp/smtp_user_enumEnumerate valid usernames on an SMTP server.
auxiliary/scanner/smtp/smtp_vrfyVerify the validity of email addresses using SMTP VRFY commands.
auxiliary/scanner/smtp/smtp_webmail_enumEnumerate webmail accounts associated with an SMTP server.
Vulnerability Scanning
Vulnerability Scanning With MSF:
analyzeThe
analyzecommand is used for analyzing modules, exploits, and vulnerabilities in the Metasploit framework.Metasploit-Autopwn GitHub Script: Metasploit-Autopwn is a GitHub script that automates the process of scanning and exploiting vulnerabilities using Metasploit. It simplifies the task of identifying and exploiting targets.
To load a custom module in Metasploit:
sudo mv <module_file> /usr/share/metasploit-framework/pluginsMove the custom module file to the Metasploit plugins directory.
load db_autopwnLoad the
db_autopwnmodule, which is used for automating the exploitation of targets in the Metasploit database.
Vulnerability Scanning With Nessus:
db_import <nessus_file_path.nessus> cImport a Nessus scan report file into the Metasploit database with the "c" option to clear existing data.
Web App Vulnerability Scanning With WMAP:
load wmapLoad the WMAP (Web Metasploit Automation Project) extension.
wmap_Access the WMAP sub-menu for further commands.
wmap_sites -a <target_URL>Add a target URL to the WMAP scan list.
wmap_sites -lList the target sites currently in the WMAP scan list.
wmap_targets -t <target_URL>Specify a target URL for scanning.
wmap_targets -lList the defined target URLs.
wmap_run -tRun WMAP scans on the specified target.
wmap_run -eExport WMAP scan results.
wmap_vulns -lList the discovered vulnerabilities from WMAP scans.
Exploitation
Windows Exploitation
Exploiting A Vulnerable HTTP File Server:
exploit/windows/http/rejetto_hfs_execThis Metasploit module exploits a remote code execution vulnerability in Rejetto HTTP File Server (HFS). It allows an attacker to execute arbitrary code on a target system running a vulnerable version of HFS.
Exploiting Windows MS17-010 SMB Vulnerability:
exploit/windows/smb/ms17_010_eternalblueThis Metasploit module exploits the MS17-010 vulnerability, also known as EternalBlue, in the SMB (Server Message Block) protocol. It allows an attacker to execute arbitrary code on a target system running a vulnerable version of Windows.
Exploiting WinRM (Windows Remote Management Protocol):
auxiliary/scanner/winrm/winrm_loginThis auxiliary module is used to perform login attempts against a Windows Remote Management (WinRM) service to check for valid credentials.
auxiliary/scanner/winrm/winrm_auth_methodsThis auxiliary module enumerates the authentication methods supported by a WinRM service.
auxiliary/scanner/winrm/winrm_cmdThis auxiliary module allows the execution of arbitrary commands on a remote Windows system through the WinRM service.
exploit/windows/winrm/winrm_script_execThis Metasploit module is used to execute PowerShell scripts on a remote Windows system via the WinRM service.
Exploiting A Vulnerable Apache Tomcat Web Server:
exploit/multi/http/tomcat_jsp_upload_bypassThis Metasploit module exploits a vulnerability in Apache Tomcat servers that allows an attacker to bypass file upload restrictions and upload a JSP (JavaServer Pages) webshell, which can lead to remote code execution on the target server.
Linux Exploitation
Exploiting A Vulnerable FTP Server:
exploit/unix/ftp/vsftpd_234_backdoorThis Metasploit module exploits a backdoor vulnerability in certain versions of the vsftpd FTP (File Transfer Protocol) server. It allows an attacker to gain unauthorized access to the target system.
Exploiting Samba:
exploit/linux/samba/is_known_pipenameThis Metasploit module checks if a named pipe exists on a Linux system running Samba. Named pipes can be used for remote code execution and lateral movement in some scenarios.
Exploiting A Vulnerable SSH Server:
auxiliary/scanner/ssh/libssh_auth_bypassThis auxiliary module is used to scan for SSH servers that are vulnerable to the LibSSH authentication bypass vulnerability. This vulnerability allows an attacker to gain unauthorized access to SSH servers without proper authentication.
Exploiting A Vulnerable SMTP Server:
exploit/linux/smtp/harakaThis Metasploit module exploits vulnerabilities in the Haraka SMTP server on Linux systems. It allows an attacker to gain unauthorized access and execute arbitrary code on the target system.
Hacker's Mantra:Being a hacker does not say what side you are on. Being a hacker means you know how things actually work and can manipulate the way things actually work for good or for harm. - Dan K
Last updated
Was this helpful?