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:Bundled-runtime applications

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

How to recognize and unpack programs that ship a language runtime plus their script payload inside one executable (PyInstaller, py2exe, Nuitka, Electron, Node.js SEA, pkg, nexe, .NET single-file): a lookup table of the marker bytes and where the payload sits.

Method

  1. Identify the container from the markers below (strings and trailing bytes first; they cost nothing).
  2. Extract the payload without running the program (downloaded samples are untrusted).
  3. Read the language-level artifact (bytecode, JavaScript, IL), not the host runtime: the host is a stock interpreter and mostly not interesting.
  4. Record the runtime version (it decides bytecode and snapshot formats).

Lookup table

Bundler Marker Payload location Version recorded in
PyInstaller 4D 45 49 0C 0B 0A 0B 0E cookie overlay, cookie at the end cookie python_version and library name, PYZ bytecode magic (Format:PyInstaller archive (CArchive and PYZ))
py2exe PE resource PYTHONSCRIPT/1, tag 0x78563412 resource + library.zip pyc magic in the zip, python DLL name (Tool:py2exe)
Nuitka no bytecode; __compiled__; onefile KA + X/Y tag native code; onefile payload at end strings / Python DLL (Tool:Nuitka)
Electron fuse sentinel dL7pKGdnNz796PbbjQWNKmHXBZaB9tsX, resources/app.asar Format:ASAR archive (Electron) Library:Electron
Node.js SEA NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 section NODE_SEA_BLOB embedded Node.js (Format:Node.js single executable application)
pkg // PAYLOAD_POSITION //, PKG_EXECPATH, /snapshot/ appended payload Node.js version in the binary (Tool:Pkg (Node.js packager))
nexe <nexe~~sentinel> in the last 16000 bytes end of file Node.js version (Tool:Nexe)
.NET single-file 8B 12 02 B9 6A 61 20 38 ... marker + int64 offset bundle at the end bundle header version (Format:.NET single-file bundle)

Python-specific advice

Code objects in PyInstaller and py2exe are Format:Marshal (Python) data of the exact interpreter version; the pyc header must be added back (Format:PYC (Python compiled bytecode)). Unmarshal with the same minor version, then decompile with a tool that supports it; newer minors (3.12 and later) are often unsupported.

Other Python packagers: Tool:Cx Freeze (a lib/library.zip of .pyc files with real mtime and size in the header, entry modules __main__<name>), Format:PyOxidizer packed resources (a pyembed\x03 blob in an executable with an embedded interpreter), Format:Python zipapp (a ZIP with an optional #! first line) and Tool:Nuitka (native code and a constants blob, no bytecode). Quick test: MEI\x0c\x0b\x0a\x0b\x0e near the end means PyInstaller; a PYTHONSCRIPT resource means py2exe; lib/library.zip plus library.dat means cx_Freeze; pyembed\x03 means PyOxidizer; a KA payload tag or __compiled__ means Nuitka.

Pitfalls

  • A marker can appear as data in analysis tools (the .NET marker, the Electron sentinel in @electron/fuses): check that offsets and lengths point inside the file.
  • Installers (NSIS, MSI, Inno Setup) wrap these apps; unpack the installer first (Format:NSIS installer).
  • Tail data such as code-signing blobs can follow the payload: scan backward for the marker, do not assume it is the last bytes.