Closed Aegrah closed 1 year ago
Looping through our detection rules:
#!/bin/bash
# Find all files with "discovery" in their name and starting with "discovery_"
file_list=$(find /Users/ruben/Documents/GitHub/detection-rules/ -type f -name "discovery_*" -name "*.toml")
# Loop through the list of files
for file in $file_list; do
# Search for lines starting with "tags = " containing "OS: Windows" recursively
tags_lines=$(grep -R -E '^tags =.*OS: Windows' "$file" 2>/dev/null)
# If any matching lines are found, extract and print the first occurrence of "name" and "rule_id"
if [ -n "$tags_lines" ]; then
name=$(grep -m 1 -E '^name =' "$file" | awk -F'= ' '{print $2}')
rule_id=$(grep -E '^rule_id =' "$file" | awk -F'= ' '{print $2}')
# Extract the filename without the path
filename=$(basename "$file")
echo "File: $filename"
echo "Name: $name"
echo "Rule ID: $rule_id"
# Add a new line after each hit
echo
fi
done
Output:
Rule_Name | Rule_ID | Tune | Comment |
---|---|---|---|
Windows System Network Connections Discovery | "c4e9ed3e-55a2-4309-a012-bc3c78dad10a" | Yes | 19k hits 7 days. Convert to new_terms, perfect candidate --> will not require complicated exclusions. |
Process Discovery Using Built-in Tools | "4982ac3e-d0ee-4818-b95d-d9522d689259" | Yes | Need to talk about performance, could be good new_terms with user.name & process.args combination. |
Potential Network Share Discovery | "b2318c71-5959-469a-a3ce-3a0768e63b9c" | Yes | 280k hits last 7 days. |
Windows Account or Group Discovery | "089db1af-740d-4d84-9a5b-babd6de143b0" | Yes | new_terms on user.name & process.command_line |
Windows System Information Discovery | "51176ed2-2d90-49f2-9f3d-17196428b169" | Yes | new_terms on user.name & process.command_line |
Discovery of Internet Capabilities via Built-in Tools | "7f89afef-9fc5-4e7b-bf16-75ffdf27f8db" | Yes | new_terms on user.name & process.command_line |
PowerShell Script with Password Policy Discovery Capabilities | "fe25d5bc-01fa-494a-95ff-535c29cc4c96" | No | |
PowerShell Script with Discovery Capabilities | "1e0a3f7c-21e7-4bb1-98c7-2036612fb1be" | Yes | Very noisy. Could be converted to new_terms on user.name & process.command_line. Not sure if this would be enough for this rule to stop generating noise. |
Query Registry using Built-in Tools | "ded09d02-0137-4ccc-8005-c45e617e8d4c" | Yes | Could be converted to new_terms on user.name & process.parent.command_line. |
Account Discovery Command via SYSTEM Account | "2856446a-34e6-435b-9fb5-f8f040bfa7ed" | Debatable | Might be good to add a new new_terms rule for UEBA instead. |
Group Policy Discovery via Microsoft GPResult Utility | "94a401ba-4fa2-455c-b7ae-b6e037afc0b7" | No | Good as-is. |
Enumerating Domain Trusts via DSQUERY.EXE | "06a7a03c-c735-47a6-a313-51c354aef6c3" | No | 0 hits, should be merged with NLTEST.EXE rule |
External IP Lookup from Non-Browser Process | "1d72d014-e2ab-4707-b056-9b96abe7b511" | Yes | Convert to new_terms, on process.executable and user.name |
System Service Discovery through built-in Windows Utilities | "e0881d20-54ac-457f-8733-fe0bc5d44c55" | Yes | Convert to new_terms to reduce noise, could leverage user.name & process.command_line |
Enumerating Domain Trusts via NLTEST.EXE | "84da2554-e12a-11ec-b896-f661ea17fbcd" | No | Rule is good, not a lot of noise. Can be combined with the DSQUERY.EXE rule |
Enumeration of Administrator Accounts | "871ea072-1b71-4def-b016-6278b505138d" | Debatable | This one could work as-is, but could end up generating noise for the UEBA model due to baseline behavior. Could choose to convert, think I would vote for conversion. |
System Time Discovery | "06568a02-af29-4f20-929c-f3af281e41aa" | No | Good results after excluding system user |
Enumeration of Privileged Local Groups Membership | "291a0de9-937a-4189-94c0-3e847c8b13e4" | Yes | Should be converted, way too noisy. |
PowerShell Share Enumeration Script | "4c59cff1-b78a-41b8-a9f1-4231984d1fb6" | No | Seems to be limited hits, should be fine. |
Peripheral Device Discovery | "0c7ca5c2-728d-4ad9-b1c5-bbba83ecb1f4" | No | Limited hits, only TPs. |
Windows Network Enumeration | "7b8bfc26-81d2-435e-965c-d722ee397ef1" | Debatable | Could work as DR, with some additional tuning. Could also work as new_terms, with unique user.name and potentially command line |
AdFind Command Activity | "eda499b8-a073-4e35-9733-22ec71f57f3a" | No | Rule is good, no FPs |
Whoami Process Activity | "ef862985-3f13-4262-a686-5f357bbb9bc2" | Yes | Could either choose to keep this one + system whoami one and create a third new_terms rule to ensure it only triggers on new users. Otherwise it will be too noisy for UEBA. |
Remote System Discovery Commands | "0635c542-1b96-4335-9b47-126582d2c19a" | Yes | Either a lot of exclusions or conversion to new_terms would work |
Security Software Discovery using WMIC | "6ea55c81-e2ba-42f2-a134-bccf857ba922" | Yes | Could work with some additional tuning, or convert to new_terms. |
System Information Discovery via Windows Command Shell | "d68e95ad-1c82-4074-a12a-125fe10ac8ba" | Yes | This one has to be converted to new_terms, way too noisy. |
PowerShell Suspicious Discovery Related Windows API Functions | "61ac3638-40a3-44b2-855a-985636ca985e" | Yes | Either new_terms or a lot of tuning. Would be a good new_terms candidate though. |
This issue is no longer needed, tuning has finished.
Summary
This issue is used to compile a list of Windows Discovery-related detection rules that can be leveraged as part of the "UEBA - Discovery - Unusual Discovery Activity from User". This list will, if necessary, be tuned/redesigned/converted to new_terms to reduce FPs while maintaining TP detection rate. These rules will then be shipped as a "UEBA Discovery" pack for telemetry gathering / evaluation.
Approach