Detect Encrypted/Encoded File in Elastic Security
Adversaries encrypt or encode files to conceal malicious content and evade static signature detection. Techniques include XOR (single-byte and multi-byte), RC4, AES, 3DES, Base64, and custom encoding schemes applied to malware payloads, configuration files, C2 communication blobs, and dropped files. The full content or only specific values (such as C2 addresses or strings) may be obfuscated, sometimes in multiple redundant layers. Common delivery vectors include password-protected ZIP/Word documents and self-extracting (SFX) archives. Threat actors ranging from APT28 and Inception Group to ransomware families like Qilin and RansomHub consistently use encrypted/encoded files to defeat antivirus and EDR static analysis.
MITRE ATT&CK
- Tactic
- Defense Evasion
- Technique
- T1027 Obfuscated Files or Information
- Sub-technique
- T1027.013 Encrypted/Encoded File
- Canonical reference
- https://attack.mitre.org/techniques/T1027/013/
Elastic Detection Query
any where
(
event.category == "process" and event.type == "start" and
(
(process.name : "certutil.exe" and process.command_line : ("*-decode*", "*-decodehex*"))
or (process.name : "powershell.exe" and process.command_line : "*FromBase64String*" and process.command_line : ("*Invoke-Expression*", "*iex*", "*IEX*", "*&(*", "*.Invoke*"))
or (process.name : "powershell.exe" and process.command_line : "*bxor*")
or (process.name : ("7z.exe", "7za.exe", "winrar.exe", "wrar.exe") and process.command_line regex~ "-p\\S+")
or (process.name : ("mshta.exe", "wscript.exe", "cscript.exe") and process.command_line : ("*Base64*", "*FromBase64*", "*bxor*", "*Encoding*"))
)
)
or
(
event.category == "file" and event.type : ("creation", "change") and
file.extension : ("bin", "dat", "tmp", "cfg", "enc") and
file.path : ("*\\Temp\\*", "*\\AppData\\*", "*\\ProgramData\\*") and
process.name : ("powershell.exe", "cmd.exe", "wscript.exe", "cscript.exe", "mshta.exe")
) Detects T1027.013 Encrypted/Encoded File execution techniques using Elastic EQL across process and file event categories. Covers certutil Base64/hex decode, PowerShell FromBase64String chained with Invoke-Expression/iex execution, PowerShell XOR decode via -bxor operator, password-protected archive extraction with 7z/WinRAR, scripting engine (mshta/wscript/cscript) invocations referencing encoded content, and suspicious encoded file drops (.bin/.dat/.enc/.tmp) to writable staging directories by scripting processes.
Data Sources
Required Tables
False Positives & Tuning
- IT administrators legitimately invoke certutil.exe -decode for PKI certificate management, decoding Base64-encoded certificate bundles or CRL files as part of routine PKI operations
- Enterprise software deployment pipelines (SCCM, Intune MDM, Ansible, DSC) routinely use PowerShell with [Convert]::FromBase64String to pass encoded configuration payloads, producing high-volume powershell_b64_decode_exec matches during deployment windows
- Patch management and software packaging solutions (PDQ Deploy, Chocolatey, NSIS installers) commonly produce password-protected 7z or WinRAR archives and drop encoded config or cache files to %TEMP% and %ProgramData% during installation sequences
Other platforms for T1027.013
Testing Methodology
Validate this detection against 4 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1Base64 Encode, Drop, and Decode with certutil
Expected signal: Sysmon EventCode 1 (ProcessCreate) for certutil.exe with '-decode' in CommandLine. EventCode 11 for both the .b64 source file and decoded output file creation in %TEMP%.
- Test 2PowerShell XOR Decryption Simulating Single-Byte XOR Malware
Expected signal: Sysmon EventCode 1 (ProcessCreate) for powershell.exe. PowerShell Script Block Logging EventCode 4104 will capture the deobfuscated script including the -bxor operator and Invoke-Expression call.
- Test 3Password-Protected ZIP Delivery and Extraction
Expected signal: Sysmon EventCode 1 for 7z.exe invocations with '-p' flag in CommandLine. EventCode 11 for .zip creation and extracted file creation in %TEMP%.
- Test 4Base64 Blob Decode and Execute via PowerShell
Expected signal: Sysmon EventCode 1 for powershell.exe. PowerShell Script Block Logging EventCode 4104 will capture both the FromBase64String call and the decoded Invoke-Expression content — this is the primary high-value telemetry source.
References (7)
- https://attack.mitre.org/techniques/T1027/013
- https://www.crowdstrike.com/blog/self-extracting-archives-decoy-files-and-their-hidden-payloads/
- https://www.crowdstrike.com/blog/shlayer-malvertising-campaigns-still-using-flash-update-disguise/
- https://www.mandiant.com/resources/apt41-dual-espionage-and-cyber-crime-operation
- https://securelist.com/the-darkhotel-apt/66779/
- https://unit42.paloaltonetworks.com/sofacy-attacks-multiple-government-entities/
- https://www.secureworks.com/research/threat-profiles/gold-southfield
Unlock Pro Content
Get the full detection package for T1027.013 including response playbook, investigation guide, and atomic red team tests.