forked from elastic/detection-rules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[New Hunt] Add Initial Linux Hunting Files (elastic#3847)
* added 'Uncommon Process Execution from Suspicious Directory' hunt * adds all linux hunting files * moves linux hunting files to queries folder * adds generated docs * fixing windows hunts * fixing windows hunts * updated README * Removed 2, updated a few, changed some names/descriptions and added list of str * updated windows for language schema changes, regenerated docs; updated README and index * changed UUIDs to hex only with standard hyphen format * removing unecessary docs * Fixed queries based on Samir feedback * ++ * regenerating linux docs * Update hunting/linux/queries/command_and_control_via_network_connections_with_low_occurrence_frequency_for_unique_agents.toml Co-authored-by: Samirbous <[email protected]> * Update hunting/linux/queries/defense_evasion_via_hidden_process_execution.toml Co-authored-by: Samirbous <[email protected]> * Update hunting/linux/queries/command_and_control_via_unusual_file_downloads_from_source_addresses.toml Co-authored-by: Samirbous <[email protected]> * Update hunting/linux/queries/defense_evasion_via_capitalized_process_execution.toml Co-authored-by: Samirbous <[email protected]> * Update hunting/linux/queries/defense_evasion_via_hidden_process_execution.toml Co-authored-by: Samirbous <[email protected]> * Updates * Update * Update hunting/linux/queries/command_and_control_via_network_connections_with_low_occurrence_frequency_for_unique_agents.toml Co-authored-by: Samirbous <[email protected]> * Updates * regenerating linux docs --------- Co-authored-by: Ruben Groenewoud <[email protected]> Co-authored-by: Samirbous <[email protected]>
- Loading branch information
1 parent
215d5a0
commit f0b2cb7
Showing
137 changed files
with
3,930 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
...trol_via_network_connections_with_low_occurrence_frequency_for_unique_agents.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Network Connections with Low Occurrence Frequency for Unique Agent ID | ||
|
||
--- | ||
|
||
## Metadata | ||
|
||
- **Author:** Elastic | ||
- **Description:** This hunt identifies network connections with low occurrence frequency for unique agent IDs on Linux systems. It monitors network connection attempts and acceptances, focusing on those initiated by processes that are rarely seen in the environment. By accounting for known low-frequency legitimate binaries (LoLBins) and suspicious directories, this hunt aims to detect unusual network activity that may indicate malicious behavior. | ||
|
||
- **UUID:** `ecd84bc7-32ae-474b-93a8-d1d9736c3464` | ||
- **Integration:** [endpoint](https://docs.elastic.co/integrations/endpoint) | ||
- **Language:** `[ES|QL]` | ||
|
||
## Query | ||
|
||
```sql | ||
from logs-endpoint.events.network-* | ||
| where @timestamp > now() - 7 day | ||
| where host.os.type == "linux" and event.type == "start" and event.action in ("connection_attempted", "connection_accepted") and destination.ip IS NOT null and not CIDR_MATCH(destination.ip, "10.0.0.0/8", "127.0.0.0/8", "169.254.0.0/16", "172.16.0.0/12", "192.0.0.0/24", "192.0.0.0/29", "192.0.0.8/32", "192.0.0.9/32", "192.0.0.10/32", "192.0.0.170/32", "192.0.0.171/32", "192.0.2.0/24", "192.31.196.0/24", "192.52.193.0/24", "192.168.0.0/16", "192.88.99.0/24", "224.0.0.0/4", "100.64.0.0/10", "192.175.48.0/24","198.18.0.0/15", "198.51.100.0/24", "203.0.113.0/24", "224.0.0.0/4", "240.0.0.0/4", "::1","FE80::/10", "FF00::/8") | ||
| stats cc = count(), agent_count = count_distinct(agent.id) by process.executable | ||
| where agent_count == 1 and cc > 0 and cc <= 3 | ||
| limit 100 | ||
| sort cc asc | ||
``` | ||
|
||
```sql | ||
from logs-endpoint.events.network-* | ||
| where @timestamp > now() - 7 day | ||
| where host.os.type == "linux" and event.type == "start" and event.action in ("connection_attempted", "connection_accepted") and ( | ||
process.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish", "socat", "java", "awk", "gawk", "mawk", "nawk", "openssl", "nc", "ncat", "netcat", "nc.openbsd", "telnet") or | ||
process.name like "python*" or | ||
process.name like "perl*" or | ||
process.name like "ruby*" or | ||
process.name like "lua*" or | ||
process.name like "php*" | ||
) and | ||
destination.ip IS NOT null and not CIDR_MATCH(destination.ip, "10.0.0.0/8", "127.0.0.0/8", "169.254.0.0/16", "172.16.0.0/12", "192.0.0.0/24", "192.0.0.0/29", "192.0.0.8/32", "192.0.0.9/32", "192.0.0.10/32", "192.0.0.170/32", "192.0.0.171/32", "192.0.2.0/24", "192.31.196.0/24", "192.52.193.0/24", "192.168.0.0/16", "192.88.99.0/24", "224.0.0.0/4", "100.64.0.0/10", "192.175.48.0/24","198.18.0.0/15", "198.51.100.0/24", "203.0.113.0/24", "224.0.0.0/4", "240.0.0.0/4", "::1","FE80::/10", "FF00::/8") | ||
| stats cc = count(), agent_count = count_distinct(agent.id) by process.name | ||
| where agent_count <= 3 and cc > 0 and cc <= 5 | ||
| limit 100 | ||
| sort cc asc | ||
``` | ||
|
||
```sql | ||
from logs-endpoint.events.network-* | ||
| where @timestamp > now() - 30 day | ||
| where host.os.type == "linux" and event.type == "start" and event.action in ("connection_attempted", "connection_accepted") and ( | ||
process.executable like "./*" or | ||
process.executable like "/dev/shm/*" or | ||
process.executable like "/var/www/*" or | ||
process.executable like "/boot/*" or | ||
process.executable like "/srv/*" or | ||
process.executable rlike "/tmp/[^/]+" or | ||
process.executable rlike "/var/tmp/[^/]+" or | ||
process.executable rlike "/run/[^/]+" or | ||
process.executable rlike "/var/run/[^/]+" | ||
) and | ||
destination.ip IS NOT null and not CIDR_MATCH(destination.ip, "127.0.0.0/8", "169.254.0.0/16", "224.0.0.0/4", "::1") | ||
| stats cc = count(), agent_count = count_distinct(agent.id) by process.executable | ||
| where agent_count <= 3 and cc > 0 and cc <= 5 | ||
| limit 100 | ||
| sort cc asc | ||
``` | ||
|
||
## Notes | ||
|
||
- Monitors for network connections initiated by processes that have low occurrence frequency, focusing on unique agent IDs. | ||
- Excludes common internal IP ranges to minimize false positives. | ||
- Accounts for known low-frequency legitimate binaries (LoLBins) to reduce noise. | ||
- Identifies suspicious directories where processes are executed from, which can indicate malicious activity. | ||
## MITRE ATT&CK Techniques | ||
|
||
- [T1071.001](https://attack.mitre.org/techniques/T1071/001) | ||
- [T1071.004](https://attack.mitre.org/techniques/T1071/004) | ||
|
||
## License | ||
|
||
- `Elastic License v2` |
39 changes: 39 additions & 0 deletions
39
...ux/docs/command_and_control_via_unusual_file_downloads_from_source_addresses.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Unusual File Downloads from Source Addresses | ||
|
||
--- | ||
|
||
## Metadata | ||
|
||
- **Author:** Elastic | ||
- **Description:** This hunt identifies unusual file download activities on Linux systems. It detects instances where commonly used download utilities such as curl and wget are executed with command lines that contain IP addresses, which can indicate potentially suspicious file downloads. | ||
|
||
- **UUID:** `0d061fad-cf35-43a6-b9b7-986c348bf182` | ||
- **Integration:** [endpoint](https://docs.elastic.co/integrations/endpoint) | ||
- **Language:** `[ES|QL]` | ||
|
||
## Query | ||
|
||
```sql | ||
from logs-endpoint.events.process-* | ||
| where @timestamp > now() - 7 day | ||
| where host.os.type == "linux" and event.type == "start" and process.name in ("curl", "wget") and process.command_line rlike """.*[0-9]{1,3}(\.[0-9]{1,3}){3}.*""" | ||
| stats cc = count(), host_count = count_distinct(host.id) by process.command_line, process.executable | ||
| where cc <= 10 and host_count <= 5 | ||
| sort cc asc | ||
| limit 100 | ||
``` | ||
|
||
## Notes | ||
|
||
- Detects instances where download utilities like curl and wget are used with IP addresses in their command lines. | ||
- Monitors for potentially suspicious file downloads, which are often seen in malicious activities. | ||
- Uses process command line counting in conjunction with host counting to minimize false positives caused by legitimate downloads. | ||
- The process command line count threshold is set to <= 10, and the host count threshold is set to <= 5 to balance detection and noise. | ||
## MITRE ATT&CK Techniques | ||
|
||
- [T1071.001](https://attack.mitre.org/techniques/T1071/001) | ||
- [T1071.004](https://attack.mitre.org/techniques/T1071/004) | ||
|
||
## License | ||
|
||
- `Elastic License v2` |
41 changes: 41 additions & 0 deletions
41
hunting/linux/docs/defense_evasion_via_capitalized_process_execution.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Defense Evasion via Capitalized Process Execution | ||
|
||
--- | ||
|
||
## Metadata | ||
|
||
- **Author:** Elastic | ||
- **Description:** This hunt identifies potential defense evasion techniques via capitalized process execution on Linux systems. It detects processes that have two or more consecutive capital letters within their names, which can indicate an attempt to evade detection. Such naming conventions are often used in malicious payloads to blend in with legitimate processes. | ||
|
||
- **UUID:** `9d485892-1ca2-464b-9e4e-6b21ab379b9a` | ||
- **Integration:** [endpoint](https://docs.elastic.co/integrations/endpoint) | ||
- **Language:** `[ES|QL]` | ||
|
||
## Query | ||
|
||
```sql | ||
from logs-endpoint.events.process-* | ||
| where @timestamp > now() - 10 day | ||
| where host.os.type == "linux" and event.type == "start" and event.action == "exec" and ( | ||
(process.name rlike """[A-Z]{2,}[a-z]{1,}[0-9]{0,}""") or | ||
(process.name rlike """[A-Z]{1,}[0-9]{0,}""") | ||
) | ||
| stats cc = count(), host_count = count_distinct(host.name) by process.name | ||
// Alter this threshold to make sense for your environment | ||
| where cc <= 3 and host_count <= 3 | ||
| limit 100 | ||
``` | ||
|
||
## Notes | ||
|
||
- Detects processes that have two or more consecutive capital letters within their names, with optional digits. | ||
- This technique is often used in malicious payloads, such as Metasploit payloads, to evade detection. | ||
- Included a process count of <= 3 and a host count of <= 3 to eliminate common processes across different hosts. | ||
## MITRE ATT&CK Techniques | ||
|
||
- [T1036.004](https://attack.mitre.org/techniques/T1036/004) | ||
- [T1070](https://attack.mitre.org/techniques/T1070) | ||
|
||
## License | ||
|
||
- `Elastic License v2` |
39 changes: 39 additions & 0 deletions
39
hunting/linux/docs/defense_evasion_via_hidden_process_execution.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Hidden Process Execution | ||
|
||
--- | ||
|
||
## Metadata | ||
|
||
- **Author:** Elastic | ||
- **Description:** This hunt identifies hidden process executions on Linux systems. It detects processes executed from hidden files, which are often used by malicious actors to conceal their activities. By focusing on hidden files rather than directories, this hunt aims to catch stealthy processes while minimizing noise. | ||
|
||
- **UUID:** `00461198-9a2d-4823-b4cc-f3d1b5c17935` | ||
- **Integration:** [endpoint](https://docs.elastic.co/integrations/endpoint) | ||
- **Language:** `[ES|QL]` | ||
|
||
## Query | ||
|
||
```sql | ||
from logs-endpoint.events.process-* | ||
| where @timestamp > now() - 30 day | ||
| where host.os.type == "linux" and event.type == "start" and event.action == "exec" and | ||
process.executable rlike "/[^/]+/\\.[^/]+" | ||
| stats cc = count(), host_count = count_distinct(host.name) by process.executable, process.parent.executable, user.id | ||
// Alter this threshold to make sense for your environment | ||
| where cc <= 3 and host_count <= 3 | ||
| sort cc asc | ||
| limit 100 | ||
``` | ||
|
||
## Notes | ||
|
||
- Included only hidden files, excluding hidden directories, as hidden directories are common in Unix. | ||
- Included a process or parent process count of <= 3, and a host count of <= 3 to eliminate common processes across different hosts. | ||
## MITRE ATT&CK Techniques | ||
|
||
- [T1036.004](https://attack.mitre.org/techniques/T1036/004) | ||
- [T1059](https://attack.mitre.org/techniques/T1059) | ||
|
||
## License | ||
|
||
- `Elastic License v2` |
Oops, something went wrong.