# T1123 - Audio Capture

## Description from ATT&CK

> An adversary can leverage a computer's peripheral devices (e.g., microphones and webcams) or applications (e.g., voice and video call services) to capture audio recordings for the purpose of listening into sensitive conversations to gather information.(Citation: ESET Attor Oct 2019)
> 
> Malware or scripts may be used to interact with the devices through an available API provided by the operating system or an application to capture audio. Audio files may be written to disk and exfiltrated later.

[Source](https://attack.mitre.org/techniques/T1123)

## Atomic Tests

- [Atomic Test #1: using device audio capture commandlet](#atomic-test-1-using-device-audio-capture-commandlet)
- [Atomic Test #2: Registry artefact when application use microphone](#atomic-test-2-registry-artefact-when-application-use-microphone)
- [Atomic Test #3: using Quicktime Player](#atomic-test-3-using-quicktime-player)

### Atomic Test #1: using device audio capture commandlet

Uses AudioDeviceCmdlets to set the default recording device and simulate audio capture.
Module repo: [AudioDeviceCmdlets](https://github.com/frgnca/AudioDeviceCmdlets)

**Supported Platforms:** Windows

**auto_generated_guid:** `9c3ad250-b185-4444-b5a9-d69218a10c95`

#### Attack Commands: Run with `powershell`!

```powershell
$mic = Get-AudioDevice -Recording
Set-AudioDevice -ID $mic.ID
Start-Sleep -Seconds 5
```


#### Dependencies: Run with `powershell`!

##### Description: AudioDeviceCmdlets module must be installed

###### Check Prereq Commands

```powershell
if (Get-Module -ListAvailable -Name AudioDeviceCmdlets) { exit 0 } else { exit 1 }
```

###### Get Prereq Commands

```powershell
Install with: Install-Module -Name AudioDeviceCmdlets -Force"
```

### Atomic Test #2: Registry artefact when application use microphone

[can-you-track-processes-accessing-the-camera-and-microphone](https://svch0st.medium.com/can-you-track-processes-accessing-the-camera-and-microphone-7e6885b37072)

**Supported Platforms:** Windows

**auto_generated_guid:** `7a21cce2-6ada-4f7c-afd9-e1e9c481e44a`

#### Attack Commands: Run with `command_prompt`!

```cmd
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\microphone\NonPackaged\C:#Windows#Temp#atomic.exe /v LastUsedTimeStart /t REG_BINARY /d a273b6f07104d601 /f
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\microphone\NonPackaged\C:#Windows#Temp#atomic.exe /v LastUsedTimeStop /t REG_BINARY /d 96ef514b7204d601 /f
```

#### Cleanup Commands

```cmd
reg DELETE HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\microphone\NonPackaged\C:#Windows#Temp#atomic.exe /f
```
### Atomic Test #3: using Quicktime Player

Use AppleScript to get Quicktime Player to record an audio file from the default microphone.

Should create a non-empty m4a file with sound from the microphone.

- requires Automation permissions but no additional microphone permissions
- saves file in /tmp by default. Other locations likely to require more permissions.

**Supported Platforms:** macOS

**auto_generated_guid:** `c7a0bb71-70ce-4a53-b115-881f241b795b`

#### Inputs

| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| filename | Location of the script | path | PathToAtomicsFolder/T1123/src/T1123.sh|
| audiofile | Location of the recorded audio file | path | /tmp/T1123.m4a|
| duration | Length of recording to make in seconds | integer | 5|

#### Attack Commands: Run with `sh`!

```sh
sh #{filename} #{audiofile} #{duration}
```

#### Cleanup Commands

```sh
if test -w #{audiofile}; then
  rm #{audiofile}
fi
```