Set up a lab to teach ethical hacking class

Note

This article references features available since the August 2022 Update, in which lab plans replaced lab accounts. For more information, see What's New in the August 2022 Update.

This article shows you how to set up a class that focuses on forensics side of ethical hacking. Penetration testing, a practice used by the ethical hacking community, occurs when someone attempts to gain access to the system or network to demonstrate vulnerabilities that a malicious attacker may exploit.

In an ethical hacking class, students can learn modern techniques for defending against vulnerabilities. Each student gets a Windows Server host virtual machine that has two nested virtual machines – one virtual machine with Metasploitable3 image and another machine with Kali Linux image. The Metasploitable virtual machine is used for exploiting purposes and Kali virtual machine provides access to the tools needed to execute forensic tasks.

This article has two main sections. The first section covers how to create the lab. The second section covers how to create the template machine with nested virtualization enabled and with the tools and images needed. In this case, a Metasploitable image and a Kali Linux image on a machine that has Hyper-V enabled to host the images.

Lab configuration

To set up this lab, you need access to an Azure subscription. Discuss with your organization's administrator to see if you can get access to an existing Azure subscription. If you don't have an Azure subscription, create a free account before you begin.

Once you have an Azure subscription, you can create a new lab plan in Azure Lab Services. For more information about creating a new lab plan, see Tutorial: Set up a lab plan with Azure Lab Services. You can also use an existing lab plan.

Lab settings

For instructions on how to create a lab, see Tutorial: Set up a lab. Use the following settings when creating the lab.

Lab settings Value
Virtual machine (VM) size Medium (Nested Virtualization)
VM image Windows Server 2019 Datacenter

Template machine configuration

Once you create a lab, a template VM will be created based on the virtual machine size and image you chose. You configure the template VM with everything you want to provide to your students for this class. For more information, see Create and manage a template in Azure Lab Services.

To configure the template VM, we'll complete the following three major tasks.

  1. Set up the machine for nested virtualization. It enables all the appropriate windows features, like Hyper-V, and sets up the networking for the Hyper-V images to be able to communicate with each other and the internet.
  2. Set up the Kali Linux image. Kali is a Linux distribution that includes tools for penetration testing and security auditing.
  3. Set up the Metasploitable image. For this example, the Metasploitable3 image will be used. This image is created to purposely have security vulnerabilities.

You can complete the tasks above by executing the Lab Services Hyper-V Script and Lab Services Ethical Hacking Script PowerShell scripts on the template machine. Once scripts have been executed, continue to Next steps.

If you choose to set up the template machine manually, continue reading. The rest of this article will cover the manual completion of template configuration tasks.

Prepare template machine for nested virtualization

Follow instructions to enable nested virtualization to prepare your template virtual machine for nested virtualization.

Set up a nested virtual machine with Kali Linux Image

Kali is a Linux distribution that includes tools for penetration testing and security auditing.

  1. Download image from Offensive Security Kali Linux VM images. Remember the default username and password noted on the download page.
    1. Download the Kali Linux VMware 64-Bit (7z) image for VMware.
    2. Extract the .7z file. If you don’t already have 7 zip, download it from https://www.7-zip.org/download.html. Remember the location of the extracted folder as you'll need it later.
  2. Convert the extracted vmdk file to a vhdx file so that you can use the vhdx file with Hyper-V. There are several tools available to convert VMware images to Hyper-V images. We'll be using the StarWind V2V Converter. To download, see StarWind V2V Converter download page.
    1. Start StarWind V2V Converter.
    2. On the Select location of image to convert page, choose Local file. Select Next.
    3. On the Source image page, navigate to and select the Kali Linux vmdk file extracted in the previous step for the File name setting. The file will be in the format Kali-Linux-{version}-vmware-amd64.vmdk. Select Next.
    4. On the Select location of destination image, choose Local file. Select Next.
    5. On the Select destination image format page, choose VHD/VHDX. Select Next.
    6. On the Select option for VHD/VHDX image format page, choose VHDX growable image. Select Next.
    7. On the Select destination file name page, accept the default file name. Select Convert.
    8. On the Converting page, wait for the image to be converted. Conversion may take several minutes. Select Finish when the conversion is completed.
  3. Create a new Hyper-V virtual machine.
    1. Open Hyper-V Manager.
    2. Choose Action -> New -> Virtual Machine.
    3. On the Before You Begin page of the New Virtual Machine Wizard, select Next.
    4. On the Specify Name and Location page, enter Kali-Linux for the name, and select Next.
    5. On the Specify Generation page, accept the defaults, and select Next.
    6. On the Assign Memory page, enter 2048 MB for the startup memory, and select Next.
    7. On the Configure Networking page, leave the connection as Not Connected. You'll set up the network adapter later.
    8. On the Connect Virtual Hard Disk page, select Use an existing virtual hard disk. Browse to the location for the Kali-Linux-{version}-vmware-amd64.vhdk file created in the previous step, and select Next.
    9. On the Completing the New Virtual Machine Wizard page, and select Finish.
    10. Once the virtual machine is created, select it in the Hyper-V Manager. Don't turn on the machine yet.
    11. Choose Action -> Settings.
    12. On the Settings for Kali-Linux dialog for, select Add Hardware.
    13. Select Legacy Network Adapter, and select Add.
    14. On the Legacy Network Adapter page, select LabServicesSwitch for the Virtual Switch setting, and select OK. LabServicesSwitch was created when preparing the template machine for Hyper-V in the Prepare Template for Nested Virtualization section.
    15. The Kali-Linux image is now ready for use. From Hyper-V Manager, choose Action -> Start, then choose Action -> Connect to connect to the virtual machine. The default username is kali and the password is kali.

