Detect Non-Standard Encoding in IBM QRadar
Adversaries may encode data with a non-standard data encoding system to make the content of command and control traffic more difficult to detect. Non-standard encoding schemes diverge from existing protocol specifications — for example, modified Base64 using a custom alphabet, XOR encoding with a static or rolling key, character substitution (replacing '/' with '-s', '+' with '-p'), or custom binary serialization. Real-world examples include OceanSalt (NOT operation on bytes), Small Sieve (hex byte swapping), TONESHELL (XOR with 32/256-byte key), NightClub (modified Base64 in DNS subdomains), RDAT (Base64 with character substitutions in DNS), InvisiMole (modified Base32 in DNS subdomains), and Uroburos (custom Base62/Base32). Detection focuses on anomalous DNS subdomain lengths and entropy, unusual encoded patterns in network traffic, and scripting processes generating high-entropy outbound data.
MITRE ATT&CK
- Tactic
- Command and Control
- Technique
- T1132 Data Encoding
- Sub-technique
- T1132.002 Non-Standard Encoding
- Canonical reference
- https://attack.mitre.org/techniques/T1132/002/
QRadar Detection Query
SELECT
DATEFORMAT(devicetime, 'yyyy-MM-dd HH:mm:ss') AS EventTime,
sourceip,
destinationip,
destinationport,
username,
LOGSOURCETYPENAME(logsourceid) AS SourceType,
QIDNAME(qid) AS EventName,
"QueryName" AS DNSQuery,
URL AS RequestURL,
"ProcessPath" AS ProcessImage,
magnitude
FROM events
WHERE
(
/* Branch 1: DNS query with encoded first subdomain label */
(
QIDNAME(qid) LIKE '%DNS%'
AND (
"QueryName" MATCHES '^[A-Za-z0-9+/=]{50,}\\..+'
OR "QueryName" MATCHES '^[A-Za-z0-9_\\-]{50,}\\..+'
OR "QueryName" MATCHES '^[0-9a-fA-F]{50,}\\..+'
)
)
OR
/* Branch 2: HTTP/S request with encoded path segment or query string parameter */
(
destinationport IN (80, 443, 8080, 8443, 8888)
AND URL IS NOT NULL
AND (
URL MATCHES '.*/[A-Za-z0-9_\\-]{60,}(/|\\?|$).*'
OR URL MATCHES '.*[?&][a-z]{1,4}=[A-Za-z0-9+/_%\\-]{60,}.*'
)
)
OR
/* Branch 3: Scripting engine process making outbound connections to public IPs */
(
"ProcessPath" MATCHES '(?i).*(python|perl|ruby|wscript|cscript|mshta|powershell|pwsh)\\..*'
AND NOT INCIDR(destinationip, '10.0.0.0/8')
AND NOT INCIDR(destinationip, '172.16.0.0/12')
AND NOT INCIDR(destinationip, '192.168.0.0/16')
AND NOT INCIDR(destinationip, '127.0.0.0/8')
AND NOT INCIDR(destinationip, '169.254.0.0/16')
)
)
LAST 24 HOURS
ORDER BY devicetime DESC QRadar AQL detection for T1132.002 across three branches: DNS events whose QueryName custom property matches Base64, URL-safe Base64, or hex encoding patterns in the first label (> 50 chars); HTTP/S flows to standard web ports containing encoded path segments or long query parameter values; and scripting engine process paths making external connections. Requires QRadar DSMs for Windows Security Event Log and Sysmon, plus custom event properties for QueryName and ProcessPath mapped via QRadar DSM editor.
Data Sources
Required Tables
False Positives & Tuning
- Enterprise endpoint agents (CrowdStrike Falcon, Microsoft Defender, Carbon Black) that use Python or PowerShell runtimes to beacon cloud management APIs with encoded host telemetry in URL parameters
- Browser extensions or enterprise SaaS tools using long Base64-encoded JWT tokens or session identifiers as HTTP query parameters for authentication and session resumption
- Custom internal REST APIs using UUID-composite path segments or Base64-encoded resource identifiers that exceed 60 characters, commonly seen in microservice architectures
Other platforms for T1132.002
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 1Simulate DNS Tunneling with Modified Base64 Subdomain Encoding
Expected signal: Sysmon Event ID 22 (DNS Query): QueryName will contain a long alphanumeric subdomain label (length > 30 characters) matching the pattern [a-z0-9ps]{30,}\.df00tech-test\.local. Sysmon Event ID 1 (Process Create): powershell.exe with command line containing Base64, Replace, and Resolve-DnsName. PowerShell ScriptBlock Log Event ID 4104 capturing the encoding logic.
- Test 2XOR-Encoded C2 Data Transmission Simulation (TONESHELL Pattern)
Expected signal: Sysmon Event ID 1: powershell.exe with CommandLine containing -bxor, New-Object System.Net.WebClient, and UploadString. Sysmon Event ID 3: Network connection attempt to 127.0.0.1:8080 (connection will be refused but event fires). PowerShell ScriptBlock Log Event ID 4104 capturing the full XOR encoding loop and WebClient upload code.
- Test 3High-Volume DNS Query Burst Simulating DNS Tunneling Data Transfer
Expected signal: 25x Sysmon Event ID 22 (DNS Query) events within ~5 seconds, each with a unique QueryName containing a long base64-like subdomain label (length 40-70 characters) under df00tech-dnstest.local. All queries initiated by powershell.exe. The burst pattern with unique subdomains matches DNS tunneling telemetry.
- Test 4HTTP C2 with Custom Base64 Alphabet Encoding (Neo-reGeorg Pattern)
Expected signal: Sysmon Event ID 1: powershell.exe with CommandLine containing IndexOf, ToCharArray, WebClient, and UploadString — all indicators of custom encoding implementation. Sysmon Event ID 3: Network connection to 127.0.0.1:8080. PowerShell ScriptBlock Log Event ID 4104 capturing the full custom alphabet encoding logic. If stream:http is available, the POST body will contain d=<60+ char custom-alphabet string>.
References (11)
- https://attack.mitre.org/techniques/T1132/002/
- https://en.wikipedia.org/wiki/Binary-to-text_encoding
- https://en.wikipedia.org/wiki/Character_encoding
- https://www.welivesecurity.com/2023/08/10/moustachedbouncer-espionage-targeted-isp-level-adversary-in-the-middle-attacks-against-belarus/
- https://unit42.paloaltonetworks.com/rdat-used-to-target-middle-eastern-energy-company/
- https://www.welivesecurity.com/2020/06/18/digging-up-invismole-hidden-arsenal/
- https://media.kasperskycontenthub.com/wp-content/uploads/sites/43/2017/08/07172148/ShadowPad_technical_description_PDF.pdf
- https://www.mandiant.com/sites/default/files/2022-02/rt-apt41-dual-operation.pdf
- https://github.com/L-codes/Neo-reGeorg
- https://www.ncsc.gov.uk/files/NCSC-GCHQ-Small-Sieve-Malware-Analysis-Report.pdf
- https://www.cisa.gov/sites/default/files/2022-02/aa22-055a-iranian-government-sponsored-actors-conduct-cyber-operations.pdf
Unlock Pro Content
Get the full detection package for T1132.002 including response playbook, investigation guide, and atomic red team tests.