From 7d7ab0a418d4d83e8d681bfefbc9af3ef2c88f8c Mon Sep 17 00:00:00 2001 From: Shashank K S Date: Mon, 15 Sep 2025 21:55:17 +0530 Subject: [PATCH 1/5] Update investigation guides --- ...fense_evasion_posh_defender_tampering.toml | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/rules/windows/defense_evasion_posh_defender_tampering.toml b/rules/windows/defense_evasion_posh_defender_tampering.toml index d449c6048c3..ab7d9366850 100644 --- a/rules/windows/defense_evasion_posh_defender_tampering.toml +++ b/rules/windows/defense_evasion_posh_defender_tampering.toml @@ -2,7 +2,7 @@ creation_date = "2024/09/11" integration = ["windows"] maturity = "production" -updated_date = "2025/09/03" +updated_date = "2025/10/15" [rule] author = ["Elastic"] @@ -15,6 +15,40 @@ index = ["winlogbeat-*", "logs-windows.powershell*"] language = "kuery" license = "Elastic License v2" name = "PowerShell Script with Windows Defender Tampering Capabilities" +note = """ ## Triage and analysis + +> **Disclaimer**: +> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs. + +### Investigating PowerShell Script with Windows Defender Tampering Capabilities + +PowerShell is a powerful scripting language used for task automation and configuration management in Windows environments. Adversaries exploit PowerShell to disable Windows Defender features, reducing detection risks. The detection rule identifies scripts attempting to modify Defender settings, such as disabling real-time monitoring, by analyzing script block text for specific cmdlets and parameters, while excluding legitimate processes and users. + +### Possible investigation steps + +- Review the PowerShell script block text to identify any suspicious cmdlets or parameters, such as Set-MpPreference with disabling options like DisableRealtimeMonitoring or DisableScriptScanning. +- Check the process execution context, including the user ID, to determine if the script was executed by an unauthorized or suspicious user, excluding known safe user IDs like "S-1-5-18". +- Investigate the file directory from which the script was executed to ensure it is not a known safe directory like "C:\ProgramData\Microsoft\Windows Defender Advanced Threat Protection\SenseCM". +- Analyze the historical activity of the involved user and host to identify any patterns of suspicious behavior or previous security alerts. +- Correlate the event with other logs and alerts to determine if this activity is part of a larger attack pattern or campaign targeting the environment. + +### False positive analysis + +- Legitimate administrative scripts may trigger the rule if they use Set-MpPreference cmdlets for valid configuration changes. To handle this, review the script's purpose and source, and consider adding exceptions for trusted scripts or users. +- Automated system management tools might use similar cmdlets for routine maintenance. Identify these tools and exclude their processes or directories from the rule to prevent unnecessary alerts. +- Security software updates or installations could temporarily disable certain Defender features. Monitor these activities and whitelist known update processes to avoid false positives. +- PowerShell scripts executed by system administrators for troubleshooting may appear suspicious. Verify the user ID and script content, and exclude known administrator accounts from the rule if they frequently perform such tasks. + +### Response and remediation + +- Immediately isolate the affected system from the network to prevent further tampering or spread of malicious activity. +- Terminate any suspicious PowerShell processes identified by the detection rule to halt ongoing malicious actions. +- Restore Windows Defender settings to their default state using a trusted administrative account to ensure antivirus protection is re-enabled. +- Conduct a full antivirus scan on the affected system to identify and remove any malicious payloads or files that may have been introduced. +- Review and revoke any unauthorized changes to user permissions or roles that may have facilitated the attack, ensuring only legitimate users have administrative access. +- Escalate the incident to the security operations center (SOC) for further analysis and to determine if additional systems are compromised. +- Implement enhanced monitoring and logging for PowerShell activities across the network to detect similar tampering attempts in the future. +""" risk_score = 21 rule_id = "c124dc1b-cef2-4d01-8d74-ff6b0d5096b6" setup = """## Setup @@ -42,6 +76,7 @@ tags = [ "Use Case: Threat Detection", "Tactic: Defense Evasion", "Data Source: PowerShell Logs", + "Resources: Investigation Guide", ] timestamp_override = "event.ingested" type = "query" From 3e7831111fc75b96a4481648a2d2244d4dbec553 Mon Sep 17 00:00:00 2001 From: Shashank K S Date: Mon, 15 Sep 2025 22:09:30 +0530 Subject: [PATCH 2/5] Fix unit test failures --- rules/windows/defense_evasion_posh_defender_tampering.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/windows/defense_evasion_posh_defender_tampering.toml b/rules/windows/defense_evasion_posh_defender_tampering.toml index ab7d9366850..c6485e4c936 100644 --- a/rules/windows/defense_evasion_posh_defender_tampering.toml +++ b/rules/windows/defense_evasion_posh_defender_tampering.toml @@ -28,7 +28,7 @@ PowerShell is a powerful scripting language used for task automation and configu - Review the PowerShell script block text to identify any suspicious cmdlets or parameters, such as Set-MpPreference with disabling options like DisableRealtimeMonitoring or DisableScriptScanning. - Check the process execution context, including the user ID, to determine if the script was executed by an unauthorized or suspicious user, excluding known safe user IDs like "S-1-5-18". -- Investigate the file directory from which the script was executed to ensure it is not a known safe directory like "C:\ProgramData\Microsoft\Windows Defender Advanced Threat Protection\SenseCM". +- Investigate the file directory from which the script was executed to ensure it is not a known safe directory like "C:\\ProgramData\\Microsoft\\Windows Defender Advanced Threat Protection\\SenseCM". - Analyze the historical activity of the involved user and host to identify any patterns of suspicious behavior or previous security alerts. - Correlate the event with other logs and alerts to determine if this activity is part of a larger attack pattern or campaign targeting the environment. From fd7a5200268bcab976e3b1db8d607ed09131efa0 Mon Sep 17 00:00:00 2001 From: Jonhnathan <26856693+w0rk3r@users.noreply.github.com> Date: Mon, 15 Sep 2025 09:46:37 -0700 Subject: [PATCH 3/5] Update rules/windows/defense_evasion_posh_defender_tampering.toml --- .../defense_evasion_posh_defender_tampering.toml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/rules/windows/defense_evasion_posh_defender_tampering.toml b/rules/windows/defense_evasion_posh_defender_tampering.toml index c6485e4c936..cf332d31a25 100644 --- a/rules/windows/defense_evasion_posh_defender_tampering.toml +++ b/rules/windows/defense_evasion_posh_defender_tampering.toml @@ -26,11 +26,14 @@ PowerShell is a powerful scripting language used for task automation and configu ### Possible investigation steps -- Review the PowerShell script block text to identify any suspicious cmdlets or parameters, such as Set-MpPreference with disabling options like DisableRealtimeMonitoring or DisableScriptScanning. -- Check the process execution context, including the user ID, to determine if the script was executed by an unauthorized or suspicious user, excluding known safe user IDs like "S-1-5-18". -- Investigate the file directory from which the script was executed to ensure it is not a known safe directory like "C:\\ProgramData\\Microsoft\\Windows Defender Advanced Threat Protection\\SenseCM". -- Analyze the historical activity of the involved user and host to identify any patterns of suspicious behavior or previous security alerts. -- Correlate the event with other logs and alerts to determine if this activity is part of a larger attack pattern or campaign targeting the environment. +- Examine the script content that triggered the detection; look for suspicious DLL imports, collection or exfiltration capabilities, suspicious functions, encoded or compressed data, and other potentially malicious characteristics. +- Investigate the script execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures. +- Examine the script's execution context, such as the user account, privileges, the role of the system on which it was executed, and any relevant timestamps. +- Investigate other alerts associated with the user/host during the past 48 hours. +- Evaluate whether the user needs to use PowerShell to complete tasks. +- Investigate the origin of the PowerShell script, including its source, download method, and any associated URLs or IP addresses. +- Use the Get-MpPreference cmdlet to check defender settings for the host. Revert them to the desired state if needed. +- Check for Files written and executed after the settings were changed. ### False positive analysis From 76466654081096faa443dddfb2f1ebafad1db32a Mon Sep 17 00:00:00 2001 From: Jonhnathan <26856693+w0rk3r@users.noreply.github.com> Date: Mon, 15 Sep 2025 09:46:42 -0700 Subject: [PATCH 4/5] Update rules/windows/defense_evasion_posh_defender_tampering.toml --- ...fense_evasion_posh_defender_tampering.toml | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/rules/windows/defense_evasion_posh_defender_tampering.toml b/rules/windows/defense_evasion_posh_defender_tampering.toml index cf332d31a25..4a2df384201 100644 --- a/rules/windows/defense_evasion_posh_defender_tampering.toml +++ b/rules/windows/defense_evasion_posh_defender_tampering.toml @@ -44,13 +44,20 @@ PowerShell is a powerful scripting language used for task automation and configu ### Response and remediation -- Immediately isolate the affected system from the network to prevent further tampering or spread of malicious activity. -- Terminate any suspicious PowerShell processes identified by the detection rule to halt ongoing malicious actions. -- Restore Windows Defender settings to their default state using a trusted administrative account to ensure antivirus protection is re-enabled. -- Conduct a full antivirus scan on the affected system to identify and remove any malicious payloads or files that may have been introduced. -- Review and revoke any unauthorized changes to user permissions or roles that may have facilitated the attack, ensuring only legitimate users have administrative access. -- Escalate the incident to the security operations center (SOC) for further analysis and to determine if additional systems are compromised. -- Implement enhanced monitoring and logging for PowerShell activities across the network to detect similar tampering attempts in the future. +- Initiate the incident response process based on the outcome of the triage. + - If malicious activity is confirmed, perform a broader investigation to identify the scope of the compromise and determine the appropriate remediation steps. +- Isolate the involved hosts to prevent further post-compromise behavior. +- If the triage identified malware, search the environment for additional compromised hosts. + - Implement temporary network rules, procedures, and segmentation to contain the malware. + - Stop suspicious processes. + - Immediately block the identified indicators of compromise (IoCs). + - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system. +- Remove and block malicious artifacts identified during triage. +- Reimage the host operating system or restore the compromised files to clean versions. +- Restrict PowerShell usage outside of IT and engineering business units using GPOs, AppLocker, Intune, or similar software. +- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services. +- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components. +- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR). """ risk_score = 21 rule_id = "c124dc1b-cef2-4d01-8d74-ff6b0d5096b6" From 5ec43a829ff5fc5ee869b3aa4eb63758ff078d42 Mon Sep 17 00:00:00 2001 From: shashank-elastic <91139415+shashank-elastic@users.noreply.github.com> Date: Mon, 15 Sep 2025 22:27:36 +0530 Subject: [PATCH 5/5] Update rules/windows/defense_evasion_posh_defender_tampering.toml --- rules/windows/defense_evasion_posh_defender_tampering.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/windows/defense_evasion_posh_defender_tampering.toml b/rules/windows/defense_evasion_posh_defender_tampering.toml index 4a2df384201..e9fc5500b2a 100644 --- a/rules/windows/defense_evasion_posh_defender_tampering.toml +++ b/rules/windows/defense_evasion_posh_defender_tampering.toml @@ -2,7 +2,7 @@ creation_date = "2024/09/11" integration = ["windows"] maturity = "production" -updated_date = "2025/10/15" +updated_date = "2025/09/15" [rule] author = ["Elastic"]