# T1614.001 - System Location Discovery: System Language Discovery

## Description from ATT&CK

> Adversaries may attempt to gather information about the system language of a victim in order to infer the geographical location of that host. This information may be used to shape follow-on behaviors, including whether the adversary infects the target and/or attempts specific actions. This decision may be employed by malware developers and operators to reduce their risk of attracting the attention of specific law enforcement agencies or prosecution/scrutiny from other entities.(Citation: Malware System Language Check)
> 
> There are various sources of data an adversary could use to infer system language, such as system defaults and keyboard layouts. Specific checks will vary based on the target and/or adversary, but may involve behaviors such as [Query Registry](https://attack.mitre.org/techniques/T1012) and calls to [Native API](https://attack.mitre.org/techniques/T1106) functions.(Citation: CrowdStrike Ryuk January 2019)
> 
> For example, on a Windows system adversaries may attempt to infer the language of a system by querying the registry key <code>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\Language</code> or parsing the outputs of Windows API functions <code>GetUserDefaultUILanguage</code>, <code>GetSystemDefaultUILanguage</code>, <code>GetKeyboardLayoutList</code> and <code>GetUserDefaultLangID</code>.(Citation: Darkside Ransomware Cybereason)(Citation: Securelist JSWorm)(Citation: SecureList SynAck Doppelgänging May 2018)
> 
> On a macOS or Linux system, adversaries may query <code>locale</code> to retrieve the value of the <code>$LANG</code> environment variable.

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

## Atomic Tests

- [Atomic Test #1: Discover System Language by Registry Query](#atomic-test-1-discover-system-language-by-registry-query)
- [Atomic Test #2: Discover System Language with chcp](#atomic-test-2-discover-system-language-with-chcp)
- [Atomic Test #3: Discover System Language with locale](#atomic-test-3-discover-system-language-with-locale)
- [Atomic Test #4: Discover System Language with localectl](#atomic-test-4-discover-system-language-with-localectl)
- [Atomic Test #5: Discover System Language by locale file](#atomic-test-5-discover-system-language-by-locale-file)
- [Atomic Test #6: Discover System Language by Environment Variable Query](#atomic-test-6-discover-system-language-by-environment-variable-query)
- [Atomic Test #7: Discover System Language with dism.exe](#atomic-test-7-discover-system-language-with-dismexe)
- [Atomic Test #8: Discover System Language by Windows API Query](#atomic-test-8-discover-system-language-by-windows-api-query)
- [Atomic Test #9: Discover System Language with WMIC](#atomic-test-9-discover-system-language-with-wmic)
- [Atomic Test #10: Discover System Language with Powershell](#atomic-test-10-discover-system-language-with-powershell)

### Atomic Test #1: Discover System Language by Registry Query

Identify System language by querying the registry on an endpoint. 

Upon successful execution, result in number format can be looked up to correlate the language.

**Supported Platforms:** Windows

**auto_generated_guid:** `631d4cf1-42c9-4209-8fe9-6bd4de9421be`

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

```cmd
reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\Language
```

### Atomic Test #2: Discover System Language with chcp

Identify System language with the chcp command.

Upon successful execution, result in number format can be looked up to correlate the language.

**Supported Platforms:** Windows

**auto_generated_guid:** `d91473ca-944e-477a-b484-0e80217cd789`

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

```cmd
chcp
```

### Atomic Test #3: Discover System Language with locale

Identify System language with the `locale` command.

Upon successful execution, the output will contain the environment variables that indicate
the 5 character locale that can be looked up to correlate the language and territory.

**Supported Platforms:** Linux

**auto_generated_guid:** `837d609b-845e-4519-90ce-edc3b4b0e138`

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

```sh
locale
```

### Atomic Test #4: Discover System Language with localectl

Identify System language with the `localectl` command.

Upon successful execution, the key `System Locale` from the output will contain the
`LANG` environment variable that has the 5 character locale result that can be looked
up to correlate the language and territory.

**Supported Platforms:** Linux

**auto_generated_guid:** `07ce871a-b3c3-44a3-97fa-a20118fdc7c9`

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

```sh
localectl status
```

### Atomic Test #5: Discover System Language by locale file

Identify System language with the by reading the locale configuration file.

The locale configuration file contains the `LANG` environment variable which
will contain the 5 character locale that can be looked up to correlate the
language and territory.

**Supported Platforms:** Linux

**auto_generated_guid:** `5d7057c9-2c8a-4026-91dd-13b5584daa69`

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

```sh
[ -f /etc/locale.conf ] && cat /etc/locale.conf || cat /etc/default/locale
```


#### Dependencies: Run with `sh`!

##### Description: Check the location of the locale configuration file.

###### Check Prereq Commands

```sh
[ -f /etc/locale.conf ] || [ -f /etc/default/locale ] && exit 0 || exit 1
```

###### Get Prereq Commands

```sh
echo "Test only valid for systems that have locale file"
```

### Atomic Test #6: Discover System Language by Environment Variable Query

Identify System language by checking the environment variables

Upon successful execution, the 5 character locale result can be looked up to
correlate the language and territory. Environment query commands are likely
to run with a pattern match command e.g. `env | grep LANG`

Note: `env` and `printenv` will usually provide the same results. `set` is
also used as a builtin command that does not generate syscall telemetry but
does provide a list of the environment variables.

**Supported Platforms:** Linux

**auto_generated_guid:** `cb8f7cdc-36c4-4ed0-befc-7ad7d24dfd7a`

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

```sh
env | grep LANG
printenv LANG
set | grep LANG
```


#### Dependencies: Run with `sh`!

##### Description: Check if printenv command exists on the machine

###### Check Prereq Commands

```sh
[ -x "$(command -v printenv)" ] && exit 0 || exit 1
```

###### Get Prereq Commands

```sh
echo "printenv command does not exist"
exit 1
```

### Atomic Test #7: Discover System Language with dism.exe

The Windows utility DISM (Deployment Image Servicing and Management) can be used to display information about international settings and languages on the currently installed Windows image using an elevated terminal.

**Supported Platforms:** Windows

**auto_generated_guid:** `69f625ba-938f-4900-bdff-82ada3df5d9c`

####