PowerShell Suspicious Script with Audio Capture Capabilities
Detects PowerShell scripts that can record audio, a common feature in popular post-exploitation tooling.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2021/10/19"
3integration = ["windows"]
4maturity = "production"
5updated_date = "2024/10/28"
6min_stack_version = "8.14.0"
7min_stack_comments = "Breaking change at 8.14.0 for the Windows Integration."
8
9[rule]
10author = ["Elastic"]
11description = "Detects PowerShell scripts that can record audio, a common feature in popular post-exploitation tooling."
12from = "now-9m"
13index = ["winlogbeat-*", "logs-windows.powershell*"]
14language = "kuery"
15license = "Elastic License v2"
16name = "PowerShell Suspicious Script with Audio Capture Capabilities"
17note = """## Triage and analysis
18
19### Investigating PowerShell Suspicious Script with Audio Capture Capabilities
20
21PowerShell is one of the main tools system administrators use for automation, report routines, and other tasks. This makes it available for use in various environments, and creates an attractive way for attackers to execute code.
22
23Attackers can use PowerShell to interact with the Windows API with the intent of capturing audio from input devices connected to the victim's computer.
24
25#### Possible investigation steps
26
27- 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.
28- 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.
29- Examine file or network events from the involved PowerShell process for suspicious behavior.
30- Investigate other alerts associated with the user/host during the past 48 hours.
31- Evaluate whether the user needs to use PowerShell to complete tasks.
32- Investigate if the script stores the recorded data locally and determine if anything was recorded.
33- Investigate whether the script contains exfiltration capabilities and identify the exfiltration server.
34- Assess network data to determine if the host communicated with the exfiltration server.
35
36### False positive analysis
37
38- Regular users should not need scripts to capture audio, which makes false positives unlikely. In the case of authorized benign true positives (B-TPs), exceptions can be added.
39
40### Related rules
41
42- PowerShell PSReflect Script - 56f2e9b5-4803-4e44-a0a4-a52dc79d57fe
43- Potential Process Injection via PowerShell - 2e29e96a-b67c-455a-afe4-de6183431d0d
44
45### Response and remediation
46
47- Initiate the incident response process based on the outcome of the triage.
48- Isolate the involved hosts to prevent further post-compromise behavior.
49- Prioritize the response if this alert involves key executives or potentially valuable targets for espionage.
50- 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.
51- Restrict PowerShell usage outside of IT and engineering business units using GPOs, AppLocker, Intune, or similar software.
52- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
53- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
54- 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).
55"""
56references = ["https://github.com/PowerShellMafia/PowerSploit/blob/master/Exfiltration/Get-MicrophoneAudio.ps1"]
57risk_score = 47
58rule_id = "2f2f4939-0b34-40c2-a0a3-844eb7889f43"
59setup = """## Setup
60
61The 'PowerShell Script Block Logging' logging policy must be enabled.
62Steps to implement the logging policy with Advanced Audit Configuration:
Computer Configuration > Administrative Templates > Windows PowerShell > Turn on PowerShell Script Block Logging (Enable)
1
2Steps to implement the logging policy via registry:
reg add "hklm\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v EnableScriptBlockLogging /t REG_DWORD /d 1
1"""
2severity = "medium"
3tags = [
4 "Domain: Endpoint",
5 "OS: Windows",
6 "Use Case: Threat Detection",
7 "Tactic: Collection",
8 "Resources: Investigation Guide",
9 "Data Source: PowerShell Logs",
10]
11timestamp_override = "event.ingested"
12type = "query"
13
14query = '''
15event.category:process and host.os.type:windows and
16 powershell.file.script_block_text : (
17 "Get-MicrophoneAudio" or
18 "WindowsAudioDevice-Powershell-Cmdlet" or
19 (waveInGetNumDevs and mciSendStringA)
20 )
21 and not powershell.file.script_block_text : (
22 "sentinelbreakpoints" and "Set-PSBreakpoint" and "PowerSploitIndicators"
23 )
24 and not user.id : "S-1-5-18"
25'''
26
27
28[[rule.threat]]
29framework = "MITRE ATT&CK"
30[[rule.threat.technique]]
31id = "T1123"
32name = "Audio Capture"
33reference = "https://attack.mitre.org/techniques/T1123/"
34
35
36[rule.threat.tactic]
37id = "TA0009"
38name = "Collection"
39reference = "https://attack.mitre.org/tactics/TA0009/"
40[[rule.threat]]
41framework = "MITRE ATT&CK"
42[[rule.threat.technique]]
43id = "T1059"
44name = "Command and Scripting Interpreter"
45reference = "https://attack.mitre.org/techniques/T1059/"
46[[rule.threat.technique.subtechnique]]
47id = "T1059.001"
48name = "PowerShell"
49reference = "https://attack.mitre.org/techniques/T1059/001/"
50
51
52[[rule.threat.technique]]
53id = "T1106"
54name = "Native API"
55reference = "https://attack.mitre.org/techniques/T1106/"
56
57
58[rule.threat.tactic]
59id = "TA0002"
60name = "Execution"
61reference = "https://attack.mitre.org/tactics/TA0002/"
Triage and analysis
Investigating PowerShell Suspicious Script with Audio Capture Capabilities
PowerShell is one of the main tools system administrators use for automation, report routines, and other tasks. This makes it available for use in various environments, and creates an attractive way for attackers to execute code.
Attackers can use PowerShell to interact with the Windows API with the intent of capturing audio from input devices connected to the victim's computer.
Possible investigation steps
- 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 file or network events from the involved PowerShell process for suspicious behavior.
- 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 if the script stores the recorded data locally and determine if anything was recorded.
- Investigate whether the script contains exfiltration capabilities and identify the exfiltration server.
- Assess network data to determine if the host communicated with the exfiltration server.
False positive analysis
- Regular users should not need scripts to capture audio, which makes false positives unlikely. In the case of authorized benign true positives (B-TPs), exceptions can be added.
Related rules
- PowerShell PSReflect Script - 56f2e9b5-4803-4e44-a0a4-a52dc79d57fe
- Potential Process Injection via PowerShell - 2e29e96a-b67c-455a-afe4-de6183431d0d
Response and remediation
- Initiate the incident response process based on the outcome of the triage.
- Isolate the involved hosts to prevent further post-compromise behavior.
- Prioritize the response if this alert involves key executives or potentially valuable targets for espionage.
- 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.
- Restrict PowerShell usage outside of IT and engineering business units using GPOs, AppLocker, Intune, or similar software.
- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
- 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).
References
Related rules
- Exchange Mailbox Export via PowerShell
- PowerShell Keylogging Script
- PowerShell Mailbox Collection Script
- PowerShell Share Enumeration Script
- PowerShell Suspicious Discovery Related Windows API Functions