Obfuscated Files or Information
| Technique | Obfuscated Files or Information (T1027) |
| Tactic | Stealth |
| Platforms | ESXi, Linux, macOS, Network Devices, Windows |
Overview
Obfuscated Files or Information (T1027) describes the practice of encoding, encrypting, compressing, or otherwise obscuring malicious content to make it harder for defenders and automated tools to identify it. Attackers use this technique to smuggle payloads past security controls, hide malicious strings from static analysis, and conceal commands that would otherwise trigger signature-based detections.
Because obfuscation is woven into nearly every stage of the attack lifecycle — from initial delivery through execution, persistence, and exfiltration — every security team must be able to recognize its patterns. Missing T1027 activity often means missing the entire intrusion, since obfuscation is frequently the wrapper around every other technique an adversary uses.
Attacker Perspective
Attackers treat obfuscation as a prerequisite, not an afterthought — it is the first layer of defense against defenders.
- PowerShell encoded commands: Adversaries invoke PowerShell with the
-EncodedCommandflag (e.g.,powershell.exe -NoP -NonI -W Hidden -Enc JABjAGwAaQBlAG4AdA...) to pass Base64-encoded scripts that bypass command-line logging and many EDR signature rules. - Packed or crypted executables: Tools like
UPX, custom packers, or commercial crypters (e.g., Themida, VMProtect) compress and encrypt PE binaries so that static AV signatures do not match the payload until it is unpacked in memory at runtime. - Obfuscated JavaScript/VBScript in phishing lures: Threat actors distribute
.jsor.htafiles with heavily concatenated, substituted, or reversed strings — for example,eval(String.fromCharCode(...))— to bypass email gateway scanning and deliver droppers. - Layered archive delivery: Malware families such as Emotet and QakBot deliver payloads inside password-protected ZIP files nested inside ISO or IMG containers, requiring user interaction to unlock, and preventing automated sandbox detonation without the password.
Obfuscation is attractive because it is cheap to apply, dramatically raises the cost and complexity of defender analysis, and a single obfuscation layer can invalidate entire categories of signature-based detection with minimal attacker effort.
Detection Strategy
Required Telemetry
- Windows PowerShell Script Block Logging (Event ID 4104): Enable via GPO at
HKLM\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging → EnableScriptBlockLogging = 1. This logs the decoded content of every script block PowerShell executes, including Base64-decoded payloads. Without this, encoded PowerShell is nearly invisible. - Windows PowerShell Module Logging (Event ID 4103): Enable via GPO at
HKLM\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ModuleLogging → EnableModuleLogging = 1. Captures pipeline execution details and module-level activity that Script Block Logging may miss. - Windows Process Creation (Event ID 4688): Requires enabling “Audit Process Creation” under Advanced Audit Policy Configuration and enabling command-line logging via
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\Audit → ProcessCreationIncludeCmdLine_Enabled = 1. Captures the full command line for every spawned process. - Sysmon Event ID 1 (Process Create): Sysmon provides richer process telemetry than native 4688, including parent process GUID, full command line, file hashes, and image paths. Deploy using a community-vetted configuration such as the SwiftOnSecurity Sysmon config. Also enable Sysmon Event ID 7 (Image Loaded) to detect packed modules loaded into processes.
- Sysmon Event ID 11 (File Create): Captures files written to disk, including dropped archives, encoded scripts, or payloads written by parent processes. Useful for correlating what was decoded and staged.
- Windows Security Event ID 4657 / Sysmon Event ID 13 (Registry Value Set): Detects encoded payloads stored in the registry — a common persistence technique that pairs with T1027. Enable object access auditing for sensitive registry paths.
- EDR telemetry (CrowdStrike, Defender for Endpoint, SentinelOne, etc.): Most EDRs surface memory scanning results, unpacked PE detection, and script engine activity that supplements SIEM-based log analysis. Ensure alerts and raw telemetry are forwarded to the SIEM.
- Email gateway logs: Capture attachment types, file names, archive nesting depth, and password-protection flags. Solutions like Proofpoint, Mimecast, or Microsoft Defender for Office 365 log these details and should be ingested into the SIEM.
- Linux auditd rules: Add rules to capture script interpreter invocations and base64 decoding activity:
-a always,exit -F arch=b64 -S execve -F exe=/usr/bin/python3 -k obfuscated_exec
-a always,exit -F arch=b64 -S execve -F exe=/bin/bash -k shell_exec
Enableausearchand forward logs to your SIEM via auditbeat or syslog. Also enableexecveargument capture so that command-line arguments are included in audit records. - macOS Unified Logging / Endpoint Security Framework: Use an EDR or osquery to capture
processevents including command-line arguments. Enable macOS audit via/etc/security/audit_controlwith theloandexflags to capture login and execution events. - Network proxy / DNS logs: Capture full URLs, hostnames, response codes, and payload sizes. Encoded or encrypted data exfiltration often presents as high-entropy subdomains or unusually large DNS TXT record responses. Ingest Squid, Zscaler, Palo Alto, or equivalent logs into the SIEM.
Key Indicators
- Base64-encoded PowerShell commands: In Event ID 4688 or Sysmon Event ID 1, check
CommandLinefor the presence of-EncodedCommand,-enc, or-efollowed by a long Base64 string. Example pattern:powershell.exe.*(-enc|-EncodedCommand|-e)\s+[A-Za-z0-9+/=]{20,}. - Decoded payload content revealing malicious strings: In PowerShell Script Block Logging Event ID 4104, check the
ScriptBlockTextfield for decoded content containingIEX,Invoke-Expression,DownloadString,Net.WebClient,FromBase64String, orSystem.Reflection.Assembly. - High-entropy command-line strings: In
CommandLinefields across any process creation log, strings with entropy above approximately 4.5 bits per character that are longer than 50 characters are strong indicators of encoded or encrypted content. This is especially suspicious for interpreter processes likewscript.exe,cscript.exe,mshta.exe, orcmd.exe. - Suspicious parent-child process relationships involving interpreters: In Sysmon Event ID 1, flag chains such as
winword.exe → cmd.exe → powershell.exe,excel.exe → wscript.exe, oroutlook.exe → mshta.exe. These represent Office macros or lures spawning script interpreters to execute obfuscated payloads. - Use of certutil or built-in decoders: In process creation logs, look for
certutil.exe -decode,certutil.exe -urlcache,expand.exe, orcopy /b(binary concatenation). These are common living-off-the-land techniques for decoding obfuscated payloads without external tools. - Compressed or encoded files written to temp directories: In Sysmon Event ID 11, check
TargetFilenamefor files with extensions such as.b64,.enc,.dat, or archives (.zip,.7z,.rar) written to%TEMP%,%APPDATA%, orC:\Users\Public. - Linux base64 decode pipelines: In auditd execve records, look for command lines matching patterns like
echo [A-Za-z0-9+/=]{20,} | base64 -d | bashorpython3 -c "import base64...". Check thea0,a1,a2argument fields in audit records. - High-entropy DNS subdomains: In DNS query logs, flag subdomains where the subdomain portion has calculated Shannon entropy above 3.5 bits per character and length exceeds 30 characters — a signature of DNS tunneling or encoded C2 beaconing.
- Password-protected archives received via email: In email gateway logs, check attachment metadata fields for
is_encrypted = trueorpassword_protected = truecombined with archive MIME types (application/zip,application/x-7z-compressed), especially when the password appears in the email body.
Detection Logic
Rule 1 (Broad — High Sensitivity): PowerShell Encoded Command Execution
IF process_name = "powershell.exe" AND CommandLine MATCHES "(-enc|-EncodedCommand|-e)\s+[A-Za-z0-9+/=]{20,}" AND NOT parent_process IN ["sccm.exe", "ccmexec.exe", "wsus_approved_deployer.exe"] THEN alert HIGH
This catches the most common obfuscated PowerShell delivery mechanism used by commodity and advanced malware alike. Expect moderate-to-high volume in environments without exclusions; SCCM and management tooling are the primary false positive sources and should be baselined and excluded by verified parent process name and signing certificate.
Rule 2 (Medium — Balanced): Script Block Logging Detects Decoded Malicious Functions
IF event_id = 4104 AND ScriptBlockText MATCHES "(IEX|Invoke-Expression|DownloadString|FromBase64String|Net\.WebClient|Reflection\.Assembly\.Load)" AND ScriptBlockText NOT MATCHES "(Test-|Get-Help|Example)" THEN alert HIGH
This rule fires on the decoded content after PowerShell has already done the decoding work, making it significantly harder for attackers to evade by varying their encoding. False positive volume is low; most legitimate administrative scripts do not combine these patterns. Tune out known-good scripts by their script block hash field (ScriptBlockId).
Rule 3 (Medium — Living Off the Land): Certutil Used for Decoding
IF process_name = "certutil.exe" AND CommandLine MATCHES "(-decode|-decodehex|-urlcache)" AND NOT parent_process IN ["msiexec.exe"] AND NOT CommandLine MATCHES "C:\\Windows\\System32\\catroot" THEN alert MEDIUM
Certutil is a native Windows binary with no legitimate reason to decode arbitrary Base64 files in most enterprise environments. This rule has low false positive volume and high precision. Alert on any match outside of documented PKI workflows.
Rule 4 (Narrow — High Precision): Office Application Spawning Obfuscated Script Interpreter
IF parent_process IN ["winword.exe", "excel.exe", "powerpnt.exe", "outlook.exe"] AND process_name IN ["powershell.exe", "wscript.exe", "cscript.exe", "mshta.exe", "cmd.exe"] AND CommandLine MATCHES "(-enc|frombase64|eval\(|execute\(|chr\()" THEN alert CRITICAL
This combination — a document spawning an interpreter running obfuscated code — represents a high-confidence malicious execution chain. False positive volume is extremely low; alert immediately and escalate to incident response without waiting for further correlation.
Tuning Guidance
- SCCM / Endpoint Management Deployments: SCCM and Intune frequently execute PowerShell with encoded commands for legitimate software deployment. Identify the specific SCCM client process (
CcmExec.exe), confirm it is signed by Microsoft, and exclude it byparent_process = "CcmExec.exe"ANDprocess_signature = "Microsoft Corporation". Do not exclude by command-line pattern alone as attackers may spoof this. - Security and monitoring tools: EDR agents, vulnerability scanners (Tenable, Qualys), and monitoring scripts frequently use Base64 encoding internally. Identify these by their installation path (e.g.,
C:\Program Files\Tenable\) and code-signing certificate, then add path-based and signature-based exclusions rather than broad process name exclusions. - Developer and DevOps workstations: Developers working with build pipelines (Azure DevOps, Jenkins agents, GitHub Actions runners) routinely invoke encoded commands as part of CI/CD scripts. Segment these hosts into a known-good group in your SIEM and apply a separate, tighter ruleset rather than blanket exclusions. Flag any encoded command that reaches out to an external IP even from these hosts.
- Legitimate archive encryption: Data protection policies may require users to send encrypted ZIP files. Tune email gateway rules by correlating with HR-approved file sharing workflows, and exclude internal-to-internal transfers where both sender and recipient are in the corporate directory. Flag all external recipients receiving password-protected archives regardless of exclusions.
- High-entropy false positives from legitimate applications: Some applications generate long Base64 strings for token passing or configuration embedding. Baseline these applications using process path, signing information, and known parent processes, and suppress at the application level rather than disabling entropy-based detection globally.
When the Alert Fires: Investigation Steps
- Verify the alert is real by confirming the raw event exists in the originating log source. Pull the raw Event ID 4104 or Sysmon Event ID 1 record from your SIEM and confirm the
ScriptBlockTextorCommandLinefield contains the flagged content — rule out parsing errors or SIEM ingestion artifacts before proceeding. - Identify the affected host and user account, and flag immediately if either is privileged. In your SIEM, correlate the process creation event with the associated
SubjectUserName(Event ID 4688) or Sysmon’sUserfield; cross-reference against your directory (Active Directory or Okta) to determine if the account holds admin, service, or privileged access roles. - Pull the full process tree — parent, grandparent, and all child processes — for the time window surrounding the alert. Use Sysmon Event ID 1 records filtered by the host and a 30-minute window around the alert time, tracing the
ParentProcessGuidchain; in CrowdStrike or Defender for Endpoint, use the process tree visualization to confirm whether the chain originates from a user-facing application, a scheduled task, or a remote execution mechanism like WMI or PSExec. - Decode the obfuscated content manually to determine the intended payload. Copy the Base64 string from the
CommandLineorScriptBlockTextfield and decode it in an isolated environment usingcertutil -decodeor Python (base64.b64decode()); look for URLs, IP addresses, additional encoded layers, or function names that reveal the next stage of the attack chain. - Check for network connections and files written to disk at the time of execution. Correlate Sysmon Event ID 3 (Network Connect) and Event ID 11 (File Create) records for the same process GUID and timeframe; note any external IP or domain contacted and any files dropped in
%TEMP%,%APPDATA%, or unusual directories, then submit file hashes to VirusTotal or your threat intel platform. - Look for lateral movement originating from the affected host following the obfuscated execution event. Query your SIEM for Event ID 4624 Type 3 (network logons) or 4648 (explicit credential use) originating from the host in the 4-hour window after the alert; also check Sysmon Event ID 3 for connections to SMB (port 445), WinRM (port 5985/5986), or RDP (port 3389) targeting internal assets.
- Make the escalation decision based on decoded payload intent, network activity, and persistence indicators. If the decoded content contains a downloader, reverse shell, or credential harvester — or if any of the subsequent checks reveal external connections, dropped executables, or new scheduled tasks — escalate immediately to a confirmed incident; if the content is verifiably a known-good administrative script that was simply encoded for transport, document the finding, add the exclusion, and close as a false positive with a tuning ticket.
Response Playbook
Containment
- Isolate the affected host from the network immediately but leave it powered on for forensic memory capture. Use your EDR’s network isolation feature (CrowdStrike “Contain Host,” Defender for Endpoint “Isolate Device,” SentinelOne “Network Quarantine”) to block all inbound and outbound traffic except the EDR management channel. Do not reimage or power off until memory acquisition is complete.
- Capture a memory image before any further remediation actions. Use WinPmem, DumpIt, or your EDR’s memory acquisition capability on the live host to preserve in-memory unpacked payloads, injected code, and decrypted strings that will be lost on reboot.
- Disable the affected user account at the directory level to prevent credential reuse. In Active Directory, use
Disable-ADAccount -Identity [username]or the Azure AD portal; if the account is a service account, coordinate with the application owner before disabling and rotate the credentials immediately. - Block identified C2 IP addresses and domains at the perimeter firewall, web proxy, and DNS resolver. Submit the IOCs from your decoded payload analysis to your firewall team and DNS sinkhole immediately; in Palo Alto, create a Dynamic Address Group entry; in Zscaler, add to the URL category blocklist. Confirm blocks are active and log all subsequent attempts to reach the blocked destinations.
- Kill the malicious process and terminate any active remote sessions tied to the affected account. Use your EDR to terminate the process by PID; simultaneously revoke active SSO tokens and Kerberos tickets for the account (
klist purgeon the host, reset the account password to force ticket invalidation at the DC).
Eradication
- Remove all identified persistence mechanisms linked to the obfuscated payload. Check and remove malicious scheduled tasks (
schtasks /query, Autoruns from Sysinternals), registry run keys (HKCU\Software\Microsoft\Windows\CurrentVersion\RunandHKLMequivalents), malicious services (sc query), and WMI subscriptions (Get-WMIObject -Namespace root\subscription). Cross-reference findings against your Sysmon Event ID 12/13/14 and Event ID 4698/4702 (scheduled task) records. - Search for and delete all dropped payloads, decoded scripts, and staging files. Use the file paths identified in your Sysmon Event ID 11 investigation to locate and remove artifacts; run a hash-based search across your EDR for the identified file hashes on all endpoints to find lateral spread of the same payload.
- Reset credentials for every account that executed or was touched by the malicious activity. Reset the primary affected account’s password, any accounts whose credentials may have been harvested (check for LSASS access via Sysmon Event ID 10 or credential-dumping tool indicators), and all service accounts on the affected host. Enforce MFA re-enrollment where applicable.
- Inspect all lateral movement targets for secondary payloads or backdoors. For every host the affected account authenticated to in the 24 hours surrounding the incident, run a targeted EDR hunt for the same file hashes, process names, and registry keys identified on the primary host; treat any match as a separate infection requiring the same containment and eradication process.
- Rotate any API keys, secrets, or certificates that were accessible to the compromised account or process. Review what secrets the affected account had access to in your secrets manager (HashiCorp Vault, AWS Secrets Manager, Azure Key Vault), invalidate and reissue them, and audit access logs for those secrets in the 72 hours preceding the incident.
Recovery
- Reimage the affected host if confidence in complete eradication is less than certain. If the decoded payload included a rootkit, a packer with unknown capabilities, or if memory forensics revealed injected code in system processes, reimage from a known-good baseline rather than attempting to clean in place — the risk of residual access outweighs the operational cost of reimaging.
- Re-enable the affected user account only after confirming no persistence mechanisms remain and credentials have been reset. Require the user to re-authenticate with MFA, brief them on the phishing or delivery vector that was used, and monitor their account with enhanced logging for 72 hours post-restoration.
- Reconnect the remediated host to the network in a monitored segment before returning it to full production. Keep the host in an elevated-monitoring VLAN or EDR watchlist for at least 72 hours, alert on any process creation, network connection, or file write that matches the IOC profile from this incident.
- Document the full attack timeline from initial delivery through containment, including every IOC and every action taken. Record decoded payload content, all file hashes, C2 addresses, affected accounts, and the initial delivery vector in your incident response platform (ServiceNow, TheHive, Jira); share IOCs with your threat intel platform and any relevant ISACs.
- Update detection rules with new IOCs and close identified telemetry gaps discovered during the investigation. If any detection gap was identified — for example, Script Block Logging was not enabled on a subset of hosts — raise a hardening ticket immediately; update your SIEM rules with new Base64 patterns, process names, or file paths discovered during the investigation, and schedule a 30-day review to validate the new rules are firing correctly.
Stay Ahead
Get daily threat intelligence and detection playbooks.
Free. No account. No email. Follow in Feedly, Inoreader, or any RSS reader.