Decode and print Rich headers from Windows PE executables
Project description
richprint
A Python tool to decode and print compiler information stored in the Rich Header of Windows PE executables.
Installation
pip install richprint-pe
What is the Rich Header?
The Rich Header is a section of binary data created by Microsoft's linker, located between the DOS stub and PE header in Windows executables. It contains a list of compiler/tool IDs (@comp.id) used to build the executable, allowing identification of exact compiler versions down to build numbers.
The data is XOR-encoded, with "Rich" being the only readable marker. Files created by non-Microsoft linkers will not have this header.
For technical details, see Daniel Pistelli's article.
Usage
Command Line
# Analyze one or more files
richprint notepad.exe
richprint file1.exe file2.dll file3.sys
# JSON output
richprint --json notepad.exe
# Use custom compiler ID database
richprint --database /path/to/comp_id.txt notepad.exe
Python API
from richprint import parse_file, load_database
# Load the bundled compiler ID database
db = load_database()
# Parse a PE file
result = parse_file("notepad.exe", db)
if result.success:
print(f"Machine: {result.pe_info.machine_name}")
print(f"XOR Key: 0x{result.rich_header.xor_key:08x}")
for entry in result.rich_header.entries:
print(f" {entry.comp_id:08x} {entry.description}")
else:
print(f"Error: {result.error}")
Output Format
Processing notepad.exe
Target machine: x64
@comp.id id version count description
00e1520d e1 21005 10 [C++] VS2013 build 21005
00df520d df 21005 1 [ASM] VS2013 build 21005
00de520d de 21005 1 [LNK] VS2013 build 21005
Compiler ID Database
The bundled comp_id.txt database maps compiler IDs to human-readable descriptions. The format supports:
[ C ]- C compiler[C++]- C++ compiler[ASM]- Assembler[LNK]- Linker[RES]- Resource converter[IMP]/[EXP]- DLL import/export records- And many more...
Suppressing Rich Headers
To prevent Microsoft tools from emitting this header, use the undocumented linker option:
/emittoolversioninfo:no
Available since VS2019 Update 11.
License
BSD 2-Clause License. See LICENSE for details.
Credits
Original C++ implementation and compiler ID database by dishather.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file richprint_pe-1.0.0.tar.gz.
File metadata
- Download URL: richprint_pe-1.0.0.tar.gz
- Upload date:
- Size: 42.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbe28a68198e4ea185eb3c0bbd0fb897af301b0f0744c1efea8ae82f6dd77391
|
|
| MD5 |
d3c8afd2f5e9bf0f7237785ffd38e60d
|
|
| BLAKE2b-256 |
a2ba17eb1b28ba078e40f740ec152687192229454b255be907f27243f7f34f14
|
File details
Details for the file richprint_pe-1.0.0-py3-none-any.whl.
File metadata
- Download URL: richprint_pe-1.0.0-py3-none-any.whl
- Upload date:
- Size: 40.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6926b9064083ff8efff4adb800f48cf3d4670b19f8a4f4fde9eb1895fd948f6
|
|
| MD5 |
fbf22e5ee2bae64bff6952ae021d9456
|
|
| BLAKE2b-256 |
82ea3bbfb7677c0464dcad95d8ee2143fb30769b05ccf42347ff6345a4327a7d
|