Skip to content

Stage II - Building the SOC

Log Analytics and Microsoft Sentinel (SIEM) Setup + Data Ingestion

Create Log Analytics Workspace.

Create LAW

Add Sentinel to the workspace.

Add Sentinel

Sentinel & LAW Connected

Create Sentinel Watchlist

In Sentinel, a new watchlist for Geo IP Data. This watchlist will help us correlate security events to geographic locations later in the lab.

Create GeoIP sentinel Watchlist

Upload the geoIP data and set the search key.

Watchlist Wizard

Once the watchlist begins uploading, sentinel will start ingesting the data and it will be available for query, even before ingestion completes.

Checking Watchlist ingestion

Querying GeoIP data using KQL.

Query GeoIP Watchlist

Upload complete.

GeoIP Ingestion Complete

Enable Microsoft Defender for Cloud

Open MDC:

Enable MDC

Go to Environment Settings > Drill down to the LAW > click the three dots corresponding to LAW > Edit Settings

Enable MDC

Enable Data Collection Click Data Collection (in sidebar) > All Events > Save

Enable MDC

Back in MDC, go to Environment Settings > click the three dots corresponding to the Subscription > Edit Settings

Enable MDC

Under Defender Plans, toggle ON: Servers, Databases, Storage and Key Vault

Enable MDC

Next to Databases > Select Types > make sure 'SQL servers on Machines' is toggled ON, all else toggled OFF > Continue

Enable MDC

Next to Servers > Under Monitoring Coverage, click Settings > make sure everything is toggled ON

Enable MDC

Next to Log Analytics Agent > under Configuration > Edit Configuration. Change the workspace selection to Custom and select the LAW created and configured earlier > Apply > Continue > Save

Enable MDC

Note

If you accidentally saved before configuring the LAW agent: Go back and change to custom, then go through your resources and delete resources that were automatically provisioned in the processes. To avoid future mixups, make sure there is only ONE LAW.

Click Continuous Export in the sidebar > Select Log Analytics Workspace at the top > toggle ON Select everything (will fine tune later).

Make sure export Export Configuration points to the resource group where the LAW is stored and Export target points to the appropriate subscription and LAW. Click Save.

Enable Continuous export to LAW

Configure Log Collection for Virtual Machines

Create a Storage Account for Azure to place NSG flow logs later.

Note

Storage Account name must be globally unique.

Create a storage account

The important part is cut off here, but make sure the storage account is in the same region as the target VMs.

create a storage account wizard

Enable NSG flow logs for target VMs

Go to Network Security Groups, pick one (any but preferably one attached to a target VM) > Under Monitoring, click NSG flow logs > Create flow log

Create NSG Flow Logs

Click +Resource > Select the target VM's > Confirm Selection

Create a flow log wizard

Select NSG

Create a Data Collection Rule for target VMs

First make sure target VMs are running. The Microsoft Defender or will automatically install the agent to the VMs once they are running, if not, you can manually install later.

Next, go to LAW > Agents > Data Collection Rules > Create Data Collection Rule

Data Collection Rule page in LAW

Create DCR

Create DCR wizard

Click + Add Resources, and select target VMs > Apply.

Select resources for DCR

Select target VMs

DCR Resources

Click 'Next: Collect and deliver >' + Data Source and add select Linux Syslog from the dropdown for Data Source Type. Then only collect logs for LOG_AUTH (set all other logs to 'none' value) > Next: Destination

Add Linux Syslog Data Source

Set the destination to the Log Analytics Workspace > Add data source

Set dest for DCR to LAW

Add another data source, this time for Windows logs.

Data Collection Summary Page

Select Windows Event Logs from the data source dropdown. Under Basic > Application, Select Information. Under Security, select both Audit success and Audit failure to pull in failed authentication logs from RDP and the SQL Server.

DCR Wizard - Windows Event Logs

As you can see the options here are pretty, well, basic. In order to retrieve (filter) specific data from Windows event logs, XPath queries must be used. Switch over to Custom and add the following X-Path Queries:

For Windows Defender Malware Detection: Microsoft-Windows-Windows Defender/Operational!*[System[(EventID=1116 or EventID=1117)]]

For Windows Firewall Tampering Detection: Microsoft-Windows-Windows Firewall With Advanced Security/Firewall!*[System[(EventID=2003)]]

DCR Wizard, Windows Event Logs Custom Configuration

Save > Next: Destination and check that the logs are going to the appropriate LAW > Add data source > Review + Create > Create

DCR Wizard - Data Sources Summary Page

Data Collection Rule complete and deployed

Data Collection Rules in LAW

If you check back to LAW > Agents, the agents should have deployed and installed on the target VMs

Windows LAW Agent Installed and Connected

Linux LAW Agent Installed and Connected

Ideally, at this point you would start querying Log Analytics for logs from the VMs and NSGs to make sure the logs are coming in:

  • Syslog (linux)
  • SecurityEvent (windows)
  • AzureNetworkAnalytics_CL (Network Security Groups/NSGs)

SecurityEvent: SecurityEvent query in LAW

Syslog: Syslog query in LAW

AzureNetworkAnalytics_CL: AzureNetworkAnalytics in LAW

Tenant Level Logging

Create diagnostic settings in Azure Active Directory (Microsoft Entra ID) that allows us to ingest logs.

AAD Diagnostic Setting

Create a user, assign global admin and use Log Analytics to check that logs are properly being ingested.

Create a Dummy User

Assign Global Admin

Create an "attacker" user and generate some failed authentication logs by failing to log in 10-20 times.

Create an attacker user

Note

