Skip to content

Commit 0d1cefb

Browse files
committed
Merge remote-tracking branch 'upstream/main' into cli/export-rule
2 parents d54fa3e + e2c8606 commit 0d1cefb

File tree

46 files changed

+316
-166
lines changed

Some content is hidden

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

46 files changed

+316
-166
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ This repository was first announced on Elastic's blog post, [Elastic Security op
1212
## Table of Contents
1313
- [Overview of this repository](#overview-of-this-repository)
1414
- [Getting started](#getting-started)
15+
- [Red Team Automation](rta)
1516
- [How to contribute](#how-to-contribute)
1617
- [Licensing](#licensing)
18+
- [Questions? Problems? Suggestions?](#questions-problems-suggestions)
1719

1820

1921
## Overview of this repository

rta/README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## Red Team Automation
2+
3+
[![Supported Python versions](https://img.shields.io/badge/python-3.7+-yellow.svg)](https://www.python.org/downloads/)
4+
[![Chat](https://img.shields.io/badge/chat-%23security--detection--rules-blueviolet)](https://ela.st/slack)
5+
6+
The repo comes with some red team automation ([RTA](./)) python scripts that run on Windows, Mac OS, and \*nix.
7+
RTA scripts emulate known attacker behaviors and are an easy way too verify that your rules are active and working as expected.
8+
9+
```console
10+
$ python -m rta -h
11+
usage: rta [-h] ttp_name
12+
13+
positional arguments:
14+
ttp_name
15+
16+
optional arguments:
17+
-h, --help show this help message and exit
18+
```
19+
`ttp_name` can be found in the [rta](.) directory. For example to execute `./rta/wevtutil_log_clear.py` script, run command:
20+
21+
```console
22+
$ python -m rta wevtutil_log_clear
23+
```
24+
25+
Most of the RTA scripts contain a comment with the rule name, in `signal.rule.name`, that maps to the Kibana Detection Signals.

rta/certutil_file_obfuscation.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# Name: Certutil Encode / Decode
66
# RTA: certutil_file_obfuscation.py
77
# ATT&CK: T1140
8+
# signal.rule.name: Encoding or Decoding Files via CertUtil
89
# Description: Uses certutil to create an encoded copy of cmd.exe. Then uses certutil to decode that copy.
910

1011
import os

rta/delete_bootconf.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# Name: Boot Config Deletion With bcdedit
66
# RTA: delete_bootconf.py
77
# ATT&CK: T1107
8+
# signal.rule.name: Modification of Boot Configuration
89
# Description: Uses bcdedit.exe to backup the current boot configuration, and then to delete the current boot
910
# configuration, finally restoring the original.
1011

rta/delete_usnjrnl.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# Name: USN Journal Deletion with fsutil.exe
66
# RTA: delete_usnjrnl.py
77
# ATT&CK: T1107
8+
# signal.rule.name: Delete Volume USN Journal with Fsutil
89
# Description: Uses fsutil to delete the USN journal.
910

1011
import time

rta/delete_volume_shadows.py

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
# Name: Volume Shadow Copy Deletion with vssadmin and wmic
66
# RTA: delete_volume_shadow.py
7+
# signal.rule.name: Volume Shadow Copy Deletion via VssAdmin
8+
# ELastic Detection: Volume Shadow Copy Deletion via WMIC
79
# ATT&CK: T1107
810
# Description: Uses both vssadmin.exe and wmic.exe to delete volumne shadow copies.
911

rta/disable_windows_fw.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# Name: Disable Windows Firewall
66
# RTA: disable_windows_fw.py
77
# ATT&CK: T1089
8+
# signal.rule.name: Disable Windows Firewall Rules via Netsh
89
# Description: Uses netsh.exe to backup, disable and restore firewall rules.
910

1011
import os

rta/installutil_network.py

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# Name: Network Traffic from InstallUtil
66
# RTA: installutil_network.py
77
# ATT&CK: T1118
8+
# Elastic detection: InstallUtil Process Making Network Connections
9+
# Elastic detection: Unusual Network Activity from a Windows System Binary
810
# Description: Uses mock .NET malware and InstallUtil to create network activity from InstallUtil.
911

1012
import os

rta/lateral_commands.py

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
# Name: Lateral Movement Commands
66
# RTA: lateral_commands.py
7+
# Elatic Detection: Local Service Commands
8+
# signal.rule.name: Local Scheduled Task Commands
9+
# signal.rule.name: Whoami Process Activity
710
# ATT&CK: T1021, T1047, T1077, T1124, T1126
811
# Description: Runs various Windows commands typically used by attackers to move laterally from the local machine.
912

rta/msbuild_network.py

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# Name: MsBuild with Network Activity
66
# RTA: msbuild_network.py
77
# ATT&CK: T1127
8+
# signal.rule.name: Microsoft Build Engine Started an Unusual Process
9+
# signal.rule.name: Trusted Developer Application Usage
810
# Description: Generates network traffic from msbuild.exe
911

1012
from . import common

rta/net_user_add.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# Name: Create User with net.exe
66
# RTA: net_user_add.py
77
# ATT&CK: T1136
8+
# signal.rule.name: User Account Creation
89
# Description: Adds an account to the local host using the net.exe command
910

1011
from . import common

rta/powershell_from_script.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
# Name: PowerShell Launched from Script
66
# RTA: powershell_from_script.py
7+
# signal.rule.name: Windows Script Executing PowerShell
78
# ATT&CK: T1064, T1192, T1193
89
# Description: Creates a javascript file that will launch powershell.
910

rta/process_name_masquerade.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
# Name: Windows Core Process Masquerade
66
# RTA: process_name_masquerade.py
7+
# signal.rule.name: Unusual Parent-Child Relationship
78
# ATT&CK: T1036
89
# Description: Creates several processes which mimic core Windows process names but that are not those executables.
910

rta/registry_persistence_create.py

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
# Name: Registry persistence creation
66
# RTA: registry_persistence_create.py
7+
# signal.rule.name: Local Service Commands
8+
# signal.rule.name: Potential Modification of Accessibility Binaries
79
# ATT&CK: T1015, T1103
810
# Description: Creates registry persistence for mock malware in Run and RunOnce keys, Services, NetSH and debuggers.
911

rta/registry_rdp_enable.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
# Name: Enable RDP Through Registry
66
# RTA: registry_rdp_enable.py
7+
# signal.rule.name: Potential Modification of Accessibility Binaries
78
# ATT&CK: T1076
89
# Description: Identifies registry write modification to enable RDP access.
910

rta/rundll32_inf_callback.py

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
# Name: RunDll32 with .inf Callback
66
# RTA: rundll32_inf_callback.py
7+
# signal.rule.name: Local Service Commands
8+
# signal.rule.name: Potential Modification of Accessibility Binaries
79
# ATT&CK: T1105
810
# Description: Loads RunDll32 with a suspicious .inf file that makes a local http GET
911

rta/rundll32_javascript_callback.py

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
# Name: RunDLL32 Javascript Callback
66
# RTA: rundll32_javascript_callback.py
7+
# signal.rule.name: Local Service Commands
8+
# signal.rule.name: Potential Modification of Accessibility Binaries
79
# ATT&CK: T1085
810
# Description: Executes javascript code with an AJAX call via RunDll32.exe
911

rta/schtask_escalation.py

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
# Name: Scheduled Task Privilege Escalation
66
# RTA: schtask_escalation.py
7+
# signal.rule.name: Local Scheduled Task Commands
8+
# signal.rule.name: Whoami Process Activity
9+
# signal.rule.name: Svchost spawning Cmd
10+
# signal.rule.name: Net command via SYSTEM account
711
# ATT&CK: T1053
812

913
import os

rta/settingcontentms_files.py

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
# Name: Abusing SettingContent-ms Files
66
# RTA: settingcontentms_files.py
7+
# signal.rule.name: Potential Modification of Accessibility Binaries
8+
# signal.rule.name: Local Service Commands
79
# ATT&CK: T1193, T1204, T1064
810
# Description: SettingContent-ms file written to specific path or by risky process
911

rta/sticky_keys_write_execute.py

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
# Name: Overwrite Accessibiity Binaries
66
# RTA: sticky_keys_write_execute.py
7+
# signal.rule.name: Potential Modification of Accessibility Binaries
8+
# signal.rule.name: Local Service Commands
9+
# signal.rule.name: Persistence via TelemetryController Scheduled Task Hijack
710
# ATT&CK: T1015
811
# Description: Writes different binaries into various accessibility locations.
912

rta/suspicious_office_children.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
# Name: Emulate Suspect MS Office Child Processes
66
# RTA: suspect_office_children.py
7+
# signal.rule.name: Suspicious MS Office Child Process
78
# ATT&CK: T1064
89
# Description: Generates network traffic various children processes from emulated Office processes.
910

rta/suspicious_powershell_download.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
# Name: Suspicious PowerShell Download
66
# RTA: suspicious_powershell_download.py
7+
# signal.rule.name: Suspicious MS Office Child Process
78
# ATT&CK: T1086
89
# Description: PowerShell using DownloadString or DownloadFile in suspicious context
910

rta/suspicious_wscript_parent.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
# Name: Suspicious WScript parent
66
# RTA: suspicious_wscript_parent.py
7+
# signal.rule.name: Suspicious MS Outlook Child Process
78
# ATT&CK: T1064, T1192, T1193
89
# Description: WScript run with suspicious parent processes
910

rta/unusual_parent_child.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
# Name: Invalid Process Trees in Windows
66
# RTA: unusual_parent_child.py
7+
# signal.rule.name: Unusual Parent-Child Relationship
78
# ATT&CK: T1093
89
# Description: Runs several Windows core processes directly, instead of from the proper parent in Windows.
910

rta/werfault_persistence.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
# Name: WerFault.exe Persistence
66
# RTA: werfault_persistence.py
7+
# signal.rule.name: Process Potentially Masquerading as WerFault
78
# ATT&CK: T1112
89
# Description: Sets an executable to run when WerFault is run with -rp flags and runs it
910

rta/wevtutil_log_clear.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
# Name: Clearing Windows Event Logs
66
# RTA: wevutil_log_clear.py
7+
# signal.rule.name: Clearing Windows Event Logs
78
# ATT&CK: T1070
89
# Description: Uses the native Windows Event utility to clear the Security, Application and System event logs.
910

rules/linux/privilege_escalation_setuid_bit_set_via_chmod.toml renamed to rules/cross-platform/privilege_escalation_setuid_setgid_bit_set_via_chmod.toml

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
[metadata]
22
creation_date = "2020/04/23"
33
maturity = "production"
4-
updated_date = "2020/12/17"
4+
updated_date = "2021/01/19"
55

66
[rule]
77
author = ["Elastic"]
88
description = """
9-
An adversary may add the setuid bit to a file or directory in order to run a file with the privileges of the owning
10-
user. An adversary can take advantage of this to either do a shell escape or exploit a vulnerability in an application
11-
with the setuid bit to get code running in a different user’s context. Additionally, adversaries can use this mechanism
12-
on their own malware to make sure they're able to execute in elevated contexts in the future.
9+
An adversary may add the setuid or setgid bit to a file or directory in order to run a file with the privileges of the
10+
owning user or group. An adversary can take advantage of this to either do a shell escape or exploit a vulnerability in
11+
an application with the setuid or setgid bit to get code running in a different user’s context. Additionally,
12+
adversaries can use this mechanism on their own malware to make sure they're able to execute in elevated contexts in the
13+
future.
1314
"""
1415
from = "now-9m"
1516
index = ["auditbeat-*", "logs-endpoint.events.*"]
1617
language = "lucene"
1718
license = "Elastic License"
1819
max_signals = 33
19-
name = "Setuid Bit Set via chmod"
20+
name = "Setuid / Setgid Bit Set via chmod"
2021
risk_score = 21
2122
rule_id = "8a1b0278-0f9a-487d-96bd-d4833298e87a"
2223
severity = "low"
23-
tags = ["Elastic", "Host", "Linux", "Threat Detection", "Privilege Escalation"]
24+
tags = ["Elastic", "Host", "Linux", "macOS", "Threat Detection", "Privilege Escalation"]
2425
type = "query"
2526

2627
query = '''
27-
event.category:process AND event.type:(start or process_started) AND process.name:chmod AND
28-
process.args:(u+s OR /4[0-9]{3}/) AND
29-
NOT user.name:root
28+
event.category:process AND event.type:(start OR process_started) AND process.name:chmod AND
29+
process.args:("+s" OR "u+s" OR /4[0-9]{3}/ OR g+s OR /2[0-9]{3}/)
3030
'''
3131

3232

rules/linux/defense_evasion_deletion_of_bash_command_line_history.toml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[metadata]
22
creation_date = "2020/05/04"
33
maturity = "production"
4-
updated_date = "2020/12/22"
4+
updated_date = "2021/02/04"
55

66
[rule]
77
author = ["Elastic"]
@@ -23,11 +23,11 @@ type = "eql"
2323
query = '''
2424
process where event.type in ("start", "process_started") and
2525
(
26-
(process.name in ("rm", "echo") and wildcard(process.args, ".bash_history", "/root/.bash_history", "/home/*/.bash_history")) or
27-
(process.name == "history" and process.args == "-c") or
28-
(process.name == "export" and process.args in ("HISTFILE=/dev/null", "HISTFILESIZE=0")) or
29-
(process.name == "unset" and process.args == "HISTFILE") or
30-
(process.name == "set" and process.args == "history" and process.args == "+o")
26+
(process.name : ("rm", "echo") and process.args : (".bash_history", "/root/.bash_history", "/home/*/.bash_history")) or
27+
(process.name : "history" and process.args : "-c") or
28+
(process.name : "export" and process.args : ("HISTFILE=/dev/null", "HISTFILESIZE=0")) or
29+
(process.name : "unset" and process.args : "HISTFILE") or
30+
(process.name : "set" and process.args : "history" and process.args : "+o")
3131
)
3232
'''
3333

rules/linux/defense_evasion_timestomp_touch.toml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[metadata]
22
creation_date = "2020/11/03"
33
maturity = "production"
4-
updated_date = "2020/12/09"
4+
updated_date = "2021/01/21"
55

66
[rule]
77
author = ["Elastic"]
@@ -23,7 +23,7 @@ type = "eql"
2323

2424
query = '''
2525
process where event.type in ("start", "process_started") and
26-
process.name == "touch" and wildcard(process.args, "-r", "-t", "-a*","-m*")
26+
process.name : "touch" and process.args : ("-r", "-t", "-a*","-m*")
2727
'''
2828

2929

@@ -43,4 +43,3 @@ reference = "https://attack.mitre.org/techniques/T1070/006/"
4343
id = "TA0005"
4444
name = "Defense Evasion"
4545
reference = "https://attack.mitre.org/tactics/TA0005/"
46-

rules/linux/privilege_escalation_setgid_bit_set_via_chmod.toml

-57
This file was deleted.

0 commit comments

Comments
 (0)