All Things Computers
4 min readApr 11, 2023

How to use Microsoft Sentinel to Threat Hunt

Threat hunting is the process of proactively searching for malicious activity in your environment. This involves analyzing logs and other data sources to identify potential threats that may have gone unnoticed by other security measures. Microsoft Sentinel is a cloud-native Security Information and Event Management (SIEM) tool that can help you automate and streamline your threat hunting process. In this blog post, we will explore how to create threat hunting queries in Sentinel, along with some examples.

Step 1: Define Your Scope

Before creating a threat hunting query, you need to define the scope of your search. This involves identifying the data sources you want to query, such as logs from a particular application or network traffic from a specific subnet. You should also determine the time range for your search, such as the past week or month.

Step 2: Identify Your Hypotheses

Once you have defined your scope, you need to identify your hypotheses. This involves developing a list of potential threats based on your knowledge of your environment, current threat intelligence, and common attack patterns. For example, you may suspect that a particular system has been compromised or that an attacker is attempting to brute force passwords.

Step 3: Create Your Query

Using the information from steps 1 and 2, you can now create your query in Sentinel. A query is a search expression that matches events based on specific criteria. Sentinel provides a powerful query language called Kusto Query Language (KQL) that enables you to create complex queries.

Let's look at some examples of threat hunting queries in Sentinel.

Example 1: Finding Failed Login Attempts

One common threat is brute force attacks, where an attacker attempts to gain access to a system by guessing passwords. You can use Sentinel to search for failed login attempts that may be indicative of such an attack.

The following query searches for failed login attempts in Windows Security logs:

SecurityEvent
| where EventID == 4625 and AccountType == 'User' and Status == '0xC000006D'
| project TimeGenerated, AccountName, Computer, TargetUserName, TargetDomainName, IPAddress

This query looks for Event ID 4625 in the SecurityEvent table, which indicates a failed login attempt. The query also filters for account types of 'User' and a status of '0xC000006D', which indicates a bad username or password. The query returns the time of the event, the account name, the name of the computer where the event occurred, the name of the target user account, the name of the target domain, and the IP address of the computer where the event occurred.

Example 2: Searching for Suspicious Network Activity

Another common threat is network attacks, where an attacker attempts to exploit vulnerabilities in network services or applications. You can use Sentinel to search for suspicious network activity that may be indicative of such an attack.

The following query searches for connections to a specific port in network logs:

NetworkCommunication
| where DestinationPort == 445
| project TimeGenerated, SourceIP, DestinationIP, DestinationPort, Protocol

This query looks for connections to port 445 in the NetworkCommunication table. Port 445 is commonly used by the SMB protocol, which is often exploited by attackers. The query returns the time of the event, the IP address of the source computer, the IP address of the destination computer, the port number, and the protocol used.

Example 3: Detecting Malware Activity

Malware is another common threat that can be difficult to detect. You can use Sentinel to search for indicators of malware activity, such as suspicious processes or file changes.

The following query searches for processes associated with a known malware family:

DeviceProcessEvents
| where ProcessCommandLine contains "malware_family"
| project TimeGenerated, DeviceName

This query looks for processes in the DeviceProcessEvents table that contain the name of a known malware family in their command line. The query returns the time of the event and the name of the device where the process occurred.

Step 4: Analyze and Refine Your Results

Once you have run your query, you need to analyze the results and refine your search as necessary. This involves looking for patterns and anomalies that may indicate malicious activity. For example, you may notice a high number of failed login attempts from a particular IP address or a spike in network traffic to a specific port.

You can also use Sentinel's built-in visualization tools to help you identify trends and patterns in your data. For example, you can create a timeline view of your search results to see when events occurred over time.

Step 5: Take Action

Finally, once you have identified potential threats, you need to take action to mitigate them. This may involve quarantining an infected device, blocking a suspicious IP address, or patching a vulnerable application.

Threat hunting is an important part of any security strategy, and Microsoft Sentinel provides a powerful platform for automating and streamlining this process. By defining your scope, identifying your hypotheses, creating your query, analyzing and refining your results, and taking action, you can proactively detect and mitigate potential threats in your environment. With practice and experience, you can become an expert threat hunter in Sentinel and stay one step ahead of attackers.

All Things Computers
All Things Computers

Written by All Things Computers

Providing support for software development, data science, AI/Machine Learning, CyberSecurity, threat hunting and hacking.

No responses yet