The AuditLogs come in pretty quickly, but the SigninLogs and AzureActivity take a while to come into the Log Analytics Workspace. Generate the logs, then take a 20-30 minute coffee break and query the LAW after.

Audit Logs

Audit Logs

Signin Logs

Signin Logs

Subscription Level Logging

Export Azure Activity Logs to Log Analytics Workspace.

Go to Azure Monitor > Activity Log > Export Activity Logs, create diagnostic settings.

Az Monitor

Diagnostic Setting Az Monitor

Generate some logs to confirm functionality. Here, I'm creating two resource groups and changing a NSG, then deleting them after confirming the logs are flowing into the LAW properly.

New Resource Groups

Test Resource Groups

New inbound security rule in attack-vm-nsg

Create Test Rule for Logs

Activity Logs

NSG Logs

Checking resource group deletion in logs

Resource Group deletion in LAW

Resource Level Logging (Data Plane Logs)
Storage Account

Enable logs for storage account and key vault.

Storage Accounts > Select Storage Account > Under Monitoring, select Diagnostic Settings

Create a Diagnostic Setting AZ Storage

Click 'Disabled' next to 'blob' > Add Diagnostic setting > Select Audit, create name for setting > Save

Create a Diagnostic Setting AZ Storage

Diagnostic Setting Az Storage

Azure Key Vault

Navigate to Azure Key Vault > Create a Key Vault or use one you already have, just make sure it is in the same resource group as the other resources. Name must be globally unique.

Create a key vault

Create a key vault - Change Access

Create a Diagnostic Setting for LAW

Create Diagnostic Setting in AKV

Diagnostic Setting AKV

Next, generate some logs by creating a few secrets and viewing them.

Create secrets in AKV for Logs

Create secrets in AKV for Logs

Secrets Overview in AKV

Query LAW to make sure logs are flowing from resources:

Confirm logs in LAW

Configure Microsoft Sentinel

World Attack Maps Construction

This is the point where we can create attack maps for the following use cases:

  • Failed Authentication in Windows (RDP/SMB)
  • Failed Authentication in Linux (SSH)
  • Failed Authentication to the Microsoft SQL Server
  • Malicious Flows to the Network Security Groups

Go to Microsoft Sentinel > Workbooks > Add Workbook > Edit > Delete default analytics query > Add query > Advanced Editor > Add json query here > Save and name workbook.

Sentinel After Workbooks Creation

If you want to test the query, to see if events will be plotted on the map. Exit the Advanced Editor and grab the query from the main Edit page, then use it to query the logs in LAW.

For example, this is the query from the Microsoft SQL Server failed authentication workbook in LAW:

MSSQL Failed Auth in LAW

By doing this, you can test changes to the query and make sure it works and is generating desired results before updating the workbooks in Sentinel.

Analytics, Alerting and Incident Generation

Manual Alert Creation

Here we're using KQL queries to trigger alerts and spin up incidents in Microsoft Sentinel.

Sentinel > Analytics > Create scheduled query rule

Create Alerts in Sentinel

Analytics Rule Wizard Part 1

Analytics Rule Wizard Part 2

Analytics Rule Wizard Part 3

Analytics Rule Wizard Part 4

Attack Traffic Generation (Simulated Attacks)

To test your alerts and incidents rule configuration, simulate some attacks on the VMs and see if they show up in Sentinel (generate alerts and incidents). We have to make sure these work before the first observation period. Here are some tests to run:

  • Trigger AAD Brute Force Success: Simulate brute force success against Azure AD with your attacker account (from attack-vm). Either use PowerShell or an incognito window to fail 10-11 consecutive logins, followed by one successful login.
  • rigger MSSQL Brute Force Attempt: Using the attack-vm, use PowerShell of SSMS to simulate brute force attempt against your SQL Server by failing 10-11 consecutive logins.
  • Trigger Malware Outbreak: In windows-vm generate a malware alert by using PowerShell to create 1 or more EICAR files. You can also do this manually by creating a text file with an EICAR string in it.
  • Trigger Possible Privilege Escalation (AKV Critical Credential Retrieval or Update): Manually read Key Vault Secret “Tenant-Global-Admin-Password” in the Azure portal.
  • Trigger Windows Host Firewall Tampering: Manually Enable and Disable the windows-vm Firewall.
  • Trigger Excessive Password Resets: Reset a users’ password in the Azure portal 10-11 times.

After each attach, wait 10-20 minutes, then check Sentinel to see if you have any incidents. This can also help you with incident investigation later on in the lab.

Incidents in Sentinel after simulating some attacks:

Test Traffic in Sentinel

Run Insecure Environment (24H)

The following table shows the measurements taken from the insecure environment after the initial 24 hour observation period:

Metrics - Before Securing Environment

Start Time: 1/18/2024 15:44
Stop Time: 1/19/2024 15:44

Metric Count
Security Events (Windows VMs) 29005
Syslog (Linux VMs) 16562
SecurityAlert (Microsoft Defender for Cloud) 4
SecurityIncident (Sentinel Incidents) 204
NSG Inbound Malicious Flows Allowed 2837

Attack Maps Before Hardening / Security

Before taking the screenshots, the workbooks need to be edited to only show the last 24 hours. The query runs over the last 30 days by default.

To edit the maps:

Generate Maps 1

Generate Maps 2

Generate Maps 3

Generate Maps 4

NSG Allowed Malicious Inbound Flows

NSG Allowed Inbound Malicious Flows

Linux SSH Authentication Failures

Linux Syslog Auth Fail

Windows RDP/SMB Authentication Failures

Windows RDP/SMB Auth Fail

MS SQL Server Authentication Failures

MSSQL Server Auth Fail