Standard Encoding
Adversaries may encode data with a standard data encoding system to make the content of command and control traffic more difficult to detect. Command and control (C2) information can be encoded using a standard data encoding system that adheres to existing protocol specifications. Common data encoding schemes include ASCII, Unicode, hexadecimal, Base64, and MIME. Some data encoding systems may also result in data compression, such as gzip. Malware families including SideTwist, Fysbis, Latrodectus, SeaDuke, Chaes, and Flagpro have all used Base64-encoded C2 traffic, making this one of the most prevalent C2 obfuscation techniques observed in the wild.
// T1132.001 — Standard Encoding C2 Detection
// Detects processes invoking encoding utilities or embedding large Base64 blobs in command lines,
// and network activity where HTTP request/response bodies contain high-entropy encoded content.
let EncodingPatterns = dynamic([
"[Convert]::FromBase64String",
"[Convert]::ToBase64String",
"[System.Convert]::FromBase64String",
"[System.Convert]::ToBase64String",
"FromBase64String",
"ToBase64String",
"base64 -d",
"base64 --decode",
"-encodedcommand",
"certutil -decode",
"certutil -encode",
"certutil /decode",
"certutil /encode"
]);
let SuspiciousParents = dynamic(["wscript.exe","cscript.exe","mshta.exe","regsvr32.exe","rundll32.exe","svchost.exe","explorer.exe","winword.exe","excel.exe","powerpnt.exe","outlook.exe"]);
// Branch 1: Process command lines with explicit encoding/decoding calls
let EncodingProcesses = DeviceProcessEvents
| where Timestamp > ago(24h)
| where ProcessCommandLine has_any (EncodingPatterns)
| extend Branch = "ExplicitEncoding"
| extend RiskScore = case(
ProcessCommandLine has_any ("certutil -decode", "certutil /decode", "certutil -encode", "certutil /encode"), 85,
InitiatingProcessFileName has_any (SuspiciousParents), 80,
ProcessCommandLine has "FromBase64String" and ProcessCommandLine has "Invoke-Expression", 90,
ProcessCommandLine has "FromBase64String" and ProcessCommandLine has "IEX", 90,
70
)
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
InitiatingProcessFileName, InitiatingProcessCommandLine,
Branch, RiskScore;
// Branch 2: PowerShell decoding combined with network or exec
let PowerShellDecode = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName in~ ("powershell.exe", "pwsh.exe")
| where ProcessCommandLine has "FromBase64String" or ProcessCommandLine has "-EncodedCommand" or ProcessCommandLine has "-enc "
| extend Branch = "PowerShellDecode"
| extend RiskScore = case(
ProcessCommandLine has "IEX" or ProcessCommandLine has "Invoke-Expression", 95,
ProcessCommandLine has "DownloadString" or ProcessCommandLine has "WebClient", 90,
75
)
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
InitiatingProcessFileName, InitiatingProcessCommandLine,
Branch, RiskScore;
// Branch 3: certutil used as a decoder (frequent LOLBin abuse)
let CertutilDecode = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName =~ "certutil.exe"
| where ProcessCommandLine has_any ("-decode", "/decode", "-encode", "/encode", "-urlcache", "/urlcache")
| extend Branch = "CertutilEncoding"
| extend RiskScore = case(
ProcessCommandLine has "-urlcache", 85,
InitiatingProcessFileName has_any (SuspiciousParents), 90,
80
)
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
InitiatingProcessFileName, InitiatingProcessCommandLine,
Branch, RiskScore;
EncodingProcesses
| union PowerShellDecode
| union CertutilDecode
| sort by RiskScore desc, Timestamp desc Data Sources
Required Tables
False Positives
- Legitimate PowerShell scripts that decode Base64-encoded configuration data or credentials from secure vaults
- certutil used by IT teams for certificate management and legitimate file encoding/decoding tasks
- Software installers and package managers that use Base64-encoded embedded payloads during installation
- Log management and SIEM agents that Base64-encode collected data before transmission to central servers
- Web application developers testing encoding/decoding functions locally
References (9)
- https://attack.mitre.org/techniques/T1132/001/
- https://en.wikipedia.org/wiki/Binary-to-text_encoding
- https://en.wikipedia.org/wiki/Base64
- https://learn.microsoft.com/en-us/defender-endpoint/advanced-hunting-deviceprocessevents-table
- https://learn.microsoft.com/en-us/sysinternals/downloads/sysmon
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1132.001/T1132.001.md
- https://research.checkpoint.com/2021/irans-apt34-returns-with-an-updated-arsenal/
- https://www.elastic.co/security-labs/spring-cleaning-with-latrodectus
- https://www.zscaler.com/blogs/security-research/lyceum-net-dns-backdoor
Unlock Pro Content
Get the full detection package for T1132.001 including response playbook, investigation guide, and atomic red team tests.