AES-Managed Overlay Decryption
Description
A payload-staging pattern in which a .NET binary carries its encrypted payload not in a manifest resource, but as a raw file overlay appended after the last PE section. The outer binary opens its own file path, seeks past the PE headers and sections, and decrypts the overlay using System.Security.Cryptography.AesManaged (or Aes in newer .NET versions). The decrypted bytes are then loaded reflectively via Assembly.Load or bridged into native code.
Contrast with Manifest-Resource Staging
| Pattern | Storage | Loader API | Typical Size |
|---|---|---|---|
| Manifest resource | .rsrc section |
Assembly.GetManifestResourceStream |
100 KB – 1 MB |
| Raw overlay | After last section, outside PE boundaries | FileStream / ReadAllBytesFromFile |
1 MB – 10 MB |
Overlay staging is harder to spot with standard PE resource tools because the payload is not indexed in the .rsrc directory. It requires file-carving or entropy analysis of the post-section gap.
Notable Examples
931242f8...(P.O_.exe) — 2.38 MB AES-managed overlay, decrypted withAesManaged+CryptoStream+MemoryStream. No GZip or Base64 layer observed. Overlay begins with repeating magicUKWES2V322hIwBbJ1183SGJ. ^[/intel/analyses/931242f8aab64f678147e83833b39bb35111e4359824f7ab694a74d5a80b8f8f.html]bc38233e...(PO1.exe) — 2.5 MB AES-CBC raw overlay with hardcoded 16-byte keyLsFnDsm0WGBtR7C. ^[/intel/analyses/bc38233e18628256407420a857d1a1999974331cac7c5beb4368550d1d15f91d.html]
Detection
- File-size anomaly: PE with tiny
.text/.rsrcbut total size > 1 MB - Entropy spike in the post-section region
- Strings referencing
FileStream,ReadAllBytesFromFile,AesManaged,CryptoStreamModealongsideAssembly.Load