forked from SEVENP/Sentinel-Queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDevice-ProcessModifiedPrimaryToken.kql
43 lines (42 loc) · 1.77 KB
/
Device-ProcessModifiedPrimaryToken.kql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//Find when a process modifies the primary access token and parse the relevant details such as any privilege attached to the token, whether it is system level and the token integrity level
//Microsoft Sentinel query
DeviceEvents
| where TimeGenerated > ago(30m)
| project
DeviceName,
ActionType,
AdditionalFields,
TimeGenerated,
InitiatingProcessParentFileName,
InitiatingProcessCommandLine
| where ActionType == "ProcessPrimaryTokenModified"
| extend TokenModificationProperties = AdditionalFields.TokenModificationProperties
| where isnotempty(TokenModificationProperties)
| parse TokenModificationProperties with * 'tokenChangeDescription":"' ['Token Change Description'] '","privilegesFlags":' ['Token Privileges'] ',"isChangedToSystemToken":' ['is Changed to System Token'] ',"originalTokenIntegrityLevelName":"' ['Original Token Level'] '","currentTokenIntegrityLevelName":"' ['Current Token Level'] '"' *
| project
TimeGenerated,
DeviceName,
InitiatingProcessParentFileName,
InitiatingProcessCommandLine,
['Original Token Level'],
['Current Token Level'],
['Token Privileges'],
['is Changed to System Token'],
['Token Change Description']
//Advanced Hunting query
DeviceEvents
| where Timestamp > ago(30m)
| project
DeviceName,
ActionType,
AdditionalFields,
Timestamp,
InitiatingProcessParentFileName,
InitiatingProcessCommandLine
| where ActionType == "ProcessPrimaryTokenModified"
| extend AF = parse_json(AdditionalFields)
| extend OriginalTokenLevel = AF.OriginalTokenIntegrityLevel
| extend OriginalTokenPriv = AF.OriginalTokenPrivEnabled
| extend CurrentTokenLevel = AF.CurrentTokenIntegrityLevel
| extend CurrentTokenPriv = AF.CurrentTokenPrivEnabled
| extend TokenModification = AF.TokenModificationProperties