Detect Standard Encoding in Google Chronicle
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.
MITRE ATT&CK
- Tactic
- Command and Control
- Technique
- T1132 Data Encoding
- Sub-technique
- T1132.001 Standard Encoding
- Canonical reference
- https://attack.mitre.org/techniques/T1132/001/
YARA-L Detection Query
rule t1132_001_standard_encoding_c2 {
meta:
author = "df00tech"
description = "Detects T1132.001 Standard Encoding C2: Base64 encoding/decoding in process command lines via certutil LOLBin, PowerShell -EncodedCommand, and .NET Base64 conversion calls."
severity = "HIGH"
technique_id = "T1132.001"
tactic = "Command and Control"
platform = "Windows"
reference = "https://attack.mitre.org/techniques/T1132/001/"
version = "1.0"
events:
$e.metadata.event_type = "PROCESS_LAUNCH"
(
(
re.regex($e.target.process.file.full_path, `(?i)certutil\.exe`) and
re.regex($e.target.process.command_line, `(?i)(-decode|/decode|-encode|/encode|-urlcache|/urlcache)`)
) or
(
re.regex($e.target.process.file.full_path, `(?i)(powershell|pwsh)\.exe`) and
re.regex($e.target.process.command_line, `(?i)(-encodedcommand|-enc\s+|-ec\s+|frombase64string)`)
) or
re.regex($e.target.process.command_line, `(?i)(frombase64string|tobase64string|base64\s+-d\b|base64\s+--decode|\[convert\]::(from|to)base64string)`)
)
$e.principal.hostname = $hostname
condition:
$e
} Chronicle YARA-L 2.0 detection rule for T1132.001 Standard Encoding C2. Uses re.regex() against UDM PROCESS_LAUNCH fields target.process.file.full_path and target.process.command_line to detect certutil LOLBin encoding abuse, PowerShell -EncodedCommand/-enc execution, and explicit .NET Base64 conversion calls. Backtick string literals in YARA-L are raw strings passed directly to the RE2 regex engine. Fires on any single matching event.
Data Sources
Required Tables
False Positives & Tuning
- Software deployment automation (SCCM task sequences, Intune PowerShell scripts) using -EncodedCommand to safely transmit multi-line PowerShell over WMI or scheduled task XML without shell escaping issues
- PKI lifecycle management scripts calling certutil with -decode or -encode for certificate format conversion (DER to PEM, CER to P7B) during enterprise CA operations
- Backup and recovery agents using .NET Base64 conversion (FromBase64String/ToBase64String) for encryption key serialization or configuration blob handling in PowerShell management modules
Other platforms for T1132.001
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 1PowerShell Base64 Encode and Decode Round-Trip
Expected signal: Sysmon Event ID 1: Process Create with CommandLine containing 'ToBase64String', 'FromBase64String', and 'IEX'. PowerShell ScriptBlock Log Event ID 4104 will capture the decoded content 'hostname; whoami'. Security Event ID 4688 (if command line auditing enabled) with full command line.
- Test 2certutil Base64 Decode to File
Expected signal: Sysmon Event ID 1: Process Create with Image=certutil.exe, CommandLine containing '-decode' and file paths. Sysmon Event ID 11: File Create events for both %TEMP%\encoded.b64 and %TEMP%\decoded.txt. Security Event ID 4688 with certutil command line (if auditing enabled).
- Test 3Base64 Encoded C2 Beacon Simulation via PowerShell
Expected signal: Sysmon Event ID 1: Process Create with CommandLine containing 'ToBase64String', 'Net.WebClient', and 'UploadString'. Sysmon Event ID 3: Network Connection attempt to 127.0.0.1:8888 (will fail — no listener). PowerShell ScriptBlock Log Event ID 4104 capturing the full encoding + upload script.
- Test 4Linux Base64 C2 Exfil Simulation via curl
Expected signal: Linux auditd or Sysmon for Linux: process creation events for 'base64' and 'curl' with command line arguments. Syslog: process execution entries. Network: outbound connection attempt to 127.0.0.1:9999 from curl.
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.