Skip to main content

dotnetfile

dotnetfile is a Common Language Runtime (CLR) header parser library for Windows .NET files built in Python. The CLR header is present in every Windows .NET assembly beside the Portable Executable (PE) header. It stores a plethora of metadata information for the managed part of the file.

dotnetfile is in a way the equivalent of pefile but for .NET samples.

The library provides an easy-to-use API, but also tries to contribute new methods to improve file detection. This includes the MemberRef hash (experimental) and the original and a modified version of TypeRef hash.

The aim of this project is to give malware analysts and threat hunters a tool to easily pull out information from the CLR header. You don't need to be an expert in the CLR header and get lost in its specification to use this library. By using the API, you'll also learn how the header is structured and hopefully get a better understanding of this file type in general.

Installation

dotnetfile requires Python >= 3.7.

PyPI

You can easily install dotnetfile with pip:

pip install dotnetfile

Local setup

To install dotnetfile as a module, please use the provided setup.py file. This can be done with the help of Python:

python3 setup.py install

Usage

To use dotnetfile, all you have to do is to import the module and create an instance of the class DotNetPE with the .NET assembly path as a parameter. A minimal example that prints out the number of streams of an assembly is shown below:

# Import class DotNetPE from module dotnetfile
from dotnetfile import DotNetPE

# Define the file path of your assembly
dotnet_file_path = '/Users/<username>/my_dotnet_assembly.exe'

# Create an instance of DotNetPE with the file path as a parameter
dotnet_file = DotNetPE(dotnet_file_path)

# Print out the number of streams of the assembly
print(f'Number of streams: {dotnet_file.get_number_of_streams()}')

You are invited to explore the example scripts: https://github.com/pan-unit42/dotnetfile/blob/main/examples/

More about how to use this library can be found in the documentation pages.

Documentation

The full documentation can be found at https://pan-unit42.github.io/dotnetfile/

Authors

This project was started in 2016 with the development of the parser library for internal use at Palo Alto Networks. It was improved/extended with the interface library and open-sourced in 2022 by the following people:

This project is a work in progress. If you find any issues or have any suggestions, please report them to the GitHub project page.

Credits

Special thanks to all the contributors who have helped improve this project.

dotnetfile is heavily based on the .NET specification.

Metadata

Release files for dotnetfile 0.2.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dotnetfile 0.2.10
File Size Uploaded
dotnetfile-0.2.10.tar.gz 51.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dotnetfile 0.2.10
File Interpreter ABI Platform
dotnetfile-0.2.10-py3-none-any.whl Python 3 none any Details

Total release size: 106.7 kB

Release files / dotnetfile-0.2.10.tar.gz

Download URL dotnetfile-0.2.10.tar.gz
Size 51.8 kB
Tags Source
SHA-256 checksum
How to use checksums
20f233f6c70a76c7667b75e13bd686506c7eb6f944f3393e4c26572747d7e943
BLAKE2b-256 checksum
How to use checksums
de6528e958c9c2e0ae54970f9d140f786aeb36d850819fdecd69f3c8b49e0c89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.9

Release files / dotnetfile-0.2.10-py3-none-any.whl

Download URL dotnetfile-0.2.10-py3-none-any.whl
Size 54.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c12f6a852f5495592d2df7fafe6ba66779f51cdaf7585a7c7b58a6e1563547f1
BLAKE2b-256 checksum
How to use checksums
28f6392904088e9ce6c45bd223e6550618e3967495b7ef538c8bb14355728a9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.9

Release history Release notifications | RSS feed

This release

0.2.10 This release

2 release files

0.2.9

2 release files

0.2.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page