Join our Newsletter — 33% off our NHI Course
Home› Guides› Malware Packers and Unpacking: How Analysts Recover the…
Guide Attack Techniques & Malware

Malware Packers and Unpacking: How Analysts Recover the Real Payload

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 27 November 2026 13 min read
On this page

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.

TypeWhat it does to the codeTypical goalWhat 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 pointSmaller files; also changes the hash and static signaturesUsually the easiest case; well-known compressors are often identified by name
CrypterEncrypts the payload and decrypts it at run time, often with a key stored in the stub or derived at run timeDefeat signature-based scanning; resell as a service to other criminalsHigh-entropy blobs, sometimes several layers, often combined with process injection
ProtectorAdds anti-debugging, anti-tamper and integrity checks around the codeProtect intellectual property (legitimate use) or frustrate analysis (malicious use)Analysis is slowed by checks that change behaviour when tools are present
Virtualising protectorTranslates original code into a custom bytecode run by an embedded virtual machine, as ATT&CK describesMake the original logic very costly to reconstructThe original instructions may never exist in memory; behavioural analysis matters more than full recovery
Embedded or staged payloadHides 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 payloadThe 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.

IndicatorWhat to look atWhat suggests packingCaveats
EntropyShannon 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 sectionCompressed resources, images and installers are high entropy too; measure per section
Import tableNumber of imported DLLs and functionsVery few imports, often only functions that load libraries, resolve addresses and allocate or protect memorySmall legitimate tools can also have short import lists
Section namesNames in the section tableNames associated with known packers (for example UPX0 and UPX1) or random strings instead of familiar names such as .text, .rdata and .rsrcMicrosoft's PE specification warns tools not to assume particular section names; names are easy to change
Raw versus virtual sizeSizeOfRawData and VirtualSize for each sectionA section with little or no data on disk but a large size in memory, waiting to be filled at run timeSections holding only uninitialised data legitimately have a raw size of zero
Section permissionsSection characteristics flagsA 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 locationAddressOfEntryPoint and the section that contains itEntry point in the last section or outside the main code sectionSome linkers and installers place entry points unusually
OverlayData appended after the last sectionA large, high-entropy overlay carrying an embedded payloadInstallers and signed files often carry overlays
StringsReadable strings in the fileVery few meaningful strings, no URLs, paths or error messagesString 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.

ApproachConceptStrengthsLimits
Known-packer toolingUse the packer's own documented decompression or a trusted generic unpacker for a recognised packerFast, repeatable, no execution of the payloadFails on modified or custom packers; attackers often alter known packers so the standard tool rejects them
Static decryptionRead the stub in a disassembler, understand the algorithm and key, and reproduce the decryption offlineNo execution; produces a reusable decryptor for a whole familySlow and skill-intensive; layered or virtualised packers make it costly
EmulationRun the stub in a CPU or OS emulator that never executes on real hardwareSafer than execution; scales for triageIncomplete API emulation and anti-emulation checks can stop it early
Debugger-assisted dynamic unpackingRun the sample under a debugger in an isolated lab, pause once the original code is in memory, then dump and repair the imageWorks on many custom packers; reveals the true entry pointThe sample really runs; anti-debugging checks may change behaviour
Sandbox and memory captureDetonate in an instrumented sandbox and capture process memory or memory dumps after the payload unpacksScales; recovers injected and fileless stages that never touch diskDumped 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.

  1. 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.
  2. Use dedicated hardware or virtualisation: Analysis machines are never used for email, browsing or corporate access, and they sit on a separate network segment.
  3. Remove bridges to the host: Disable shared folders, shared clipboards and drag-and-drop between guest and host, and keep the hypervisor patched.
  4. 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.
  5. Snapshot and revert: Take a clean snapshot before each run and revert after it. Never reuse a guest that has run malware.
  6. 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.
  7. 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

FrameworkReferenceRelevance
MITRE ATT&CK v20T1027.002, T1027.009, T1027.013, T1140, T1497, T1622Packing, embedded and encrypted payloads, run-time decoding, analysis evasion
MITRE D3FENDD3-DA Dynamic Analysis, D3-EFA Emulated File Analysis, D3-FCR File Content Rules, D3-FH File Hashing, D3-PA Process AnalysisDefensive techniques used to analyse and detect packed files
NIST SP 800-53 Rev 5SI-3, SC-44, IR-4Malicious code protection, detonation chambers, incident handling
NIST SP 800-83 Rev. 1Malware incident prevention and handlingAnalysis feeds containment and eradication decisions
CIS Controls v8.1Control 10 Malware DefensesAnti-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

Related NHI Mgmt Group resources: Malware Analysis Guide for Defenders · Malware Sandbox Guide · YARA Rules Guide · Digital Forensics (DFIR) Guide

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.