Skip to content

Commit 9a02481

Browse files
Merge pull request #168 from Amndeep7/yaml
Yaml
2 parents fbb3cfc + 2961ff8 commit 9a02481

File tree

121 files changed

+1332
-1130
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+1332
-1130
lines changed

.github/workflows/lint-yaml.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Lint the yaml
2+
3+
on:
4+
pull_request_target:
5+
push:
6+
branches: [master]
7+
8+
jobs:
9+
yamllint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Pull down repo
13+
uses: actions/checkout@v3
14+
- name: Set up python
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: '3.10'
18+
cache: 'pip'
19+
- name: Install script dependencies
20+
run: pip install -r ./scripts/requirements.txt
21+
- name: Run yamllint
22+
run: yamllint analytics/ data_model/ sensors/
23+
analysis-schema:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Pull down repo
27+
uses: actions/checkout@v3
28+
- name: Set up python
29+
uses: actions/setup-python@v4
30+
with:
31+
python-version: '3.10'
32+
cache: 'pip'
33+
- name: Install script dependencies
34+
run: pip install -r ./scripts/requirements.txt
35+
- name: Validate against analysis schema
36+
run: yamale -s scripts/analytic_schema.yaml --no-strict analytics/
37+
datamodel-schema:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Pull down repo
41+
uses: actions/checkout@v3
42+
- name: Set up python
43+
uses: actions/setup-python@v4
44+
with:
45+
python-version: '3.10'
46+
cache: 'pip'
47+
- name: Install script dependencies
48+
run: pip install -r ./scripts/requirements.txt
49+
- name: Validate against data model schema
50+
run: yamale -s scripts/datamodel_schema.yaml --no-strict data_model/
51+
sensor-schema:
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Pull down repo
55+
uses: actions/checkout@v3
56+
- name: Set up python
57+
uses: actions/setup-python@v4
58+
with:
59+
python-version: '3.10'
60+
cache: 'pip'
61+
- name: Install script dependencies
62+
run: pip install -r ./scripts/requirements.txt
63+
- name: Validate against sensor schema
64+
run: yamale -s scripts/sensor_schema.yaml --no-strict sensors/
65+
filetype-is-yaml:
66+
runs-on: ubuntu-latest
67+
steps:
68+
- name: Pull down repo
69+
uses: actions/checkout@v3
70+
- name: Files should be .yaml not .yml and should also be actual files (ex. not directories)
71+
shell: bash
72+
run: find analytics data_model sensors -mindepth 1 -maxdepth 1 \( ! -name "*.yaml" \) -o \( ! -type f \)
73+
id-filename-equivalence:
74+
runs-on: ubuntu-latest
75+
steps:
76+
- name: Pull down repo
77+
uses: actions/checkout@v3
78+
- name: Analytics files need to have their filename be '{id}.yaml'
79+
run: >
80+
ret=0;
81+
for file in analytics/*.yaml; do
82+
echo "Checking $file";
83+
if ! [ "$(basename $file | sed -e "s/\.yaml$//")" = "$(yq '.id' < $file)" ]; then
84+
echo "Failed";
85+
ret=1;
86+
fi;
87+
done;
88+
exit "$ret"
89+
- name: Data model files need to have their filename be '{name but fully lowercase and with underscores replacing spaces}.yaml'
90+
run: >
91+
ret=0;
92+
for file in data_model/*.yaml; do
93+
echo "Checking $file";
94+
if ! [ "$(basename $file | sed -e "s/\.yaml$//")" = "$(yq '.name | downcase | sub(" ", "_")' < $file)" ]; then
95+
echo "Failed";
96+
ret=1;
97+
fi;
98+
done;
99+
exit "$ret"
100+
- name: Sensor files need to have their filename be '{sensor_name but fully lowercase}_{sensor_version}.yaml'
101+
run: >
102+
ret=0;
103+
for file in sensors/*.yaml; do
104+
echo "Checking $file";
105+
if ! [ "$(basename $file | sed -e "s/\.yaml$//")" = "$(yq '(.sensor_name | downcase) + "_" + .sensor_version' < $file)" ]; then
106+
echo "Failed";
107+
ret=1;
108+
fi;
109+
done;
110+
exit "$ret"

.yamllint

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
extends: default
3+
4+
rules:
5+
line-length: disable

analytics/CAR-2013-01-002.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
title: Autorun Differences
23
submission_date: 2013/01/25
34
information_domain: 'Analytic, Host'
@@ -11,7 +12,7 @@ analytic_types:
1112
contributors:
1213
- MITRE
1314
id: CAR-2013-01-002
14-
description: |-
15+
description: |
1516
The Sysinternals tool [Autoruns](../sensors/autoruns) checks the registry and file system for known identify persistence mechanisms. It will output any tools identified, including built-in or added-on Microsoft functionality and third party software. Many of these locations are known by adversaries and used to obtain [Persistence](https://attack.mitre.org/tactics/TA0003). Running Autoruns periodically in an environment makes it possible to collect and monitor its output for differences, which may include the removal or addition of persistent tools. Depending on the persistence mechanism and location, legitimate software may be more likely to make changes than an adversary tool. Thus, this analytic may result in significant noise in a highly dynamic environment. While Autoruns is a convenient method to scan for programs using persistence mechanisms its scanning nature does not conform well to streaming based analytics. This analytic could be replaced with one that draws from sensors that collect registry and file information if streaming analytics are desired.
1617
1718
Utilizes the Sysinternals autoruns tool (ignoring validated Microsoft entries). Primarily not a detection analytic by itself but through analysis of results by an analyst can be used for such. Building another analytic on top of this one identifying unusual entries would likely be a beneficial alternative.

analytics/CAR-2013-01-003.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
title: SMB Events Monitoring
23
submission_date: 2013/01/25
34
information_domain: Network
@@ -10,8 +11,8 @@ analytic_types:
1011
contributors:
1112
- MITRE
1213
id: CAR-2013-01-003
13-
description: |-
14-
[Server Message Block](https://en.wikipedia.org/wiki/Server_Message Block) (SMB) is used by Windows to allow for file, pipe, and printer sharing over port 445/tcp. It allows for enumerating, and reading from and writing to file shares for a remote computer. Although it is heavily used by Windows servers for legitimate purposes and by users for file and printer sharing, many adversaries also use SMB to achieve [Lateral Movement](https://attack.mitre.org/tactics/TA0008). Looking at this activity more closely to obtain an adequate sense of situational awareness may make it possible to detect adversaries moving between hosts in a way that deviates from normal activity. Because SMB traffic is heavy in many environments, this analytic may be difficult to turn into something that can be used to quickly detect an APT. In some cases, it may make more sense to run this analytic in a forensic fashion. Looking through and filtering its output after an intrusion has been discovered may be helpful in identifying the scope of compromise.
14+
description: |
15+
[Server Message Block](https://en.wikipedia.org/wiki/Server_Message Block) (SMB) is used by Windows to allow for file, pipe, and printer sharing over port 445/tcp. It allows for enumerating, and reading from and writing to file shares for a remote computer. Although it is heavily used by Windows servers for legitimate purposes and by users for file and printer sharing, many adversaries also use SMB to achieve [Lateral Movement](https://attack.mitre.org/tactics/TA0008). Looking at this activity more closely to obtain an adequate sense of situational awareness may make it possible to detect adversaries moving between hosts in a way that deviates from normal activity. Because SMB traffic is heavy in many environments, this analytic may be difficult to turn into something that can be used to quickly detect an APT. In some cases, it may make more sense to run this analytic in a forensic fashion. Looking through and filtering its output after an intrusion has been discovered may be helpful in identifying the scope of compromise.
1516
1617
### Output Description
1718
@@ -28,8 +29,8 @@ coverage:
2829
- T1021.002
2930
coverage: Moderate
3031
implementations:
31-
- description: 'Although there may be more native ways to detect detailed SMB events on the host, they can be extracted out of network traffic. With the right protocol decoders, port 445 traffic can be filtered and even the file path (relative to the share) can be retrieved. '
32-
code: |-
32+
- description: 'Although there may be more native ways to detect detailed SMB events on the host, they can be extracted out of network traffic. With the right protocol decoders, port 445 traffic can be filtered and even the file path (relative to the share) can be retrieved.'
33+
code: |
3334
flow = search Flow:Message
3435
smb_events = filter flow where (dest_port == "445" and protocol == "smb")
3536
smb_events.file_name = smb_events.proto_info.file_name

analytics/CAR-2013-02-003.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
title: Processes Spawning cmd.exe
23
submission_date: 2013/02/05
34
information_domain: Host

analytics/CAR-2013-02-008.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
title: Simultaneous Logins on a Host
23
submission_date: 2013/02/18
34
information_domain: Host
@@ -12,7 +13,7 @@ analytic_types:
1213
contributors:
1314
- MITRE
1415
id: CAR-2013-02-008
15-
description: |-
16+
description: |
1617
Multiple users logged into a single machine at the same time, or even within the same hour, do not typically occur in networks we have observed.
1718
1819
Logon events are Windows Event Code 4624 for Windows Vista and above, 518 for pre-Vista. Logoff events are 4634 for Windows Vista and above, 538 for pre-Vista.
@@ -26,10 +27,10 @@ coverage:
2627
- T1078.003
2728
coverage: Low
2829
implementations:
29-
- code: |-
30+
- code: |
3031
users_list = search UserSession:Login
3132
users_grouped = group users_list by hostname
32-
users_grouped = from users_grouped select min(time) as earliest_time, max(time) as latest_time count(user) as user_count
33+
users_grouped = from users_grouped select min(time) as earliest_time, max(time) as latest_time count(user) as user_count
3334
multiple_logins = filter users_grouped where (latest_time - earliest_time <= 1 hour and user_count > 1)
3435
output multiple_logins
3536
type: pseudocode

analytics/CAR-2013-02-012.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
title: User Logged in to Multiple Hosts
23
submission_date: 2013/02/27
34
information_domain: Host
@@ -12,7 +13,7 @@ analytic_types:
1213
contributors:
1314
- MITRE
1415
id: CAR-2013-02-012
15-
description: |-
16+
description: |
1617
Most users use only one or two machines during the normal course of business. User accounts that log in to multiple machines, especially over a short period of time, may be compromised. Remote logins among multiple machines may be an indicator of [Lateral Movement](https://attack.mitre.org/tactics/TA0008).
1718
1819
Certain users will likely appear as being logged into several machines and may need to be "whitelisted." Such users would include network admins or user names that are common to many hosts.
@@ -25,8 +26,8 @@ coverage:
2526
tactics:
2627
- TA0008
2728
subtechniques:
28-
- T1078.002
29-
- T1078.003
29+
- T1078.002
30+
- T1078.003
3031
coverage: Moderate
3132
d3fend_mappings:
3233
- iri: d3f:AuthenticationEventThresholding

analytics/CAR-2013-03-001.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
title: Reg.exe called from Command Shell
23
submission_date: 2013/03/28
34
information_domain: Host
@@ -10,7 +11,7 @@ analytic_types:
1011
contributors:
1112
- MITRE
1213
id: CAR-2013-03-001
13-
description: |-
14+
description: |
1415
Registry modifications are often essential in establishing persistence via known Windows mechanisms. Many legitimate modifications are done graphically via `regedit.exe` or by using the corresponding channels, or even calling the Registry APIs directly. The built-in utility `reg.exe` provides a [command-line interface](https://en.wikipedia.org/wiki/Command-line_interface) to the registry, so that queries and modifications can be performed from a shell, such as `cmd.exe`. When a user is responsible for these actions, the parent of `cmd.exe` will likely be `explorer.exe`. Occasionally, power users and administrators write scripts that do this behavior as well, but likely from a different process tree. These background scripts must be learned so they can be tuned out accordingly.
1516
1617
### Output Description
@@ -45,15 +46,15 @@ coverage:
4546
coverage: Moderate
4647
implementations:
4748
- description: 'To gain better context, it may be useful to also get information about the cmd process to know its parent. This may be helpful when tuning the analytic to an environment, if this behavior happens frequently. This may also help to rule out instances of users running '
48-
code: |-
49+
code: |
4950
processes = search Process:Create
5051
reg = filter processes where (exe == "reg.exe" and parent_exe == "cmd.exe")
5152
cmd = filter processes where (exe == "cmd.exe" and parent_exe != "explorer.exe"")
5253
reg_and_cmd = join (reg, cmd) where (reg.ppid == cmd.pid and reg.hostname == cmd.hostname)
5354
output reg_and_cmd
5455
type: pseudocode
5556
- description: DNIF version of the above pseudocode.
56-
code: |-
57+
code: |
5758
_fetch * from event where $LogName=WINDOWS-SYSMON AND $EventID=1 AND $Process=regex(.*reg\.exe.*)i AND $ParentProcess=regex(.*cmd\.exe.*)i as #A limit 100
5859
>>_fetch * from event where $LogName=WINDOWS-SYSMON AND $EventID=1 AND $Process=regex(.*cmd\.exe.*)i NOT $ParentProcess=regex(.*explorer\.exe.*)i as #B limit 100
5960
>>_checkif sjoin #B.$PPID = #A.$CPID str_compare #B.$SystemName eq #A.$SystemName include

analytics/CAR-2013-04-002.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
title: Quick execution of a series of suspicious commands
23
submission_date: 2013/04/11
34
information_domain: 'Analytic, Host'

analytics/CAR-2013-05-002.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
title: Suspicious Run Locations
23
submission_date: 2013/05/07
34
information_domain: Host

0 commit comments

Comments
 (0)