-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCustom.Windows.DataAccess.yaml
More file actions
509 lines (441 loc) · 21.3 KB
/
Custom.Windows.DataAccess.yaml
File metadata and controls
509 lines (441 loc) · 21.3 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
name: Custom.Windows.DataAccess
author: Phalgun Kulkarni and Kostya Ilioukevitch
description: |
This artifact combines a variety of data access artifacts and provides normalized results that can be used for data access report generation.
It also enhances investigations by saving the time used to normalize and filter useful information from multiple sources.
Please note: Execute `Server.Import.ArtifactExchange` and `Server.Import.Extras` in Servers Artifact before importing/creating this artifact.
The following data access sources are included within the artifact:
- `LNK` (shortcut) files
- `Jumplists`
- `Shellbags`
- `MRU` (Most Recently Used files and directories)
- `Local files` accessed via Browsers
- `WinScp Registry Key` consisting of paths traversed<br />
We provide two options for parsing LNK, JumpLists, ShellBags, and Browsers:
- Using `built-in` artifacts
- Using `third-party` tools
We use built-in artifacts by default but if you wish to use third-party tools, please note the following:
- For `LNK`, `JumpLists`, and `Shellbags`, we are using Zimmerman tools (LECmd, JLECmd, and SBECmd respectively), we recommended that you upload `.NET version 4` binaries in the tools section to avoid potential issues regarding unavailablity of .NET version 6 or 9 on endpoints.
- For `Browsers`, we are using Nirsoft's BrowsingHistoryView64, which is often tagged as **`MALWARE`** by Endpoint Detection and Response tools - `this may cause alerts`.
- Please upload tools **(.exe and not .zip files)** and set the setting to serve locally to avoid issues regarding internet access.
We have **disabled** `MRU` parsing by default as it often contains duplicate data.
Artifacts used as inspiration or wrapper:
- Windows.Forensics.Lnk
- Windows.Applications.LECmd
- Windows.Forensics.JumpLists
- Windows.Applications.JLECmd
- Windows.Forensics.Shellbags
- Windows.Applications.SBECmd
- Windows.Applications.NirsoftBrowserViewer
- Generic.Forensic.SQLiteHunter
- Windows.Registry.NTUser
- Windows.Registry.RecentDocs
tools:
- name: LECmd
- name: JLECmd
- name: SBECmd
- name: NirsoftBrowsingHistoryView64
type: CLIENT
parameters:
- name: UserAccountRegex
description: Regex to only include events tied to specific users
type: regex
default: .
- name: DateAfter
type: timestamp
description: Search for events after this date. YYYY-MM-DDTmm:hh:ssZ
- name: DateBefore
type: timestamp
description: Search for events before this date. YYYY-MM-DDTmm:hh:ssZ
- name: UseBuiltInArtifacts
type: bool
default: Y
description: Checked by default, runs built-in artifacts instead of using third-party tools
- name: RecentDocsMRU
type: bool
default: N
description: If checked, runs Windows.Registry.RecentDocs artifact
- name: BrowserAccessNirsoft
type: bool
default: N
description: If checked, runs Nirsoft's BrowsingHistoryView. **NOTE - The binary is often flagged by EDRs as `malicious` and may cause alerts**
precondition: SELECT OS From info() where OS = 'windows'
sources:
- name: LNK
description: Parses Windows LNK or Shortcut files to extract evidence of data access.
query: |
LET hostname <= SELECT Hostname
FROM info()
LET DateAfterTime <= if(condition=DateAfter,
then=timestamp(epoch=DateAfter),
else=timestamp(epoch="1600-01-01"))
LET DateBeforeTime <= if(condition=DateBefore,
then=timestamp(epoch=DateBefore),
else=timestamp(epoch="2200-01-01"))
LET tmpdir <= tempdir()
SELECT *
FROM if(condition=UseBuiltInArtifacts,
then={
SELECT SourceFile.Mtime AS EventTime,
hostname[0].Hostname AS Host,
split(string=SourceFile.OSPath, sep="\\\\")[2] AS UserAccount,
if(condition=StringData.TargetPath,
then=StringData.TargetPath,
else=LinkTarget.LinkTarget) AS Path,
ShellLinkHeader.FileSize AS FileSize,
"LNK" AS Artifact,
"File_Modification" AS Time_Type,
SourceFile.OSPath AS ArtifactSource,
ExtraData AS Additional_Info
FROM Artifact.Windows.Forensics.Lnk()
},
else={
SELECT *
FROM chain(a={SELECT * FROM foreach(row={SELECT OSPath FROM Artifact.Generic.Utils.FetchBinary(ToolName="LECmd", IsExecutable=FALSE)
},
query={SELECT * FROM execve(argv=[OSPath, "-d", "C:\\", "--csv",
tmpdir + "lecmd", "--csvf", "results.csv"])
})},
b={SELECT SourceModified AS EventTime,
hostname[0].Hostname AS Host,
split(string=SourceFile, sep="\\\\")[2] AS UserAccount,
if(condition=LocalPath, then=LocalPath, else=RelativePath) AS Path,
FileSize,
"LNK" AS Artifact,
"File_Modification" AS Time_Type,
SourceFile AS ArtifactSource,
dict(`SourceCreated`=SourceCreated,
`WorkingDirectory`=WorkingDirectory,
`RelativePath`=RelativePath,
`Arguments`=Arguments) AS Additional_Info
FROM parse_csv(filename=tmpdir + "lecmd" + "\\results.csv")
})
})
WHERE UserAccount =~ UserAccountRegex
AND EventTime > DateAfterTime
AND EventTime < DateBeforeTime
notebook:
- type: md
template: |
# Master Data Access Sheet
- type: vql
name: Master Data Access Workbook
template: |
SELECT *
FROM chain(a={
SELECT *
FROM source(artifact="Custom.Windows.DataAccess/LNK")
LIMIT 50
}, b={
SELECT *
FROM source(artifact="Custom.Windows.DataAccess/Jumplists")
LIMIT 50
}, c={
SELECT *
FROM source(artifact="Custom.Windows.DataAccess/Shellbags")
LIMIT 50
}, d={
SELECT *
FROM source(artifact="Custom.Windows.DataAccess/Browser Access Nirsoft")
LIMIT 50
}, e={
SELECT *
FROM source(artifact="Custom.Windows.DataAccess/Browser Access SQLiteHunter")
LIMIT 50
}, f={
SELECT *
FROM source(artifact="Custom.Windows.DataAccess/WinSCP Remote Path")
LIMIT 50
}, g={
SELECT *
FROM source(artifact="Custom.Windows.DataAccess/MRU")
LIMIT 50
})
- type: md
template: |
# Custom.Windows.DataAccess/LNK
- type: vql
template: |
SELECT *
FROM source(artifact="Custom.Windows.DataAccess/LNK")
LIMIT 50
- name: Jumplists
description: Parses Windows Jumpliists or automaticdestinations and customdestinations `(only with JLECmd)` files to extract evidence of data access.
query: |
LET hostname <= SELECT Hostname
FROM info()
LET DateAfterTime <= if(condition=DateAfter,
then=timestamp(epoch=DateAfter),
else=timestamp(epoch="1600-01-01"))
LET DateBeforeTime <= if(condition=DateBefore,
then=timestamp(epoch=DateBefore),
else=timestamp(epoch="2200-01-01"))
LET tmpdir <= tempdir()
LET x = scope()
SELECT *
FROM if(condition=UseBuiltInArtifacts,
then={
SELECT WriteTime AS EventTime,
hostname[0].Hostname AS Host,
split(string=AutomaticDestinationsPath, sep="\\\\")[2] AS UserAccount,
LinkTarget AS Path,
FileSize,
"Jumplists" AS Artifact,
"File_Modification" AS Time_Type,
AutomaticDestinationsPath AS ArtifactSource,
dict(`Application`=Application,
`ApplicationId`=ApplicationId,
`CreationTime`=CreationTime) AS Additional_Info
FROM Artifact.Windows.Forensics.JumpLists()
},
else={
SELECT *
FROM chain(a={SELECT * FROM foreach(row={SELECT OSPath FROM Artifact.Generic.Utils.FetchBinary(ToolName="JLECmd",IsExecutable=FALSE)
},
query={SELECT * FROM execve(argv=[OSPath, "-d", "C:\\", "--fd", "--csv",
tmpdir, "--csvf", "results.csv"])
})},
b={SELECT * FROM foreach(row={SELECT OSPath FROM glob(globs="results_*.csv", root=tmpdir)
},
query={SELECT x.SourceModified AS EventTime,
hostname[0].Hostname AS Host,
split(string=x.SourceFile, sep="\\\\")[2] AS UserAccount,
if(condition=x.LocalPath, then=x.LocalPath, else=x.Path) AS Path,
x.FileSize AS FileSize,
"Jumplists" AS Artifact,
"File_Modification" AS Time_Type,
x.SourceFile AS ArtifactSource,
dict(`x.SourceCreated`=SourceCreated,
`x.AppIdDescription`=AppIdDescription,
`x.TargetIDAbsolutePath`=TargetIDAbsolutePath,
`x.RelativePath`=RelativePath,
`x.Arguments`=Arguments) AS Additional_Info
FROM parse_csv(filename=OSPath)
})
})
})
WHERE UserAccount =~ UserAccountRegex
AND EventTime > DateAfterTime
AND EventTime < DateBeforeTime
- name: Shellbags
description: Parses Windows Shellbags to extract evidence of data access.
query: |
LET hostname <= SELECT Hostname
FROM info()
LET DateAfterTime <= if(condition=DateAfter,
then=timestamp(epoch=DateAfter),
else=timestamp(epoch="1600-01-01"))
LET DateBeforeTime <= if(condition=DateBefore,
then=timestamp(epoch=DateBefore),
else=timestamp(epoch="2200-01-01"))
LET tempfolder <= tempdir()
LET UserProfiles <= SELECT Uid,
Name,
Directory,
UUID,
Mtime
FROM Artifact.Windows.Sys.Users()
SELECT *
FROM if(condition=UseBuiltInArtifacts,
then={
SELECT ModTime AS EventTime,
hostname[0].Hostname AS Host,
split(string=Hive, sep="\\\\")[2] AS UserAccount,
regex_replace(source=FullPath, replace="\\", re=" -> ") AS Path,
"N/A" AS FileSize,
"Shellbags" AS Artifact,
"Key_Modification" AS Time_Type,
Hive AS ArtifactSource,
Description AS Additional_Info
FROM Artifact.Windows.Forensics.Shellbags()
},
else={SELECT * FROM
chain(a={SELECT * FROM foreach(row={SELECT OSPath FROM Artifact.Generic.Utils.FetchBinary(ToolName="SBECmd", IsExecutable=TRUE)},
query={SELECT * FROM foreach(row=UserProfiles,
query={SELECT *, Name FROM execve(argv=[OSPath, "-d", Directory, "--csv",
tempfolder + "\\" + Name, "--dedupe"])}
)})}
,
b={SELECT * FROM foreach(row={SELECT OSPath FROM glob(globs="**\\Deduplicated.csv", root=tempfolder)
},
query={SELECT if(condition=LastInteracted,
then=LastInteracted,
else=LastWriteTime) AS EventTime,
hostname[0].Hostname AS Host,
split(string=OSPath, sep="\\\\")[5] AS UserAccount,
AbsolutePath AS Path,
"N/A" AS FileSize,
"Shellbags" AS Artifact,
"Key_Modification" AS Time_Type,
SourceFile AS ArtifactSource,
dict(`Value`=Value,
`ChildBags`=ChildBags,
`CreatedOn`=CreatedOn,
`ModifiedOn`=ModifiedOn,
`FirstInteracted`=FirstInteracted,
`MRUPosition`=MRUPosition,
`HasExplored`=HasExplored) AS Additional_Info
FROM parse_csv(filename=OSPath)
})}
)}
)
WHERE UserAccount =~ UserAccountRegex
AND EventTime > DateAfterTime
AND EventTime < DateBeforeTime
- name: Browser Access Nirsoft
description: Parses Windows Browsers to extract evidence of local data access via Nirsoft's NirsoftBrowserViewer.
query: |
LET hostname <= SELECT Hostname
FROM info()
LET DateAfterTime <= if(condition=DateAfter,
then=timestamp(epoch=DateAfter),
else=timestamp(epoch="1600-01-01"))
LET DateBeforeTime <= if(condition=DateBefore,
then=timestamp(epoch=DateBefore),
else=timestamp(epoch="2200-01-01"))
SELECT *
FROM if(condition=BrowserAccessNirsoft,
then={
SELECT timestamp_format(time=`Visit Time`, format="RFC3339") AS EventTime,
hostname[0].Hostname AS Host,
`User Profile` AS UserAccount,
if(condition=URL =~ "file:///",
then=split(string=URL, sep_string="file:///")[1]) AS Path,
'N/A' AS FileSize,
`Web Brower` + "Access" AS Artifact,
"Visit Time" AS Time_Type,
`History File` AS ArtifactSource,
dict(`Visit Count`=`Visit Count`,
`Visit Type`=`Visit Type`,
`Visit Duration`=`Visit Duration`) AS Additional_Info
FROM Artifact.Windows.Applications.NirsoftBrowserViewer(PARSE_TZ='GMT')
})
WHERE UserAccount =~ UserAccountRegex
AND EventTime > DateAfterTime
AND EventTime < DateBeforeTime
AND Path =~ ".+"
- name: Browser Access SQLiteHunter
description: Parses Windows Browsers to extract evidence of local data access.
query: |
LET hostname <= SELECT Hostname
FROM info()
LET DateAfterTime <= if(condition=DateAfter,
then=timestamp(epoch=DateAfter),
else=timestamp(epoch="1600-01-01"))
LET DateBeforeTime <= if(condition=DateBefore,
then=timestamp(epoch=DateBefore),
else=timestamp(epoch="2200-01-01"))
LET Chromium <= SELECT
VisitTime AS EventTime,
hostname[0].Hostname AS Host,
split(string=OSPath, sep="\\\\")[2] AS UserAccount,
if(condition=URL =~ "file:///",
then=split(string=URL, sep_string="file:///")[1]) AS Path,
'N/A' AS FileSize,
"Chromium Browser access" AS Artifact,
"Visit Time" AS Time_Type,
OSPath AS ArtifactSource,
dict(`VisitCount`=`VisitCount`,
`TypedCount`=`TypedCount`,
`VisitDurationInSeconds`=`VisitDurationInSeconds`,
`Hidden`=`Hidden`) AS Additional_Info
FROM Artifact.Generic.Forensic.SQLiteHunter(
source='Chromium Browser History_Visits')
LET FireFox <= SELECT
LastVisitDate AS EventTime,
hostname[0].Hostname AS Host,
split(string=OSPath, sep="\\\\")[2] AS UserAccount,
if(condition=URL =~ "file:///",
then=split(string=URL, sep_string="file:///")[1]) AS Path,
'N/A' AS FileSize,
"FireFox Browser access" AS Artifact,
"Visit Time" AS Time_Type,
OSPath AS ArtifactSource,
dict(`VisitCount`=`VisitCount`,
`Title`=`Title`,
`Typed`=`Typed`,
`Hidden`=`Hidden`) AS Additional_Info
FROM Artifact.Generic.Forensic.SQLiteHunter(source='Firefox Places_History')
LET Edge <= SELECT
`Last Visited Time` AS EventTime,
hostname[0].Hostname AS Host,
split(string=OSPath, sep="\\\\")[2] AS UserAccount,
if(condition=URL =~ "file:///",
then=split(string=URL, sep_string="file:///")[1]) AS Path,
'N/A' AS FileSize,
"Edge Browser access" AS Artifact,
"Visit Time" AS Time_Type,
OSPath AS ArtifactSource,
dict(`VisitCount`=`VisitCount`, `Title`=`Title`) AS Additional_Info
FROM Artifact.Generic.Forensic.SQLiteHunter(
source='Edge Browser Navigation History_Navigation History')
SELECT *
FROM chain(a={
SELECT *
FROM Chromium
},
b={
SELECT *
FROM FireFox
},
c={
SELECT *
FROM Edge
})
WHERE UserAccount =~ UserAccountRegex
AND EventTime > DateAfterTime
AND EventTime < DateBeforeTime
AND Path =~ ".+"
- name: WinSCP Remote Path
description: Parses WinScp RemoteTarget registry key to extract evidence of data access.
query: |
LET hostname <= SELECT Hostname
FROM info()
LET DateAfterTime <= if(condition=DateAfter,
then=timestamp(epoch=DateAfter),
else=timestamp(epoch="1600-01-01"))
LET DateBeforeTime <= if(condition=DateBefore,
then=timestamp(epoch=DateBefore),
else=timestamp(epoch="2200-01-01"))
SELECT Mtime AS EventTime,
hostname[0].Hostname AS Host,
Username AS UserAccount,
regex_replace(source=Data.value, re='%5C', replace='/') AS Path,
'N/A' AS FileSize,
"WinSCP Remote Path" AS Artifact,
"Key_Modification" AS Time_Type,
OSPath AS ArtifactSource,
dict(Directory=`Directory`) AS Additional_Info
FROM Artifact.Windows.Registry.NTUser(
KeyGlob="Software\\Martin Prikryl\\WinSCP 2\\Configuration\\History\\RemoteTarget\\*")
WHERE UserAccount =~ UserAccountRegex
AND EventTime > DateAfterTime
AND EventTime < DateBeforeTime
- name: MRU
description: Parses RecentDocs registry keys to extract evidence of data access.
query: |
LET hostname <= SELECT Hostname
FROM info()
LET DateAfterTime <= if(condition=DateAfter,
then=timestamp(epoch=DateAfter),
else=timestamp(epoch="1600-01-01"))
LET DateBeforeTime <= if(condition=DateBefore,
then=timestamp(epoch=DateBefore),
else=timestamp(epoch="2200-01-01"))
SELECT *
FROM if(condition=RecentDocsMRU,
then={
SELECT LastWriteTime AS EventTime,
hostname[0].Hostname AS Host,
Username AS UserAccount,
MruEntries AS Path,
'N/A' AS FileSize,
"MRU" AS Artifact,
"Key_Modification" AS Time_Type,
HiveName AS ArtifactSource,
dict(Key=`Key`, UUID=`UUID`) AS Additional_Info
FROM Artifact.Windows.Registry.RecentDocs()
})
WHERE UserAccount =~ UserAccountRegex
AND EventTime > DateAfterTime
AND EventTime < DateBeforeTime