forked from elastic/detection-rules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
defense_evasion_posh_process_injection.toml
113 lines (87 loc) · 3.88 KB
/
defense_evasion_posh_process_injection.toml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
[metadata]
creation_date = "2021/10/14"
maturity = "production"
updated_date = "2022/02/28"
[rule]
author = ["Elastic"]
description = """
Detects the use of Windows API functions that are commonly abused by malware and security tools to load
malicious code or inject it into remote processes.
"""
false_positives = ["Legitimate PowerShell scripts that make use of these functions."]
from = "now-9m"
index = ["winlogbeat-*", "logs-windows.*"]
language = "kuery"
license = "Elastic License v2"
name = "Potential Process Injection via PowerShell"
note = """## Triage and analysis.
### Investigating Potential Process Injection via PowerShell
PowerShell is one of the main tools used by system administrators for automation, report routines, and other tasks.
PowerShell also has solid capabilities to make the interaction with the Win32 API in an uncomplicated and reliable way,
like the execution of inline C# code, PSReflect, Get-ProcAddress, etc.
Red Team tooling and malware developers take advantage of these capabilities to develop stagers and loaders that inject
payloads directly into the memory, without touching the disk.
#### Possible investigation steps:
- Examine script content that triggered the detection.
- Investigate script execution chain (parent process tree).
- Inspect any file or network events from the suspicious PowerShell host process instance.
- If the action is suspicious for the user, check for any other activities done by the user in the last 48 hours.
### False Positive Analysis
- Verify whether the script content is malicious/harmful.
### Related Rules
- PowerShell PSReflect Script - 56f2e9b5-4803-4e44-a0a4-a52dc79d57fe
### Response and Remediation
- Immediate response steps should be taken to validate, investigate, and potentially contain the activity to prevent
further post-compromise behavior.
## Config
The 'PowerShell Script Block Logging' logging policy must be enabled.
Steps to implement the logging policy with with Advanced Audit Configuration:
```
Computer Configuration >
Administrative Templates >
Windows PowerShell >
Turn on PowerShell Script Block Logging (Enable)
```
Steps to implement the logging policy via registry:
```
reg add "hklm\\SOFTWARE\\Policies\\Microsoft\\Windows\\PowerShell\\ScriptBlockLogging" /v EnableScriptBlockLogging /t REG_DWORD /d 1
```
"""
references = [
"https://github.com/EmpireProject/Empire/blob/master/data/module_source/management/Invoke-PSInject.ps1",
"https://github.com/EmpireProject/Empire/blob/master/data/module_source/management/Invoke-ReflectivePEInjection.ps1",
"https://github.com/BC-SECURITY/Empire/blob/master/empire/server/data/module_source/credentials/Invoke-Mimikatz.ps1",
]
risk_score = 73
rule_id = "2e29e96a-b67c-455a-afe4-de6183431d0d"
severity = "high"
tags = ["Elastic", "Host", "Windows", "Threat Detection", "Defense Evasion"]
timestamp_override = "event.ingested"
type = "query"
query = '''
event.category:process and
powershell.file.script_block_text : (
(VirtualAlloc or VirtualAllocEx or VirtualProtect or LdrLoadDll or LoadLibrary or LoadLibraryA or
LoadLibraryEx or GetProcAddress or OpenProcess or OpenProcessToken or AdjustTokenPrivileges) and
(WriteProcessMemory or CreateRemoteThread or NtCreateThreadEx or CreateThread or QueueUserAPC or
SuspendThread or ResumeThread)
)
'''
[[rule.threat]]
framework = "MITRE ATT&CK"
[[rule.threat.technique]]
id = "T1055"
name = "Process Injection"
reference = "https://attack.mitre.org/techniques/T1055/"
[[rule.threat.technique.subtechnique]]
id = "T1055.001"
name = "Dynamic-link Library Injection"
reference = "https://attack.mitre.org/techniques/T1055/001/"
[[rule.threat.technique.subtechnique]]
id = "T1055.002"
name = "Portable Executable Injection"
reference = "https://attack.mitre.org/techniques/T1055/002/"
[rule.threat.tactic]
id = "TA0005"
name = "Defense Evasion"
reference = "https://attack.mitre.org/tactics/TA0005/"