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"
 5min_stack_comments = "New fields added: required_fields, related_integrations, setup"
 6min_stack_version = "8.3.0"
 7updated_date = "2024/03/08"
 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 = ["Domain: Endpoint", "OS: Windows", "Use Case: Threat Detection", "Tactic: Collection", "Resources: Investigation Guide", "Data Source: PowerShell Logs"]
 4timestamp_override = "event.ingested"
 5type = "query"
 6
 7query = '''
 8event.category:process and host.os.type:windows and
 9  powershell.file.script_block_text : (
10    "Get-MicrophoneAudio" or
11    "WindowsAudioDevice-Powershell-Cmdlet" or
12    (waveInGetNumDevs and mciSendStringA)
13  )
14  and not powershell.file.script_block_text : (
15    "sentinelbreakpoints" and "Set-PSBreakpoint" and "PowerSploitIndicators"
16  )
17  and not user.id : "S-1-5-18"
18'''
19
20
21[[rule.threat]]
22framework = "MITRE ATT&CK"
23[[rule.threat.technique]]
24id = "T1123"
25name = "Audio Capture"
26reference = "https://attack.mitre.org/techniques/T1123/"
27
28
29[rule.threat.tactic]
30id = "TA0009"
31name = "Collection"
32reference = "https://attack.mitre.org/tactics/TA0009/"
33[[rule.threat]]
34framework = "MITRE ATT&CK"
35[[rule.threat.technique]]
36id = "T1059"
37name = "Command and Scripting Interpreter"
38reference = "https://attack.mitre.org/techniques/T1059/"
39[[rule.threat.technique.subtechnique]]
40id = "T1059.001"
41name = "PowerShell"
42reference = "https://attack.mitre.org/techniques/T1059/001/"
43
44
45[[rule.threat.technique]]
46id = "T1106"
47name = "Native API"
48reference = "https://attack.mitre.org/techniques/T1106/"
49
50
51[rule.threat.tactic]
52id = "TA0002"
53name = "Execution"
54reference = "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.
  • 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

to-top