Set up a nested VM with Metasploitable Image

The Rapid7 Metasploitable image is an image purposely configured with security vulnerabilities. You'll use this image to test and find issues. The following instructions show you how to use a pre-created Metasploitable image. However, if a newer version of the Metasploitable image is needed, see https://github.com/rapid7/metasploitable3.

  1. Download the Metasploitable image.
    1. Navigate to https://information.rapid7.com/download-metasploitable-2017.html. Fill out the form to download the image and select the Submit button.
    2. Select the Download Metasploitable Now button.
    3. When the zip file is downloaded, extract the zip file, and remember the location of the Metasploitable.vmdk file.
  2. Convert the extracted vmdk file to a vhdx file so that you can use the vhdx file with Hyper-V. There are several tools available to convert VMware images to Hyper-V images. We'll be using the StarWind V2V Converter again. To download, see StarWind V2V Converter download page.
    1. Start StarWind V2V Converter.
    2. On the Select location of image to convert page, choose Local file. Select Next.
    3. On the Source image page, navigate to and select the Metasploitable.vmdk extracted in the previous step for the File name setting. Select Next.
    4. On the Select location of destination image, choose Local file. Select Next.
    5. On the Select destination image format page, choose VHD/VHDX. Select Next.
    6. On the Select option for VHD/VHDX image format page, choose VHDX growable image. Select Next.
    7. On the Select destination file name page, accept the default file name. Select Convert.
    8. On the Converting page, wait for the image to be converted. Conversion may take several minutes. Select Finish when the conversion is completed.
  3. Create a new Hyper-V virtual machine.
    1. Open Hyper-V Manager.
    2. Choose Action -> New -> Virtual Machine.
    3. On the Before You Begin page of the New Virtual Machine Wizard, select Next.
    4. On the Specify Name and Location page, enter Metasploitable for the name, and select Next. Screenshot of New Virtual Machine Wizard in Hyper V.
    5. On the Specify Generation page, accept the defaults, and select Next.
    6. On the Assign Memory page, enter 512 MB for the startup memory, and select Next. Screenshot of Assign Memory page of New Virtual Machine Wizard in Hyper V.
    7. On the Configure Networking page, leave the connection as Not Connected. You'll set up the network adapter later.
    8. On the Connect Virtual Hard Disk page, select Use an existing virtual hard disk. Browse to the location for the metasploitable.vhdx file created in the previous step, and select Next. Screenshot of Connect Virtual Hard Disk  page of New Virtual Machine Wizard in Hyper V.
    9. On the Completing the New Virtual Machine Wizard page, and select Finish.
    10. Once the virtual machine is created, select it in the Hyper-V Manager. Don't turn on the machine yet.
    11. Choose Action -> Settings.
    12. On the Settings for Metasploitable dialog for, select Add Hardware.
    13. Select Legacy Network Adapter, and select Add. Screenshot of settings dialog for Hyper V VM.
    14. On the Legacy Network Adapter page, select LabServicesSwitch for the Virtual Switch setting, and select OK. LabServicesSwitch was created when preparing the template machine for Hyper-V in the Prepare Template for Nested Virtualization section. Screenshot of Legacy Network adapter settings page for Hyper V VM.
    15. The Metasploitable image is now ready for use. From Hyper-V Manager, choose Action -> Start, then choose Action -> Connect to connect to the virtual machine. The default username is msfadmin and the password is msfadmin.

The template is now updated and has images needed for an ethical hacking penetration testing class, an image with tools to do the penetration testing and another image with security vulnerabilities to discover. The template image can now be published to the class.

Cost

If you would like to estimate the cost of this lab, you can use the following example:

For a class of 25 students with 20 hours of scheduled class time and 10 hours of quota for homework or assignments, the price for the lab would be:

25 students * (20 + 10) hours * 55 Lab Units * 0.01 USD per hour = 412.50 USD

Important

Cost estimate is for example purposes only. For current details on pricing, see Azure Lab Services Pricing.

Conclusion

This article walked you through the steps to create a lab for ethical hacking class. It includes steps to set up nested virtualization for creating two virtual machines inside the host virtual machine for penetrating testing.

Next steps

The template image can now be published to the lab. For more information, see Publish the template VM.

As you set up your lab, see the following articles: