Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Technique:Executable packing

From ReverseEngineering.wiki
Technique
On this wiki Facts · Code · Notes · Topics

Executable packers compress or encrypt a program and prepend a small stub that restores it in memory at start-up; this page covers how to recognise a packed file and the general way to unpack it.

Overview

A packer replaces the program's code and data by a compressed (or encrypted) blob plus a loader stub. At run time the stub restores the original image in memory and jumps to the original entry point (OEP). Static analysis of a packed file shows only the stub, so a packed file must be unpacked first.

DOS packers (EXEPACK, LZEXE, PKLITE, DIET and others) are recognised by MZ header fields and entry-point bytes rather than section names: see Technique:DOS executable packers and extenders.

Recognising a packed file

  • Very few imports (often only LoadLibrary/GetProcAddress/VirtualProtect or ExitProcess), a tiny import table.
  • PE: unusual section names, a first section with large virtual size but raw size 0 (the space the original image is decompressed into), high entropy in the raw data, entry point in the last or second section. See Format:PE (Portable Executable).
  • ELF: very small file, no section headers, RWX segments. See Format:ELF (Executable and Linkable Format).
  • Marker strings: UPX packs carry the text "UPX!" and section names UPX0/UPX1 (see Tool:UPX).
  • The Rich header and compiler artefacts of the original program are often absent or come from the packer's stub.

Unpacking strategies

  1. Use the packer's own decompressor when it exists (UPX: upx -d, see Tool:UPX).
  2. Static unpacking: re-implement the stub's decompression from the format documentation.
  3. Run to the OEP in a debugger or emulator, dump the process image and rebuild the import table. This executes the sample: only in an isolated VM, never on a personal computer.

Caveats

Modified UPX stubs, custom headers and commercial protectors (virtualisation, anti-debug) are not undone by the generic tools. Do not publish unpacked copyrighted programs; publish formats, markers and procedures.

Related

Tool:UPX

Code & repositories

  • https://github.com/upx/upx @ c068381dfb00bfee2f754eaa313152ede043db82 · license: unrecognized (COPYING)
    Official UPX source: packer, stub loaders and format documentation (doc/upx.pod).
    Tested on: source read, not run: read the source at the pinned commit · checked 2026-10-18; last activity 2026-10-17; Note: the latest release ships binaries; the wiki links only the source, never the binaries; the license file was not recognized automatically: read it