Detect Data Encoding in Splunk
Adversaries may encode data 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. Use of data encoding may adhere to existing protocol specifications and includes use of ASCII, Unicode, Base64, MIME, or other binary-to-text and character encoding systems. Some data encoding systems may also result in data compression, such as gzip. Real-world examples include BADNEWS converting encrypted C2 data to hexadecimal then Base64 before transmission, Ursnif embedding Base64-encoded data in HTTP URLs, H1N1 using an altered Base64 scheme for C2 traffic, and Linux Rabbit sending encoded payloads as URL parameters.
MITRE ATT&CK
- Tactic
- Command and Control
- Technique
- T1132 Data Encoding
- Canonical reference
- https://attack.mitre.org/techniques/T1132/
SPL Detection Query
index=wineventlog sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1
| eval cmdline=lower(CommandLine)
| eval img=lower(Image)
| eval parent_img=lower(ParentImage)
`comment("Branch 1: certutil encoding/decoding LOLBin usage")`
| eval CertutilEncoding=if(
match(img, "certutil\\.exe") AND match(cmdline, "(-encode|-decode|-urlcache)"),
1, 0)
`comment("Branch 2: scripting interpreter combining encoding and network primitives")`
| eval ScriptEncodeNet=if(
match(img, "(python[23]?\\.exe|perl\\.exe|php\\.exe|ruby\\.exe|node\\.exe|nodejs)")
AND match(cmdline, "(base64|b64encode|b64decode|binascii|hexlify|unhexlify|zlib|gzip|btoa|atob|urllib\\.parse\\.quote|hex_codec)")
AND match(cmdline, "(http://|https://|ftp://|socket|urllib\\.request|requests\\.|connect\\()"),
1, 0)
`comment("Branch 3: PowerShell Base64 conversion with network class usage")`
| eval PSEncodeNet=if(
match(img, "(powershell\\.exe|pwsh\\.exe)")
AND match(cmdline, "(frombase64string|tobase64string|\\[convert\\]::|system\\.convert)")
AND match(cmdline, "(net\\.webclient|invoke-webrequest|invoke-restmethod|tcpclient|udpclient|uploadstring|downloadstring)"),
1, 0)
`comment("Branch 4: curl or wget invoked with long Base64 or hex-encoded argument strings")`
| eval EncodedNetUtil=if(
match(img, "(curl\\.exe|wget\\.exe|\\bcurl$|\\bwget$)")
AND (match(cmdline, "[a-z0-9+/]{60,}={0,2}") OR match(cmdline, "[0-9a-f]{80,}")),
1, 0)
| eval TotalScore=CertutilEncoding + ScriptEncodeNet + PSEncodeNet + EncodedNetUtil
| where TotalScore > 0
| table _time, host, User, Image, CommandLine, ParentImage, ParentCommandLine,
CertutilEncoding, ScriptEncodeNet, PSEncodeNet, EncodedNetUtil, TotalScore
| sort - _time Detects encoded C2 communication patterns using Sysmon Event ID 1 (Process Creation) with a four-branch scoring approach. Branch 1 flags certutil.exe -encode/-decode/-urlcache (LOLBin encoding helper). Branch 2 flags scripting interpreters whose command lines simultaneously reference encoding libraries (base64, binascii, hexlify, zlib) and network operations (urllib, socket, http). Branch 3 flags PowerShell combining Base64 conversion APIs with WebClient or network classes. Branch 4 flags curl/wget with embedded long Base64 or hex-encoded strings. The cumulative TotalScore lets analysts prioritize events where multiple indicators co-occur, which strongly differentiates malicious automated encoding from incidental legitimate Base64 usage.
Data Sources
Required Sourcetypes
False Positives & Tuning
- Software deployment tools (SCCM, Intune, Ansible) that use certutil -decode or -urlcache to deliver installer payloads from internal distribution servers
- Data science and DevOps pipelines (CI/CD agents, Terraform, configuration management) that Base64-encode credentials or configuration blobs before transmitting to APIs
- Application monitoring agents (Datadog, Splunk UF, New Relic) that encode telemetry payloads before posting to SaaS collection endpoints
- Web developers testing REST APIs with curl, passing Base64-encoded Bearer tokens or JSON payloads in request bodies
- Security tooling including vulnerability scanners and SIEM forwarders that encode log data or signatures during transmission
Other platforms for T1132
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 1certutil Base64 Encode Reconnaissance Output and Transmit via curl
Expected signal: Sysmon Event ID 1: Process Create for certutil.exe with CommandLine containing '-encode %TEMP%\recon_out.txt'. Sysmon Event ID 11: File Create for %TEMP%\recon_encoded.b64. Sysmon Event ID 1: Subsequent Process Create for curl.exe with CommandLine containing '--data-binary @' and the encoded temp file. Sysmon Event ID 3: Network Connection from curl.exe to 127.0.0.1:8080 (connection refused, but event fires).
- Test 2Python Base64-Encoded System Fingerprint Beacon
Expected signal: Sysmon Event ID 1: Process Create for python.exe (or python3.exe) with CommandLine containing 'base64', 'urllib.request', 'socket', and 'os'. Sysmon Event ID 3: Network Connection attempt from python.exe to 127.0.0.1:8080.
- Test 3PowerShell ToBase64String with WebClient POST
Expected signal: Sysmon Event ID 1: Process Create for powershell.exe with CommandLine containing 'ToBase64String', '[System.Convert]::', 'Net.WebClient', and 'UploadString'. Sysmon Event ID 3: Network Connection attempt from powershell.exe to 127.0.0.1:8080. PowerShell ScriptBlock Log Event ID 4104 in Microsoft-Windows-PowerShell/Operational captures the full script including the ToBase64String call.
- Test 4Hex-Encoded C2 Data via Python binascii and subprocess curl
Expected signal: Sysmon Event ID 1: Process Create for python.exe with CommandLine containing 'binascii', 'hexlify', and 'subprocess'. Sysmon Event ID 1: Child Process Create for curl.exe with CommandLine containing 'http://127.0.0.1:8080/q?d=' followed by a hex-encoded string of 40+ characters. Sysmon Event ID 3: Network Connection attempt from curl.exe to 127.0.0.1:8080.
References (12)
- https://attack.mitre.org/techniques/T1132/
- https://attack.mitre.org/techniques/T1132/001/
- https://attack.mitre.org/techniques/T1132/002/
- https://en.wikipedia.org/wiki/Binary-to-text_encoding
- https://en.wikipedia.org/wiki/Character_encoding
- https://arxiv.org/ftp/arxiv/papers/1408/1408.1136.pdf
- https://www.proofpoint.com/us/threat-insight/post/ursnif-variant-dreambot-adds-tor-functionality
- https://www.anomali.com/blog/pulling-linux-rabbit-rabbot-malware-out-of-a-hat
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1132/T1132.md
- https://learn.microsoft.com/en-us/defender-endpoint/advanced-hunting-devicenetworkevents-table
- https://learn.microsoft.com/en-us/defender-endpoint/advanced-hunting-deviceprocessevents-table
- https://docs.splunk.com/Documentation/SplunkCloud/latest/SearchReference/CommonStatsFunctions
Unlock Pro Content
Get the full detection package for T1132 including response playbook, investigation guide, and atomic red team tests.