Detect Standard Encoding in Splunk
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/
SPL Detection Query
index=wineventlog (sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1)
| eval CommandLine=coalesce(CommandLine, ProcessCommandLine)
| eval Image=coalesce(Image, NewProcessName)
| eval ParentImage=coalesce(ParentImage, ParentProcessName)
| eval cmdline_lower=lower(CommandLine)
| eval img_lower=lower(Image)
`comment("Branch flags for encoding patterns")`
| eval ExplicitBase64=if(match(cmdline_lower, "(frombase64string|tobase64string|base64\s+-d|base64\s+--decode)"), 1, 0)
| eval CertutilEncoding=if(match(img_lower, "certutil\.exe") AND match(cmdline_lower, "(-decode|/decode|-encode|/encode|-urlcache|/urlcache)"), 1, 0)
| eval PowerShellEncoded=if(match(img_lower, "(powershell\.exe|pwsh\.exe)") AND match(cmdline_lower, "(-encodedcommand|-enc\s|-e\s|-ec\s|frombase64string)"), 1, 0)
| eval ChainedWithExec=if(match(cmdline_lower, "(invoke-expression|iex\(|iex\s)"), 1, 0)
| eval ChainedWithDownload=if(match(cmdline_lower, "(downloadstring|downloadfile|net\.webclient|invoke-webrequest|iwr\s)"), 1, 0)
| eval SuspiciousParent=if(match(lower(ParentImage), "(wscript\.exe|cscript\.exe|mshta\.exe|regsvr32\.exe|rundll32\.exe|winword\.exe|excel\.exe|powerpnt\.exe|outlook\.exe)"), 1, 0)
| eval RiskScore=case(
ExplicitBase64=1 AND ChainedWithExec=1, 95,
ExplicitBase64=1 AND ChainedWithDownload=1, 90,
CertutilEncoding=1 AND SuspiciousParent=1, 90,
CertutilEncoding=1, 80,
PowerShellEncoded=1 AND (ChainedWithExec=1 OR ChainedWithDownload=1), 90,
PowerShellEncoded=1, 75,
ExplicitBase64=1 AND SuspiciousParent=1, 80,
ExplicitBase64=1, 70,
1==1, 0
)
| where RiskScore > 0
| eval Branch=case(
CertutilEncoding=1, "CertutilEncoding",
PowerShellEncoded=1, "PowerShellDecode",
ExplicitBase64=1, "ExplicitBase64",
1==1, "Other"
)
| table _time, host, User, Image, CommandLine, ParentImage, ParentCommandLine, Branch, ExplicitBase64, CertutilEncoding, PowerShellEncoded, ChainedWithExec, ChainedWithDownload, SuspiciousParent, RiskScore
| sort - RiskScore _time Detects standard encoding activity used for C2 traffic obfuscation using Sysmon Event ID 1 (Process Creation). Evaluates three categories: explicit Base64 API calls (FromBase64String/ToBase64String), certutil.exe encode/decode/urlcache operations, and PowerShell with EncodedCommand or Base64 decoding. A RiskScore is assigned based on combination of encoding with execution (IEX) or download cradle patterns. Higher scores indicate chained obfuscation suggesting active C2 staging.
Data Sources
Required Sourcetypes
False Positives & Tuning
- Legitimate PowerShell automation scripts decoding Base64-encoded secrets or configuration blobs
- certutil used by IT for certificate operations and legitimate file transcoding
- Software installers embedding Base64-encoded payloads during setup routines
- Monitoring agents encoding collected telemetry data before forwarding
- Build pipelines that encode/decode artifacts as part of CI/CD processing
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.