| 1 |
# Artifact definition format and style guide |
| 2 |
|
| 3 |
The best way to show what an artifact definition is, is by example. The |
| 4 |
following example is the artifact definition for the Windows EVTX System Event |
| 5 |
Logs. |
| 6 |
|
| 7 |
```yaml |
| 8 |
name: WindowsSystemEventLogEvtx |
| 9 |
doc: Windows System Event log for Vista or later systems. |
| 10 |
sources: |
| 11 |
- type: FILE |
| 12 |
attributes: {paths: ['%%environ_systemroot%%\System32\winevt\Logs\System.evtx']} |
| 13 |
supported_os: [Windows] |
| 14 |
urls: ['https://artifacts-kb.readthedocs.io/en/latest/sources/windows/EventLog.html'] |
| 15 |
``` |
| 16 |
|
| 17 |
The artifact definition can have the following values: |
| 18 |
|
| 19 |
Value | Description |
| 20 |
--- | --- |
| 21 |
aliases | Optional list of alternate names to identify the artifact definition. Also see: See section: [Name](#name). |
| 22 |
doc | The description (or documentation). A human readable string that describes the artifact definition. See section: [Description](#description). |
| 23 |
name | The name. An unique string that identifies the artifact definition. See section: [Name](#name). |
| 24 |
provides | Optional list of *TODO* |
| 25 |
sources | A list of source definitions. See section: [Sources](#sources). |
| 26 |
supported_os | Optional list that indicates which operating systems the artifact definition applies to. See section: [Supported operating system](#supported-operating-system). |
| 27 |
urls | Optional list of URLs with more contextual information. Ideally the artifact definition links to an article that discusses the artifact in more depth for example on [Digital Forensics Artifact Knowledge Base](https://github.com/ForensicArtifacts/artifacts-kb). |
| 28 |
|
| 29 |
## Deprecated values |
| 30 |
|
| 31 |
Value | Description |
| 32 |
--- | --- |
| 33 |
conditions | Optional list of conditions that describe when the artifact definition should apply. Note that conditions have been deprecated as of version 20220710. |
| 34 |
labels | Optional list of predefined labels. Note that labels have been deprecated as of version 20220311. |
| 35 |
|
| 36 |
## Name |
| 37 |
|
| 38 |
The name of an artifact definition should be in CamelCase name without spaces. |
| 39 |
|
| 40 |
Prefix platform specific artifact definitions with the name of the operating |
| 41 |
system using "Linux", "MacOS" or "Windows". |
| 42 |
|
| 43 |
If not platform specific: |
| 44 |
|
| 45 |
* prefix with the application name, for example "ChromeHistory". |
| 46 |
* prefix with the name of the subsystem, for example "WMIComputerSystemProduct". |
| 47 |
|
| 48 |
Commonly used prefixes: |
| 49 |
|
| 50 |
Prefix | Description |
| 51 |
--- | --- |
| 52 |
Darwin | Mac OS (or Darwin) operating system specific artifact definition. |
| 53 |
Linux | Linux operating system specific artifact definition. |
| 54 |
Shell | Shell user-interface specific artifact definition. |
| 55 |
User | User specific artifact definition. |
| 56 |
Unix | Unix operating system (or POSIX) specific artifact definition. |
| 57 |
Windows | Windows operating system specific artifact definition. |
| 58 |
|
| 59 |
Suffix artifact definitions with the type of artifact, for example are files use |
| 60 |
"BrowserHistoryFile" instead of "BrowserHistory" to reduce ambiguity. |
| 61 |
|
| 62 |
Suffix | Description |
| 63 |
--- | --- |
| 64 |
ConfigurationFile | Contents of one or more configuration files. |
| 65 |
Directory | Contents of one or more directories. |
| 66 |
File | Contents of one or more files. |
| 67 |
LogFile | Contents of one or more log files. |
| 68 |
PlistFile | Contents of one or more property list (plist) files. |
| 69 |
SQLiteDatabaseFile | Contents of one or more SQLite database files. |
| 70 |
|
| 71 |
## Description |
| 72 |
|
| 73 |
**Style note**: Typically one line description of the artifact, mentioning |
| 74 |
important caveats. If more than one line is necessary, use the multi-line YAML |
| 75 |
Literal Style as indicated by the `|` character. |
| 76 |
|
| 77 |
```yaml |
| 78 |
doc: | |
| 79 |
The Windows run keys. |
| 80 |
|
| 81 |
Note users.sid will currently only expand to SIDs with profiles on the system, |
| 82 |
not all SIDs. |
| 83 |
``` |
| 84 |
|
| 85 |
**Style note**: the short description (first line) and the longer portion are |
| 86 |
separated by an empty line. |
| 87 |
|
| 88 |
**Style note**: explicit newlines (\n) should not be used. |
| 89 |
|
| 90 |
## Sources |
| 91 |
|
| 92 |
Every source definition starts with a `type` followed by arguments for example: |
| 93 |
|
| 94 |
```yaml |
| 95 |
sources: |
| 96 |
- type: COMMAND |
| 97 |
attributes: |
| 98 |
args: [-qa] |
| 99 |
cmd: /bin/rpm |
| 100 |
``` |
| 101 |
|
| 102 |
```yaml |
| 103 |
sources: |
| 104 |
- type: FILE |
| 105 |
attributes: |
| 106 |
paths: |
| 107 |
- /root/.bashrc |
| 108 |
- /root/.cshrc |
| 109 |
- /root/.ksh |
| 110 |
- /root/.logout |
| 111 |
- /root/.profile |
| 112 |
- /root/.tcsh |
| 113 |
- /root/.zlogin |
| 114 |
- /root/.zlogout |
| 115 |
- /root/.zprofile |
| 116 |
- /root/.zprofile |
| 117 |
``` |
| 118 |
|
| 119 |
**Style note**: where sources take a single argument with a single value, the |
| 120 |
one-line {} form should be used to save on line breaks as below: |
| 121 |
|
| 122 |
```yaml |
| 123 |
- type: FILE |
| 124 |
attributes: {paths: ['%%environ_systemroot%%\System32\winevt\Logs\System.evtx']} |
| 125 |
``` |
| 126 |
|
| 127 |
Value | Description |
| 128 |
--- | --- |
| 129 |
attributes | A dictionary of keyword attributes specific to the type of source definition. |
| 130 |
type | The source type. |
| 131 |
supported_os | Optional list that indicates which operating systems the artifact definition applies to. See section: [Supported operating system](#supported-operating-system). |
| 132 |
|
| 133 |
## Deprecated values |
| 134 |
|
| 135 |
Value | Description |
| 136 |
--- | --- |
| 137 |
conditions | Optional list of conditions to when the artifact definition should apply. See section: Note that conditions have been deprecated as of version 20220710. |
| 138 |
|
| 139 |
### Source types |
| 140 |
|
| 141 |
Currently the following different source types are defined: |
| 142 |
|
| 143 |
Value | Description |
| 144 |
--- | --- |
| 145 |
ARTIFACT_GROUP | A source that consists of a group of other artifacts. |
| 146 |
COMMAND | A source that consists of the output of a command. |
| 147 |
FILE | A source that consists of the contents of files. |
| 148 |
PATH | A source that consists of the contents of paths. |
| 149 |
REGISTRY_KEY | A source that consists of the contents of Windows Registry keys. |
| 150 |
REGISTRY_VALUE | A source that consists of the contents of Windows Registry values. |
| 151 |
WMI | A source that consists of the output of Windows Management Instrumentation (WMI) queries. |
| 152 |
|
| 153 |
The sources types are defined in |
| 154 |
[definitions.py](https://github.com/ForensicArtifacts/artifacts/blob/main/artifacts/definitions.py). |
| 155 |
as TYPE_INDICATOR constants. |
| 156 |
|
| 157 |
### Artifact group source |
| 158 |
|
| 159 |
The artifact group source is a source that consists of a group of other artifacts e.g. |
| 160 |
|
| 161 |
```yaml |
| 162 |
- type: ARTIFACT_GROUP |
| 163 |
attributes: |
| 164 |
names: |
| 165 |
- WindowsRunKeys |
| 166 |
- WindowsServices |
| 167 |
``` |
| 168 |
|
| 169 |
Where `attributes` can contain the following values: |
| 170 |
|
| 171 |
Value | Description |
| 172 |
--- | --- |
| 173 |
names | A list of artifact definition names that make up this "composite" artifact. This can also be used to group multiple artifact definitions into one for convenience. |
| 174 |
|
| 175 |
### Command source |
| 176 |
|
| 177 |
The command source is a source that consists of the output of a command e.g. |
| 178 |
|
| 179 |
```yaml |
| 180 |
- type: COMMAND |
| 181 |
attributes: |
| 182 |
args: [-qa] |
| 183 |
cmd: /bin/rpm |
| 184 |
``` |
| 185 |
|
| 186 |
Where `attributes` can contain the following values: |
| 187 |
|
| 188 |
Value | Description |
| 189 |
--- | --- |
| 190 |
args | A list arguments to pass to the command. |
| 191 |
cmd | The path of the command. |
| 192 |
|
| 193 |
### File source |
| 194 |
|
| 195 |
The file source is a source that consists of the contents of files e.g. |
| 196 |
|
| 197 |
```yaml |
| 198 |
- type: FILE |
| 199 |
attributes: |
| 200 |
paths: ['%%environ_systemroot%%\System32\winevt\Logs\System.evtx'] |
| 201 |
``` |
| 202 |
|
| 203 |
Where `attributes` can contain the following values: |
| 204 |
|
| 205 |
Value | Description |
| 206 |
--- | --- |
| 207 |
paths | A list of file paths that can potentially be collected. The paths can use parameter expansion e.g. `%%environ_systemroot%%`. See section: [Parameter expansion and globs](parameter-expansion-and-globs). |
| 208 |
separator | Optional path segment separator e.g. '\' for Windows systems. When not specified the default path segment separator is '/'. |
| 209 |
|
| 210 |
### Path source |
| 211 |
|
| 212 |
The path source is a source that consists of the contents of paths e.g. |
| 213 |
|
| 214 |
```yaml |
| 215 |
- type: PATH |
| 216 |
attributes: |
| 217 |
paths: ['\Program Files'] |
| 218 |
separator: '\' |
| 219 |
``` |
| 220 |
|
| 221 |
Where `attributes` can contain the following values: |
| 222 |
|
| 223 |
Value | Description |
| 224 |
--- | --- |
| 225 |
paths | A list of file paths that can potentially be collected. The paths can use parameter expansion e.g. `%%environ_systemroot%%`. See section: [Parameter expansion and globs](parameter-expansion-and-globs). |
| 226 |
separator | Optional path segment separator e.g. '\' for Windows systems. When not specified the default path segment separator is '/'. |
| 227 |
|
| 228 |
### Windows Registry key source |
| 229 |
|
| 230 |
The Windows Registry key source is a source that consists of the contents of |
| 231 |
Windows Registry keys e.g. |
| 232 |
|
| 233 |
```yaml |
| 234 |
sources: |
| 235 |
- type: REGISTRY_KEY |
| 236 |
attributes: |
| 237 |
keys: |
| 238 |
- 'HKEY_USERS\%%users.sid%%\Software\Microsoft\Internet Explorer\TypedURLs\*' |
| 239 |
``` |
| 240 |
|
| 241 |
Where `attributes` can contain the following values: |
| 242 |
|
| 243 |
Value | Description |
| 244 |
--- | --- |
| 245 |
keys | A list of Windows Registry key paths that can potentially be collected. The paths can use parameter expansion e.g. `%%users.sid%%`. See section: [Parameter expansion and globs](parameter-expansion-and-globs). |
| 246 |
|
| 247 |
### Windows Registry value source |
| 248 |
|
| 249 |
The Windows Registry value source is a source that consists of the contents of |
| 250 |
Windows Registry values e.g. |
| 251 |
|
| 252 |
```yaml |
| 253 |
- type: REGISTRY_VALUE |
| 254 |
attributes: |
| 255 |
key_value_pairs: |
| 256 |
- {key: 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\WindowsUpdate', value: 'CISCNF4654'} |
| 257 |
``` |
| 258 |
|
| 259 |
Where `attributes` can contain the following values: |
| 260 |
|
| 261 |
Value | Description |
| 262 |
--- | --- |
| 263 |
key_value_pairs | A list of Windows Registry key paths and value names that can potentially be collected. The key path can use parameter expansion e.g. `%%users.sid%%`. See section: [Parameter expansion and globs](parameter-expansion-and-globs). |
| 264 |
|
| 265 |
### Windows Management Instrumentation (WMI) query source |
| 266 |
|
| 267 |
The Windows Management Instrumentation (WMI) query source is a source that |
| 268 |
consists of the output of Windows Management Instrumentation (WMI) queries e.g. |
| 269 |
|
| 270 |
```yaml |
| 271 |
- type: WMI |
| 272 |
attributes: |
| 273 |
query: SELECT * FROM Win32_UserAccount WHERE name='%%users.username%%' |
| 274 |
``` |
| 275 |
|
| 276 |
Where `attributes` can contain the following values: |
| 277 |
|
| 278 |
Value | Description |
| 279 |
--- | --- |
| 280 |
base_object | Optional WMI base object e.g. `winmgmts:\root\SecurityCenter2` |
| 281 |
query | The Windows Management Instrumentation (WMI) query. The query can use parameter expansion e.g. `%%users.username%%`. See section: [Parameter expansion and globs](parameter-expansion-and-globs). |
| 282 |
|
| 283 |
## Supported operating system |
| 284 |
|
| 285 |
Since operating system (OS) are a very common constraint, this has been provided |
| 286 |
as a separate option "supported_os" to simplify syntax. For supported_os no |
| 287 |
quotes are required. The currently supported operating systems are: |
| 288 |
|
| 289 |
* Darwin (also used for Mac OS X) |
| 290 |
* Linux |
| 291 |
* Windows |
| 292 |
|
| 293 |
```yaml |
| 294 |
supported_os: [Darwin, Linux, Windows] |
| 295 |
``` |
| 296 |
|
| 297 |
This can be translated to objectfilter as: |
| 298 |
|
| 299 |
```yaml |
| 300 |
["os =='Darwin'" OR "os=='Linux'" OR "os == 'Windows'"] |
| 301 |
``` |
| 302 |
|
| 303 |
## Parameter expansion and globs |
| 304 |
|
| 305 |
Artifact definitions can use different types of parameters that need to be |
| 306 |
expanded at runtime, such as: |
| 307 |
|
| 308 |
* POSIX users variables, for example %%users.homedir%% |
| 309 |
* Windows evironment variables, for example %%environ_systemroot%% |
| 310 |
* Windows users variables, for example %%users.temp%% |
| 311 |
|
| 312 |
### POSIX users variables |
| 313 |
|
| 314 |
Supported POSIX users variables are: |
| 315 |
|
| 316 |
Variable | Description |
| 317 |
--- | --- |
| 318 |
%%users.homedir%% | A user's home directory, for example '/home/username', '/root' or '/Users/username' |
| 319 |
|
| 320 |
#### Decomposition rules |
| 321 |
|
| 322 |
Note that the following decomposition rules are approximations based on |
| 323 |
common usage scenarios. |
| 324 |
|
| 325 |
%%users.homedir%% can be decomposed into: |
| 326 |
|
| 327 |
* '/Users/*' for Mac OS |
| 328 |
* '/home/*' and '/root' for Linux |
| 329 |
|
| 330 |
### Windows evironment variables |
| 331 |
|
| 332 |
Supported Windows evironment variables are: |
| 333 |
|
| 334 |
Variable | Description |
| 335 |
--- | --- |
| 336 |
%%environ_allusersappdata%% | The %AllUsersAppData% environment variable, which should fallback to the %ProgramData% environment variable if not available. |
| 337 |
%%environ_allusersprofile%% | The %AllUsersProfile% environment variable. |
| 338 |
%%environ_programdata%% | The %ProgramData% environment variable, which should fallback to the %AllUsersAppData% environment variable or '%AllUsersProfile%\\Application Data' if not available. |
| 339 |
%%environ_programfiles%% | The %ProgramFiles% environment variable. |
| 340 |
%%environ_programfilesx86%% | The %ProgramFiles(x86)% environment variable. |
| 341 |
%%environ_systemdrive%% | The %SystemDrive% environment variable, for example 'C:' |
| 342 |
%%environ_systemroot%% | The %SystemRoot% environment variable, for example 'C:\\Windows' |
| 343 |
%%environ_windir%% | The %WinDir% environment variable, for example 'C:\\Windows' |
| 344 |
|
| 345 |
### Windows users variables |
| 346 |
|
| 347 |
Supported Windows users variables are: |
| 348 |
|
| 349 |
Variable | Description |
| 350 |
--- | --- |
| 351 |
%%users.appdata%% | Windows version independent representation of a user specific %AppData% environment variable. |
| 352 |
%%users.localappdata%% | Windows version independent representation of a user specific %LocalAppData% environment variable. |
| 353 |
%%users.sid%% | A user's security identifier (SID) |
| 354 |
%%users.temp%% | A user's temporary files directory, comparable to the %TEMP% or %TMP% environment variables, for example '/Users/username/temp' |
| 355 |
%%users.username%% | A user's username, comparable to the %USERNAME% environment variable |
| 356 |
%%users.userprofile%% | A user's (local) profile directory, for example '/Users/username' |
| 357 |
|
| 358 |
#### Decomposition rules |
| 359 |
|
| 360 |
**TODO: add information about system accounts** |
| 361 |
|
| 362 |
Note that the following decomposition rules are approximations based on |
| 363 |
common usage scenarios. |
| 364 |
|
| 365 |
%%users.appdata%% can be decomposed into: |
| 366 |
|
| 367 |
* '%%users.userprofile%%\\AppData\\Roaming' for Windows Vista and later |
| 368 |
* '%%users.userprofile%%\\Application Data' |
| 369 |
|
| 370 |
%%users.localappdata%% can be decomposed into: |
| 371 |
|
| 372 |
* '%%users.userprofile%%\\AppData\\Local' for Windows Vista and later |
| 373 |
* '%%users.userprofile%%\\Local Settings\\Application Data' |
| 374 |
|
| 375 |
%%users.localappdata_low%% can be decomposed into: |
| 376 |
|
| 377 |
* '%%users.userprofile%%\\AppData\\LocalLow' for Windows Vista and later |
| 378 |
|
| 379 |
%%users.temp%% can be decomposed into: |
| 380 |
|
| 381 |
* '%%users.localappdata%%\\Temp' |
| 382 |
|
| 383 |
%%users.userprofile%% can be decomposed into: |
| 384 |
|
| 385 |
* 'Documents and Settings\\*' |
| 386 |
* 'Users\\*' for Windows Vista and later |
| 387 |
|
| 388 |
## Additional style notes |
| 389 |
|
| 390 |
### Artifact definition YAML files |
| 391 |
|
| 392 |
Artifact definition YAML filenames should be of the form: |
| 393 |
|
| 394 |
``` |
| 395 |
$FILENAME.yaml |
| 396 |
``` |
| 397 |
|
| 398 |
Where $FILENAME is name of the file e.g. windows.yaml. |
| 399 |
|
| 400 |
Each definition file should have a comment at the top of the file with a |
| 401 |
one-line summary describing the type of artifact definitions contained in the |
| 402 |
file e.g. |
| 403 |
|
| 404 |
```yaml |
| 405 |
# Windows specific artifacts. |
| 406 |
``` |
| 407 |
|
| 408 |
### Lists |
| 409 |
|
| 410 |
Generally use the short `[]` format for single-item lists that fit inside 80 |
| 411 |
characters to save on unnecessary line breaks: |
| 412 |
|
| 413 |
```yaml |
| 414 |
supported_os: [Windows] |
| 415 |
urls: ['https://artifacts-kb.readthedocs.io/en/latest/sources/windows/EventLog.html'] |
| 416 |
``` |
| 417 |
|
| 418 |
and the bulleted list form for multi-item lists or long lines: |
| 419 |
|
| 420 |
```yaml |
| 421 |
paths: |
| 422 |
- 'HKEY_USERS\%%users.sid%%\Software\Microsoft\Windows\CurrentVersion\Run\*' |
| 423 |
- 'HKEY_USERS\%%users.sid%%\Software\Microsoft\Windows\CurrentVersion\RunOnce\*' |
| 424 |
- 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\*' |
| 425 |
- 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce\*' |
| 426 |
- 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnceEx\*' |
| 427 |
``` |
| 428 |
|
| 429 |
### Quotes |
| 430 |
|
| 431 |
Quotes should not be used for doc strings, artifact names, and simple lists |
| 432 |
like supported_os. |
| 433 |
|
| 434 |
Paths and URLs should use single quotes to avoid the need for manual escaping. |
| 435 |
|
| 436 |
```yaml |
| 437 |
paths: ['%%environ_temp%%\*.exe'] |
| 438 |
urls: ['https://artifacts-kb.readthedocs.io/en/latest/sources/windows/EventLog.html'] |
| 439 |
``` |
| 440 |
|
| 441 |
Double quotes should be used where escaping causes problems, such as |
| 442 |
regular expressions: |
| 443 |
|
| 444 |
```yaml |
| 445 |
content_regex_list: ["^%%users.username%%:[^:]*\n"] |
| 446 |
``` |
| 447 |
|
| 448 |
### Minimize the number of definitions by using multiple sources |
| 449 |
|
| 450 |
To minimize the number of artifacts in the list, combine them using the |
| 451 |
supported_os attributes where it makes sense. e.g. rather than having |
| 452 |
FirefoxHistoryWindows, FirefoxHistoryLinux, FirefoxHistoryDarwin, do: |
| 453 |
|
| 454 |
```yaml |
| 455 |
name: FirefoxHistory |
| 456 |
doc: Firefox places.sqlite files. |
| 457 |
sources: |
| 458 |
- type: FILE |
| 459 |
attributes: |
| 460 |
paths: |
| 461 |
- %%users.localappdata%%\Mozilla\Firefox\Profiles\*\places.sqlite |
| 462 |
- %%users.appdata%%\Mozilla\Firefox\Profiles\*\places.sqlite |
| 463 |
supported_os: [Windows] |
| 464 |
- type: FILE |
| 465 |
attributes: |
| 466 |
paths: [%%users.homedir%%/Library/Application Support/Firefox/Profiles/*/places.sqlite] |
| 467 |
supported_os: [Darwin] |
| 468 |
- type: FILE |
| 469 |
attributes: |
| 470 |
paths: ['%%users.homedir%%/.mozilla/firefox/*/places.sqlite'] |
| 471 |
supported_os: [Linux] |
| 472 |
supported_os: [Windows, Linux, Darwin] |
| 473 |
``` |
| 474 |
|