|
| 1 | +--- |
| 2 | +title: Set up an Ethical Hacking lab with Azure Lab Services | Microsoft Docs |
| 3 | +description: Learn how to set up a lab using Azure Lab Services to teach ethical hacking. |
| 4 | +services: lab-services |
| 5 | +documentationcenter: na |
| 6 | +author: spelluru |
| 7 | +manager: |
| 8 | +editor: '' |
| 9 | + |
| 10 | +ms.service: lab-services |
| 11 | +ms.workload: na |
| 12 | +ms.tgt_pltfrm: na |
| 13 | +ms.devlang: na |
| 14 | +ms.topic: article |
| 15 | +ms.date: 10/04/2019 |
| 16 | +ms.author: spelluru |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +# Set up a lab to teach shell scripting on Linux |
| 21 | +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. |
| 22 | + |
| 23 | +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 **Metaspoiltable** image and another machine with [Kali Linux](https://www.kali.org/) image. The Metasploitable virtual machine is used for exploiting purposes and Kali virtual machine provides access to the tools needed to execute forensic tasks. |
| 24 | + |
| 25 | +This article has two main sections. The first section covers how to create the classroom 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. |
| 26 | + |
| 27 | +## Lab configuration |
| 28 | +To set up this lab, you need an Azure subscription to get started. If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/) before you begin. Once you get an Azure subscription, you can either create a new lab account in Azure Lab Services or use an existing account. See the following tutorial for creating a new lab account: [Tutorial to setup a lab account](tutorial-setup-lab-account.md). |
| 29 | + |
| 30 | +Follow [this tutorial](tutorial-setup-classroom-lab.md) to create a new lab and then apply the following settings: |
| 31 | + |
| 32 | +| Virtual machine size | Image | |
| 33 | +| -------------------- | ----- | |
| 34 | +| Medium (Nested Virtualization) | Windows Server 2019 Datacenter | |
| 35 | + |
| 36 | +## Template machine |
| 37 | + |
| 38 | +After the template machine is created, start the machine and connect to it to complete the following three major tasks. |
| 39 | + |
| 40 | +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. |
| 41 | +2. Set up the [Kali](https://www.kali.org/) Linux image. Kali is a Linux distribution that includes tools for penetration testing and security auditing. |
| 42 | +3. Set up the Metasploitable image. For this example, the [Metasploitable3](https://github.com/rapid7/metasploitable3) image will be used. This image is created to purposely have security vulnerabilities. |
| 43 | + |
| 44 | +  |
| 45 | + |
| 46 | +### Prepare template machine for nested virtualization |
| 47 | +Follow instructions in [this article](how-to-enable-netsted-virtualization-template-vm.md) to prepare your template virtual machine for nested virtualization. |
| 48 | + |
| 49 | +### Set up a nested virtual machine with Kali Linux Image |
| 50 | +Kali is a Linux distribution that includes tools for penetration testing and security auditing. |
| 51 | + |
| 52 | +1. Download image from [https://www.offensive-security.com/kali-linux-vm-vmware-virtualbox-image-download/](https://www.offensive-security.com/kali-linux-vm-vmware-virtualbox-image-download/). |
| 53 | + 1. Download the **Kali Linux Hyper-V 64 Bit** for Hyper-V. |
| 54 | + 1. Extract the .7z file. If you don’t already have 7 zip, download it from [https://www.7-zip.org/download.html](https://www.7-zip.org/download.html). Remember the location of the extracted folder as you'll need it later. |
| 55 | +2. Open **Hyper-V Manager** from Administrative Tools. |
| 56 | +1. Select **Action**, and then select **Import Virtual Machine**. |
| 57 | +1. On the **Locate Folder** page of the **Import Virtual Machine** wizard, choose the location of the extracted folder that holds the Kali Linux image. |
| 58 | + |
| 59 | +  |
| 60 | +1. On the **Select Virtual Machine** page, select the Kali Linux image. In this case, the image is **kali-linux-2019.3-hyperv**. |
| 61 | + |
| 62 | +  |
| 63 | +1. On the **Choose Import Type** page, select **Copy the virtual machine (create a new unique ID)**. |
| 64 | + |
| 65 | +  |
| 66 | +1. Accept the default settings on **Choose Folders for Virtual Machine Files** and **Choose Folders to Store Virtual Hard Disks** pages, and then select **Next**. |
| 67 | +1. On the **Connect Network** page, choose **LabServicesSwitch** created earlier in the **Prepare Template for Nested Virtualization** section of this article, and then select **Next**. |
| 68 | + |
| 69 | +  |
| 70 | +1. Select **Finish** on the **Summary** page. Wait until copy and importing operations are completed. The Kali Linux virtual machine will now be available in Hyper-V. |
| 71 | +1. From **Hyper-V Manager**, choose **Action** -> **Start**, then choose **Action** -> **Connect** to connect to the virtual machine. |
| 72 | +12. The default username is `root` and the password is `toor`. |
| 73 | + |
| 74 | + > [!NOTE] |
| 75 | + > If you need to unlock the image, press the CTRL key and drag the mouse upwards. |
| 76 | + |
| 77 | +## Set up a nested virtual machine with Metasploitable Image |
| 78 | +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](https://github.com/rapid7/metasploitable3). |
| 79 | + |
| 80 | +1. Navigate to [https://information.rapid7.com/download-metasploitable-2017.html](https://information.rapid7.com/download-metasploitable-2017.html). Fill out the form to download the image and select the **Submit** button. |
| 81 | +1. Select the **Download Metasploitable Now** button. |
| 82 | +1. When the zip file is downloaded, extract the zip file, and remember the location. |
| 83 | +1. Convert the extracted vmdk file to a vhdx file so that you can use with Hyper-V. To do so, open PowerShell with administrative privileges and navigate to the folder where the vmdk file resides, and follow these instructions: |
| 84 | + 1. Download the [Microsoft Virtual Machine Converter](https://www.microsoft.com/download/details.aspx?id=42497), and run mvmc_setup.msi file when prompted. |
| 85 | + 1. Import the PowerShell module. The default location in which the module is installed is C:\Program Files\Microsoft Virtual Machine Converter\ |
| 86 | + |
| 87 | + ```powershell |
| 88 | + Import-Module 'C:\Program Files\Microsoft Virtual Machine Converter\MvmcCmdlet.psd1' |
| 89 | + ``` |
| 90 | + 1. Convert the vmdk to a vhd file that can be used by Hyper-V. This operation may take several minutes. |
| 91 | + |
| 92 | + ```powershell |
| 93 | + ConvertTo-MvmcVirtualHardDisk -SourceLiteralPath .\Metasploitable.vmdk -DestinationLiteralPath .\Metasploitable.vhdx -VhdType DynamicHardDisk -VhdFormat vhdx |
| 94 | + ``` |
| 95 | + 1. Copy the newly created metasploitable.vhdx to C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\. |
| 96 | +1. Create a new Hyper-V virtual machine. |
| 97 | + 1. Open **Hyper-V Manager**. |
| 98 | + 1. Choose **Action** -> **New** -> **Virtual Machine**. |
| 99 | + 1. On the **Before You Begin** page of the **New Virtual Machine Wizard**, click **Next**. |
| 100 | + 1. On the **Specify Name and Location** page, enter **Metasploitable** for the **name**, and select **Next**. |
| 101 | +
|
| 102 | +  |
| 103 | + 1. On the **Specify Generation** page, accept the defaults, and select **Next**. |
| 104 | + 1. On the **Assign Memory** page, enter **512 MB** for the **startup memory**, and select **Next**. |
| 105 | +
|
| 106 | +  |
| 107 | + 1. On the **Configure Networking** page, leave the connection as **Not Connected**. You'll set up the network adapter later. |
| 108 | + 1. 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**. |
| 109 | +
|
| 110 | +  |
| 111 | + 1. On the **Completing the New Virtual Machine Wizard** page, and select **Finish**. |
| 112 | + 1. Once the virtual machine is created, select it in the Hyper-V Manager. Don't turn on the machine yet. |
| 113 | + 1. Choose **Action** -> **Settings**. |
| 114 | + 1. On the **Settings for Metasploitable** dialog for, select **Add Hardware**. |
| 115 | + 1. Select **Legacy Network Adapter**, and select **Add**. |
| 116 | +
|
| 117 | +  |
| 118 | + 1. 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. |
| 119 | +
|
| 120 | +  |
| 121 | + 1. 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**. |
| 122 | +
|
| 123 | +
|
| 124 | +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. Select the **Publish** button on template page to publish the template to the lab. |
| 125 | + |
| 126 | +
|
| 127 | +## Cost |
| 128 | +If you would like to estimate the cost of this lab, you can use the following example: |
| 129 | + |
| 130 | +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. FOr more details on pricing, see [Azure Lab Services Pricing](https://azure.microsoft.com/pricing/details/lab-services/). |
| 131 | +
|
| 132 | +## Conclusion |
| 133 | +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. |
| 134 | +
|
| 135 | +## Next steps |
| 136 | +Next steps are common to setting up any lab: |
| 137 | +
|
| 138 | +- [Add users](tutorial-setup-classroom-lab.md#add-users-to-the-lab) |
| 139 | +- [Set quota](tutorial-setup-classroom-lab.md#set-quotas-for-users) |
| 140 | +- [Set a schedule](tutorial-setup-classroom-lab.md#set-a-schedule-for-the-lab) |
| 141 | +- [Email registration links to students](tutorial-setup-classroom-lab.md#send-an-email-with-the-registration-link). |
| 142 | +
|
0 commit comments