Hunting
File Activity
file-activity-audit.kql
Timestamped file activity (open, read, modify, delete, create) by user and device. Written for a client that needed to demonstrate this capability to an auditor.
// Author: Ian D. Hanley (DevSecOpsDad) | linkedin.com/in/ianhanley | devsecopsdad.com | devsecopsdadattack.com
// I wrote this up for a client that needed to prove to an auditor that they could track file activities (open, read, modify, delete, create, etc.) by user and device with timestamps.
union DeviceEvents,DeviceNetworkEvents,DeviceFileEvents //<-- query Device Events, DeviceNetworkEvents, and DeviceFileEvents tables and combine the results.
| where RemoteUrl contains '' or FileOriginUrl != '' or FileOriginReferrerUrl != '' //<-- show me every website URL, file URL, etc. that this user has touched.
| where InitiatingProcessAccountName contains 'InitiatingProcessAccountName' //<-- swap out InitiatingProcessAccountName for a user you want to track activity for, like 'john.smith' for example.
| where ActionType contains "File" and ActionType !contains "Shell"
| summarize count() by InitiatingProcessAccountName,ActionType,FileName,RemoteUrl,FileOriginUrl,FileOriginReferrerUrl, TimeGenerated, DeviceName //<-- Return time-stamped results for each action.
| project-away count_