Skip to content
Pwnversity
MAL-OBFUSadvanced · 6 min · upd. 2026-10

Obfuscation and Packing

T1027T1027.002T1140

Malware hides its real logic to hinder analysis and break static signatures. Two big technique families: obfuscation (transforming code and strings so they’re unreadable but functionally identical) and packing (compressing/encrypting the whole executable, which only decompresses in memory at runtime). This page looks at them from the analyst’s side: recognizing and reversing them is the step before understanding the sample; for the defender, both break simple signatures but not runtime behavior.

All obfuscation is a trade-off: the more it hides the code, the more it has to reveal at runtime. A packer protects the binary on disk, but at some point it decompresses the real code in memory and jumps to it — and that’s where the analyst catches it. So the defensive strategy isn’t to “beat” the packer statically, but to force the runtime (see Dynamic analysis) and sign over memory. Obfuscation raises the cost of analysis; it doesn’t make it impossible.

Packing: executable compression and encryption

Section titled “Packing: executable compression and encryption”

A packer wraps the original binary: on disk you see the stub (unpacker) plus the encrypted/compressed data; at runtime, the stub decompresses the real code in memory and jumps to its OEP (Original Entry Point).

Static signs of packing:

  • High entropy in sections (encrypted/compressed data).
  • Few imports (resolved at runtime): tiny IAT.
  • Odd section names (UPX0, .packed) or RWX sections.
  • Almost no strings statically but many at runtime.

Detect It Easy (DIE) and PEstudio identify the packer and give per-section entropy.

Ventana de terminal
upx -d sample.exe # standard UPX (if not modified)

For custom or commercial packers (VMProtect, Themida), unpack dynamically:

  1. Run under a debugger to the OEP (right after in-memory unpacking).
  2. Dump the already-unpacked process (pe-sieve, Scylla, Process Hacker → dump).
  3. Rebuild the IAT and analyze the dump statically.

Automated: sandboxes like CAPE often dump the unpacked payload for you (see Dynamic analysis).

flowchart LR
  O[Original] --> F[Control-flow flattening]
  O --> P[Opaque predicates]
  O --> J[Junk code]
  O --> H[API hashing]
  O --> V[Code virtualization]
  V -.hardest.-> X[Analysis cost]
  H --> X
  F --> X
  • Control-flow flattening — flattens the flow into a loop+dispatcher; the graph becomes unreadable.
  • Opaque predicates — always-true/false conditions that confuse analysis.
  • Junk code — no-effect instructions that bloat and mislead.
  • API hashing — instead of importing VirtualAlloc by name (an IOC), it hashes the name and resolves it at runtime, breaking import-based analysis.
  • Code virtualization — a custom interpreter runs custom bytecode; the most expensive to reverse.

API hashing is everywhere: to recover which APIs the sample uses you must replicate its hash function and cross it with the DLLs’ exports (IDA/Ghidra plugins automate this).

Encrypted or stacked strings (stackstrings) built at runtime. To reverse them: FLOSS extracts them statically (see Static analysis); or you locate the decryption routine; or you dump memory dynamically, where they already appear in cleartext.

Techniques: base64, concatenation, character replacement, compression (Gzip/Deflate), indirect invocation (IEX), environment variables, chained encoding. To deobfuscate:

  • CyberChef — chains base64, gunzip, XOR, etc.
  • PowerShell: replace IEX with Write-Output to see the script instead of running it.
  • box-js / malware-jail for JavaScript; olevba for VBA.
  • Script Block Logging (4104) captures already-deobfuscated PowerShell (see PowerShell for hacking).

In authorized exercises, obfuscation tests whether the client’s static signatures hold up against variants of the same artifact. What matters for the report isn’t “I evaded”, but which layer saw it again: if in-memory behavior or EDR telemetry still detect it, the obfuscation added nothing. Always within scope and measuring detection.

  • By behavior, not static signature: obfuscation/packing breaks disk signatures, but runtime injection, network, and encryption are still detectable by EDR.
  • High entropy and API hashing are suspicious signals in themselves; use them as enrichment, not a verdict.
  • YARA over memory (not just disk): the unpacked sample in memory does have signatures (YARA).
  • AMSI and Script Block Logging capture scripts after deobfuscation — the key moment for PowerShell/VBA.
  • RWX section loads and anomalous image loads (Sysmon 7) as hints of in-memory unpacking.

If a sample is heavily obfuscated/virtualized, prioritize dynamic analysis and config extraction over exhaustive reversing: it usually yields actionable IOCs sooner.

  • UPX is the most-used free packer (and the easiest to reverse); its abuse is so common that “packed with modified UPX” is almost a genre.
  • Themida/VMProtect (virtualization) appear in families that want to maximize analysis cost.
  • Office blocking macros by default (2022) pushed loaders toward obfuscated containers (ISO/LNK/OneNote) and heavily encoded PowerShell scripts.
  • ATT&CK: T1027 (Obfuscated Files or Information), T1027.002 (Software Packing), T1140 (Deobfuscate/Decode Files or Information).
  • Packing detected (entropy, few imports, DIE/PEstudio)
  • Unpacked (UPX -d; or dynamic: OEP + dump)
  • IAT rebuilt and dump analyzed
  • Code obfuscation identified (flattening, API hashing, virtualization)
  • API hashing resolved (IDA/Ghidra plugins)
  • Obfuscated strings extracted (FLOSS / memory dump)
  • Scripts deobfuscated (CyberChef, olevba, Script Block Logging)
  • YARA over memory after unpacking (YARA)