Skip to content

Commit 00054ed

Browse files
authored
Merge pull request #3447 from MicrosoftDocs/maccruz-uniqueprocess
Update screenshots and add Linux bit
2 parents e3ad5e0 + b4105ae commit 00054ed

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

defender-xdr/advanced-hunting-best-practices.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ The [join operator](/azure/data-explorer/kusto/query/joinoperator) merges rows f
134134
| join kind=inner (DeviceFileEvents | where Timestamp > ago(1h)) on SHA256
135135
```
136136
137-
- **Use hints for performance**—Use hints with the `join` operator to instruct the backend to distribute load when running resource-intensive operations. [Learn more about join hints](/azure/data-explorer/kusto/query/joinoperator#join-hints)
137+
- **Use hints for performance**—Use hints with the `join` operator to instruct the backend to distribute load when running resource-intensive operations. [Learn more about join hints](/azure/data-explorer/kusto/query/joinoperator#join-hints).
138138
139139
For example, the **[shuffle hint](/azure/data-explorer/kusto/query/shufflequery)** helps improve query performance when joining tables using a key with high cardinality—a key with many unique values—such as the `AccountObjectId` in the query below:
140140
@@ -193,15 +193,24 @@ The [summarize operator](/azure/data-explorer/kusto/query/summarizeoperator) agg
193193
| summarize hint.shufflekey = RecipientEmailAddress count() by Subject, RecipientEmailAddress
194194
```
195195
196-
197-
198196
## Query scenarios
199197
200198
### Identify unique processes with process IDs
201199
202200
Process IDs (PIDs) are recycled in Windows and reused for new processes. On their own, they can't serve as unique identifiers for specific processes.
203201
204-
Usually, the only way to uniquely identify a process on a specific device was by combining its process ID with its process creation time, along with the device identifier (either `DeviceId` or `DeviceName`). While this approach is still valid, there’s a more direct method using the `ProcessUniqueId` field. Both methods yield unique process instances, but as a best practice we recommend using `ProcessUniqueId` when available, as it simplifies queries and eliminates the need to handle PID reuse scenarios.
202+
Typically, the only way to uniquely identify a process on a specific device was by combining its process ID with its process creation time, along with the device identifier (either `DeviceId` or `DeviceName`). For instance, the following example query finds processes that access more than 10 IP addresses over port 445 (SMB), possibly scanning for file shares.
203+
204+
```kusto
205+
DeviceNetworkEvents
206+
| where RemotePort == 445 and Timestamp > ago(12h) and InitiatingProcessId !in (0, 4)
207+
| summarize RemoteIPCount=dcount(RemoteIP) by DeviceName, InitiatingProcessId, InitiatingProcessCreationTime, InitiatingProcessFileName
208+
| where RemoteIPCount > 10
209+
```
210+
211+
The above query summarizes by both `InitiatingProcessId` and `InitiatingProcessCreationTime` so that it looks at a single process, without mixing multiple processes with the same process ID.
212+
213+
This approach is still valid, especially for non-Windows systems. However, in Windows, there’s a more direct method using the `ProcessUniqueId` field. While both the previous method and the one discussed below yield unique process instances, as a best practice we recommend using `ProcessUniqueId` when available, as it simplifies queries and eliminates the need to handle PID reuse scenarios.
205214

206215
This query demonstrates how to use the `ProcessUniqueId` and `InitiatingProcessUniqueId` fields to link a specific parent process to its child processes. By matching each child’s `InitiatingProcessUniqueId` to the parent’s `ProcessUniqueId`, it isolates only those child processes launched by that exact parent instance, even if process IDs get reused over time.
207216

@@ -232,7 +241,9 @@ DeviceProcessEvents
232241
Timestamp
233242
```
234243

235-
The query summarizes by both `InitiatingProcessId` and `InitiatingProcessCreationTime` so that it looks at a single process, without mixing multiple processes with the same process ID.
244+
Likewise, the query summarizes by both `InitiatingProcessId` and `InitiatingProcessCreationTime` so that it looks at a single process, without mixing multiple processes with the same process ID.
245+
246+
:::image type="content" source="/defender-xdr/media/best-practice-unique-processid-tb.png" alt-text="Screenshot of sample query results for getting unique processes in the Microsoft Defender portal." lightbox="/defender-xdr/media/best-practice-unique-processid.png":::
236247

237248
### Query command lines
238249
There are numerous ways to construct a command line to accomplish a task. For example, an attacker could reference an image file without a path, without a file extension, using environment variables, or with quotes. The attacker could also change the order of parameters or add multiple quotes and spaces.
128 KB
Loading
89.2 KB
Loading

0 commit comments

Comments
 (0)