Skip to main content

A small Python project to extract resources and code from self contained .NET executables.

Project description

dotnet-sce

Extract assemblies and resources from self-contained .NET 5+ executables.

This is a Python conversion of the SelfContainedExtractor project, providing cross-platform bundle extraction with a simple command-line interface.

Features

  • Automatic bundle detection: Scans executable PE headers to locate the embedded bundle
  • Optional manual offset: Provide the bundle offset explicitly if needed
  • Transparent decompression: Automatically handles compressed (zlib) and uncompressed files
  • Cross-platform: Works on Windows, macOS, and Linux
  • Single-file extraction: Extract individual files without extracting the entire bundle

How It Works

Self-contained .NET executables (.NET 5+) bundle all required runtime files and dependencies into a single executable file. This tool locates and parses the internal bundle structure to extract:

  • Application assemblies (.dll files)
  • Runtime configuration files (.runtimeconfig.json, .deps.json)
  • System libraries and dependencies
  • Supporting native binaries

The extraction process:

  1. Scans the PE (Portable Executable) header to locate the bundle signature
  2. Reads the bundle header to determine format version and file count
  3. Parses individual file entries (offset, size, compression status, type)
  4. Decompresses files as needed using zlib
  5. Writes extracted files to the output directory, preserving structure

Installation

Via PyPI (recommended)

Install the latest released version from PyPI:

pip install dotnet-sce

Or with uv:

uv pip install dotnet-sce

After installation, the dotnet-sce command will be available globally:

dotnet-sce --help

From source (development)

Requirements

  • Python 3.8 or later
  • uv package manager (or pip)

Installation

git clone https://github.com/yourusername/dotnet-sce.git
cd dotnet-sce
uv pip install -e .

Or with development dependencies:

uv pip install -e ".[dev]"

With pip:

pip install -e .

Usage

Basic usage (auto-detect bundle offset)

dotnet-sce <executable> <output-directory>

Example:

dotnet-sce MyApp.exe ./extracted_files

Specify bundle offset manually

If auto-detection fails, you can provide the offset explicitly (in decimal or hex):

# Decimal offset
dotnet-sce MyApp.exe ./extracted_files --offset 1048576

# Hexadecimal offset
dotnet-sce MyApp.exe ./extracted_files --offset 0x100000

Display help

dotnet-sce -h

Example Output

$ dotnet-sce samples/WinChatClient.exe samples_out

Bundle details:
Bundle ID: wA4enLQ_7Ls8
Version: 6.0
Embedded files count: 171

Embedded file info: Name: WinChatClient.dll, Size: 14848, Type: 1
Embedded file info: Name: WinChatClient.runtimeconfig.json, Size: 372, Type: 4
...
Successfully extracted file WinChatClient.dll.
Successfully extracted file WinChatClient.runtimeconfig.json.
...

Architecture

The project follows a modular design:

  • binary_reader.py — Low-level binary I/O with variable-length encoding support
  • bundle_header.py — Bundle header parsing and validation
  • bundle_file_entry.py — File entry metadata and type enumeration
  • bundle.py — Core extraction logic
  • cli.py — Command-line argument parsing and orchestration

All modules follow Google Python style conventions and include comprehensive docstrings.

Testing

Run the included test suite:

uv run pytest

Test the tool with the sample bundle:

uv run dotnet-sce samples/WinChatClient.exe samples_out

Limitations

  • Only supports .NET 5+ self-contained executables (versions 2.x and 6.x bundles)
  • Does not support bundled native executables or platform-specific resources
  • Offset auto-detection works best on unmodified official .NET self-contained builds

Attribution

This project is a Python conversion of SelfContainedExtractor by LukeFZ.

The original C# implementation was reverse-engineered from the .NET Runtime source code and ported to Python for broader compatibility and ease of use.

The Python version maintains feature parity with the original while providing improved usability through:

  • A simpler installation process
  • Better error messages with contextual help
  • Cross-platform compatibility without .NET dependencies
  • Type hints and improved code documentation

License

This project is provided as-is for educational and practical use. Refer to the original SelfContainedExtractor repository for licensing details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dotnet_sce-0.1.0.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dotnet_sce-0.1.0-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

Details for the file dotnet_sce-0.1.0.tar.gz.

File metadata

  • Download URL: dotnet_sce-0.1.0.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dotnet_sce-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0d6411d308d5d8e847118b58d05484de6ed7460206d23ebc27e793d1fa8a8a80
MD5 e891b81d80c4a5c0d5c64c3718ea2904
BLAKE2b-256 e2ebd752e3031d1090b0573ff31d54913645aef90a6cd694e7c8f8fee73b76c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for dotnet_sce-0.1.0.tar.gz:

Publisher: publish.yml on stolenfootball/dotnet-sce

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dotnet_sce-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dotnet_sce-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dotnet_sce-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9046806c5ffb3d7f063269b98d4809241a8575ef1707cded382857f3db94cbde
MD5 157242b7a38746a675bc2051941f8be6
BLAKE2b-256 9894113b65fd4a612df5c12143cd764c059d0f22334e7bc343d503a60db35865

See more details on using hashes here.

Provenance

The following attestation bundles were made for dotnet_sce-0.1.0-py3-none-any.whl:

Publisher: publish.yml on stolenfootball/dotnet-sce

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page