Most malware that reaches an analyst's desk is packed, so the file on disk tells you almost nothing about what the program actually does. Packers, crypters and protectors compress, encrypt or virtualise the real code and only reveal it in memory at run time, which defeats static signatures and slows triage. This guide explains what each kind of packer does, the indicators that tell you a sample is packed, the general static and dynamic approaches analysts use to recover the payload, the lab safety requirements that must come first, and what packing means for antivirus and YARA detection. It is written for malware analysts and DFIR practitioners, and it stays at concept level: it is not a walkthrough for unpacking live malware. It builds on the Malware Analysis Guide for Defenders, which covers the wider analysis workflow.
Key takeaways
- Packing is a symptom, not a verdict. Legitimate software is packed too, so a packed file needs analysis, not automatic condemnation.
- Several weak indicators beat one strong one. High entropy, a sparse import table, odd section names and a large gap between raw and virtual section size together point to packing far more reliably than any single measure.
- The payload lives in memory. Most packers decompress or decrypt the original code at run time, so dynamic analysis and memory capture usually recover more than static work on the file.
- Isolation comes before curiosity. Unpacking means letting malware run; do it only in a dedicated, isolated lab with snapshots, no shared folders and controlled network access.
- Detect the behaviour, not just the wrapper. Signatures on a packer stub break with every repack; rules on the unpacked payload, memory scanning and behavioural telemetry last longer.
What packers, crypters and protectors do
MITRE ATT&CK tracks packing as T1027.002 Software Packing, a sub-technique of T1027 Obfuscated Files or Information, under the Stealth tactic in ATT&CK v20. ATT&CK describes packing as compressing or encrypting an executable so its file signature changes, notes that most packers decompress the code in memory, and names MPRESS and UPX as example packers while warning that adversaries may build custom packers that leave fewer known artefacts. See the T1027 Obfuscated Files or Information page for the parent technique.
| Type | What it does to the code | Typical goal | What the analyst faces |
|---|---|---|---|
| Compressor (packer) | Compresses the original sections and adds a small stub that decompresses them in memory before jumping to the original entry point | Smaller files; also changes the hash and static signatures | Usually the easiest case; well-known compressors are often identified by name |
| Crypter | Encrypts the payload and decrypts it at run time, often with a key stored in the stub or derived at run time | Defeat signature-based scanning; resell as a service to other criminals | High-entropy blobs, sometimes several layers, often combined with process injection |
| Protector | Adds anti-debugging, anti-tamper and integrity checks around the code | Protect intellectual property (legitimate use) or frustrate analysis (malicious use) | Analysis is slowed by checks that change behaviour when tools are present |
| Virtualising protector | Translates original code into a custom bytecode run by an embedded virtual machine, as ATT&CK describes | Make the original logic very costly to reconstruct | The original instructions may never exist in memory; behavioural analysis matters more than full recovery |
| Embedded or staged payload | Hides an encrypted or encoded payload inside another file or resource and extracts it later (T1027.009 Embedded Payloads, T1027.013 Encrypted/Encoded File) | Separate the loader from the payload | The first file is a loader; the real sample is the next stage. See the Malware Loaders and Droppers Guide |
The run-time step that reveals the code is itself tracked as T1140 Deobfuscate/Decode Files or Information. Packers that check for analysis tools overlap with T1497 Virtualization/Sandbox Evasion and T1622 Debugger Evasion, which is why a sample can behave differently in a lab than on a victim host.
Legitimate use: Commercial software uses compressors to reduce size and protectors to deter cracking. UPX, for example, is an open source executable compressor (GPLv2 or later) for Windows programs and DLLs and Linux executables, and its documentation says you can "list, test and unpack" files it produced. This is why packing alone should raise a sample's priority, not decide its verdict.
Recognising a packed sample
No single test proves packing. Analysts combine structural indicators from the file header with content measures. The PE examples below apply to Windows files; ELF and Mach-O have equivalent structures.
| Indicator | What to look at | What suggests packing | Caveats |
|---|---|---|---|
| Entropy | Shannon entropy of the whole file and of each section (0 to 8 bits per byte) | Sections close to the maximum (commonly above about 7), especially an executable section | Compressed resources, images and installers are high entropy too; measure per section |
| Import table | Number of imported DLLs and functions | Very few imports, often only functions that load libraries, resolve addresses and allocate or protect memory | Small legitimate tools can also have short import lists |
| Section names | Names in the section table | Names associated with known packers (for example UPX0 and UPX1) or random strings instead of familiar names such as .text, .rdata and .rsrc | Microsoft's PE specification warns tools not to assume particular section names; names are easy to change |
| Raw versus virtual size | SizeOfRawData and VirtualSize for each section | A section with little or no data on disk but a large size in memory, waiting to be filled at run time | Sections holding only uninitialised data legitimately have a raw size of zero |
| Section permissions | Section characteristics flags | A section that is both writable (IMAGE_SCN_MEM_WRITE, 0x80000000) and executable (IMAGE_SCN_MEM_EXECUTE, 0x20000000) | Some legitimate runtimes and JIT compilers need writable code |
| Entry point location | AddressOfEntryPoint and the section that contains it | Entry point in the last section or outside the main code section | Some linkers and installers place entry points unusually |
| Overlay | Data appended after the last section | A large, high-entropy overlay carrying an embedded payload | Installers and signed files often carry overlays |
| Strings | Readable strings in the file | Very few meaningful strings, no URLs, paths or error messages | String obfuscation can exist without packing |
Packer identification tools match stub signatures and report a likely packer name; treat that as a hint, because custom and modified packers will not match and signatures can produce false matches. The YARA pe module exposes many of the fields above (section names, raw and virtual sizes, characteristics, the entry point, import counts and details, imphash(), overlay and signature status), and the math module provides an entropy function, so triage rules can score packing indicators automatically. See the YARA Rules Guide.
Unpacking approaches: static and dynamic
The goal is not always a perfect rebuilt executable. Often it is enough to recover the payload's code, strings and configuration for analysis and detection. Choose the approach that answers the question you have.
| Approach | Concept | Strengths | Limits |
|---|---|---|---|
| Known-packer tooling | Use the packer's own documented decompression or a trusted generic unpacker for a recognised packer | Fast, repeatable, no execution of the payload | Fails on modified or custom packers; attackers often alter known packers so the standard tool rejects them |
| Static decryption | Read the stub in a disassembler, understand the algorithm and key, and reproduce the decryption offline | No execution; produces a reusable decryptor for a whole family | Slow and skill-intensive; layered or virtualised packers make it costly |
| Emulation | Run the stub in a CPU or OS emulator that never executes on real hardware | Safer than execution; scales for triage | Incomplete API emulation and anti-emulation checks can stop it early |
| Debugger-assisted dynamic unpacking | Run the sample under a debugger in an isolated lab, pause once the original code is in memory, then dump and repair the image | Works on many custom packers; reveals the true entry point | The sample really runs; anti-debugging checks may change behaviour |
| Sandbox and memory capture | Detonate in an instrumented sandbox and capture process memory or memory dumps after the payload unpacks | Scales; recovers injected and fileless stages that never touch disk | Dumped images may need repair before static tools read them; evasive samples may stay dormant |
Choosing an approach
- Triage at volume: Start with identification and automated sandbox memory capture. Escalate only samples that matter to the incident.
- Incident-critical sample: Use dynamic unpacking in the lab to get configuration (command and control addresses, keys, campaign identifiers) quickly, then share indicators.
- Recurring family: Invest in static understanding of the packer so you can build a decryptor and a durable detection for every future build.
- Virtualised code: Focus on behaviour, network traffic and memory artefacts rather than full code recovery.
- Small teams: Use a managed sandbox for first-pass unpacking and keep in-house effort for samples tied to live incidents. See Online malware analysis services for the data-handling trade-offs of uploading samples.
Whatever the route, record what was recovered: hashes of the packed and unpacked files, the stage at which the payload was captured, and any repairs made, so another analyst can reproduce the result. Disassembly of the recovered payload is covered in the Ghidra for Malware Analysis Guide, and memory capture in the Memory Forensics Guide.
Safe analysis environment
Unpacking a sample usually means executing it. The lab must assume the malware will try to spread, beacon out and detect the analysis environment.
- Get authorisation and define scope: Agree who may handle live samples, where they are stored and which incidents justify dynamic work. Record chain of custody for samples tied to an investigation.
- Use dedicated hardware or virtualisation: Analysis machines are never used for email, browsing or corporate access, and they sit on a separate network segment.
- Remove bridges to the host: Disable shared folders, shared clipboards and drag-and-drop between guest and host, and keep the hypervisor patched.
- Control the network: Default to no internet. Use simulated services or a monitored, sinkholed connection when network behaviour must be observed, and never from a corporate IP range.
- Snapshot and revert: Take a clean snapshot before each run and revert after it. Never reuse a guest that has run malware.
- Handle samples safely: Store samples in password-protected archives, with defanged names, in a restricted repository. Never place them where endpoint tools on ordinary hosts will scan or quarantine them unpredictably.
- Keep credentials out: No real accounts, tokens or SSH keys in the lab. Malware routinely harvests credentials, and a lab holding them becomes an incident.
See the Malware Sandbox Guide for sandbox design. NIST SP 800-53 SC-44 Detonation Chambers describes the same isolation principle as a control.
Detection implications for defenders
Packing is designed to break static detection. Each repack produces a new hash and can move or encrypt every byte a signature relied on.
- Hashes and stub signatures: File hashes of packed samples have a short life. Signatures on a packer stub catch every user of that packer, including legitimate software, and miss custom builds.
- Payload rules: Write YARA rules against the unpacked payload and apply them to memory and sandbox dumps, where the code is visible. Rules on packed files alone age quickly.
- Packing indicators as scoring: Use entropy, import and section heuristics to raise priority or route files to a sandbox, not to block on their own.
- Memory and behaviour: Endpoint tools that scan memory and watch behaviour (allocating executable memory, writing then executing it, injecting into another process) see the payload after it unpacks. See the EDR Telemetry Guide.
- Allowlisting: Application allowlisting does not care whether a file is packed; it blocks anything unapproved. See the Application Allowlisting Guide.
Where identity fits
A packed payload that also carries a valid code signature is far more likely to run unchallenged. Stolen signing keys turn malware into apparently trusted software: after the NVIDIA code-signing certificate theft, malware signed with the leaked certificates appeared within days. Check signature status during triage, treat signing keys as high-value machine credentials, and see the Code Signing Security Guide.
Metrics
- Percentage of escalated samples where the payload was recovered and analysed.
- Median time from sample receipt to extracted configuration and shared indicators.
- Number of detections written against unpacked payloads or memory, versus against packed files.
- Repeat detections: how often a payload rule catches a new build that file hashes missed.
- Lab incidents: any escape, unexpected outbound connection or host infection (target zero).
Framework mapping
| Framework | Reference | Relevance |
|---|---|---|
| MITRE ATT&CK v20 | T1027.002, T1027.009, T1027.013, T1140, T1497, T1622 | Packing, embedded and encrypted payloads, run-time decoding, analysis evasion |
| MITRE D3FEND | D3-DA Dynamic Analysis, D3-EFA Emulated File Analysis, D3-FCR File Content Rules, D3-FH File Hashing, D3-PA Process Analysis | Defensive techniques used to analyse and detect packed files |
| NIST SP 800-53 Rev 5 | SI-3, SC-44, IR-4 | Malicious code protection, detonation chambers, incident handling |
| NIST SP 800-83 Rev. 1 | Malware incident prevention and handling | Analysis feeds containment and eradication decisions |
| CIS Controls v8.1 | Control 10 Malware Defenses | Anti-malware and behaviour-based detection |
Common failure patterns
- Calling a file malicious because it is packed: Blocking every packed binary breaks legitimate software and erodes trust in the analysis team. Score, sandbox and decide.
- Trusting a clean sandbox run: Evasive samples stay dormant when they detect a lab. A run that shows nothing is inconclusive, not benign.
- Writing signatures on the stub: Rules built on the packed file catch one build and then go silent, giving false comfort.
- Stopping at the first layer: Many samples are packed several times or drop a second stage. Confirm that what you dumped is the final payload.
- Running samples on a networked workstation: A single slip turns analysis into an incident. Isolation and snapshots are not optional.
- Uploading sensitive samples to public services: Samples from targeted intrusions can contain victim data and tip off the attacker. Decide what may be shared before uploading.
Practitioner checklist
- Build an isolated analysis lab with snapshots, no host bridges, controlled networking and no real credentials.
- Write a sample-handling procedure covering storage, naming, chain of custody and external sharing.
- Score every incoming sample for packing indicators (entropy per section, imports, section names, raw versus virtual size, permissions, entry point, overlay).
- Route packed samples to an instrumented sandbox with memory capture before manual work.
- Escalate incident-critical samples to dynamic unpacking and extract configuration first.
- Record hashes of packed and unpacked stages and the capture point for each sample.
- Write YARA rules against unpacked payloads and run them on memory and sandbox dumps.
- Check code signature status and report suspected signing key misuse to the certificate owner.
- Review metrics quarterly and retire detections that only match packed builds.
Standards and references
- MITRE ATT&CK: T1027.002 Software Packing
- NIST: SP 800-83 Rev. 1 Guide to Malware Incident Prevention and Handling for Desktops and Laptops
- NIST: SP 800-53 Rev. 5 Security and Privacy Controls
- MITRE D3FEND: Dynamic Analysis
- Microsoft Learn: PE Format
- YARA documentation: PE module
- YARA documentation: Math module
- UPX project: Ultimate Packer for eXecutables
Related NHI Mgmt Group resources: Malware Analysis Guide for Defenders · Malware Sandbox Guide · YARA Rules Guide · Digital Forensics (DFIR) Guide