Binary Forensics for Beginners #1: Unmasking Binaries/Identifying the Packer Behind the File

The goal of this ticket is to give a few hints about how to know if a binary it is packaged or not.

Cybersecurity diagram showing malware payload entering a packer engine and evasion shield

A packed binary hides its real code inside a compressed or encrypted blob, plus a small stub that unpacks it at run time.

Analyse it as-is and you are reading the wrapper, not the program. Seven static checks that tells you which one you have, without running it.

The seven checks

#CheckToolPacked if
1Signature and entropyDetect It Easy (DIE)A packer is named, or a section is at 7.2+ bits/byte
2Section namesPEviewPacker names (UPX0, .MPRESS1), only 2 to 3 sections, or names that do not fit the content
3Sizes and permissionsPEviewRaw size 0 with a large virtual size, or any RWX section
4ImportspestudioA handful, mostly LoadLibraryA, GetProcAddress, VirtualProtect
5Entry pointPEiDOutside .text: a packer section, a data-named section.
6Unpackupx -t, upx -dUnpacks, or refuses while 1 to 5 still look packed

Each check below is shown on three training samples: 02_upx.exe (plain UPX), 03_upx_renamed.exe (UPX with its names and signature wiped) and 04_xor_stub.exe (a home-made XOR crypter).

Check 1: Signature and entropy

Open the file in DIE, read the detection list, then open the entropy view. Compressed or encrypted data sits near 8.0 bits per byte; normal code sits around 5 to 6.5.

Detect It Easy window analyzing a UPX-packed Windows executable with protection details highlighted in red
Detect It Easy entropy analysis showing a packed executable file and its entropy graph.
  • 02_upx: DIE names UPX. UPX1 is at 7.84.

Check 2: Section names

List the sections in PEview. Compilers produce a predictable set (.text, .data, .rdata, .idata, .reloc), usually 4 to 8 of them. Watch for packer names, very few sections, or names that do not fit what is inside.

PEview window displaying the UPX-packed executable 02_upx.exe with PE headers, UPX sections, and hexadecimal raw data.
  • 02_upx: only 3 sections, UPX0, UPX1, UPX2. Instant giveaway.

Names are just labels and are trivial to change, so treat this as weak evidence.

Check 3: Sizes and permissions

In PEview, compare each section’s Virtual Size with its Size of Raw Data, and read its Characteristics. A packer reserves empty memory to unpack into, then writes code there and runs it, so it needs sections that are both writable and executable (RWX).

PEview window displaying the IMAGE_SECTION_HEADER.code section of a renamed UPX executable, with highlighted virtual size and raw data size fields.
PEview window showing the .rdat section header and executable, readable, and writable memory characteristics highlighted
  • 03_upx_renamed: identical under new names: .code has raw size 0, .code and .rdat are RWX.

Check 4: Imports

Count the imported functions and ask whether they explain what the program does. A packer only needs enough to unpack and rebuild the real import table at run time: LoadLibraryA, GetProcAddress, VirtualProtect, sometimes VirtualAlloc.

PEStudio malware assessment showing executable imports, with VirtualProtect flagged as suspicious.
  • 02_upx: 6 functions. Four are the unpacker kit, plus one leftover each from msvcrt and USER32.
PEStudio malware assessment showing suspicious imports including VirtualProtect from KERNEL32.dll in a packed executable.
  • 04_xor_stub: only 4, all from KERNEL32.

[Screenshot 4a] Import list for 04_xor_stub: four functions, no USER32.

Check 5: Entry point

Read AddressOfEntryPoint in PEiD and find which section contains it. A compiler starts the program in .text. A packer starts it in its own stub.

PEiD v0.95 window displaying analysis details for 01_baseline.exe, including its entry point, .text section, file offset, and linker information.
  • 01_baseline: RVA 0x0013E0, in .text.
PEiD v0.95 window displaying analysis of the 04_xor_stub.exe file, including its entry point, .boot section, file offset, and Win32 console subsystem.
  • 04_xor_stub: RVA 0x8000, in .boot, the last section in the table. A stub added at the end is a classic layout.

Check 6: Unpack

On a copy, run upx -t to test, then upx -d to unpack. A clean unpack settles the question. A refusal only means UPX does not recognize the file, so fall back on checks 1 to 5.

  • 02_upx: upx -d restores the original program.
  • 03_upx_renamed: upx -t reports “Tested 0 files” because the UPX! magic was wiped. Checks 1 to 6 still say packed, so restore the magic by hand or dump it from memory.
  • 04_xor_stub: “not packed by UPX”, which is true. It is a custom packer, so reverse the stub or dump the decrypted data from memory.

Side by side

Check02_upx03_upx_renamed04_xor_stub
1. Signature, top entropyUPX; 7.84none; 7.84none; 7.96
2. SectionsUPX0/1/23, misnamed8, odd .enc/.boot
3. Sizes, RWXraw 0, 2 RWXraw 0, 2 RWX0x10-byte .text
4. Imports664
5. Entry pointUPX1.rdat.boot (last)
6. upx -dunpacksrefusednot UPX
VerdictUPXUPX, tamperedCustom

Takeaways

  • No signature does not mean clean. 03_upx_renamed and 04_xor_stub beat both shortcuts.
  • Entropy, imports and entry point are the hardest signs to hide.
  • When you can, compare against a clean build of the same program: a drop in imports and strings is hard to miss.