Skip to main content

Library to parse the CLR header of .NET assemblies

Project description

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.

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

dotnetfile-0.2.10.tar.gz (51.8 kB view details)

Uploaded Source

Built Distribution

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

dotnetfile-0.2.10-py3-none-any.whl (54.9 kB view details)

Uploaded Python 3

File details

Details for the file dotnetfile-0.2.10.tar.gz.

File metadata

  • Download URL: dotnetfile-0.2.10.tar.gz
  • Upload date:
  • Size: 51.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.9

File hashes

Hashes for dotnetfile-0.2.10.tar.gz
Algorithm Hash digest
SHA256 20f233f6c70a76c7667b75e13bd686506c7eb6f944f3393e4c26572747d7e943
MD5 288ee67e71202c7756d588327a8efe82
BLAKE2b-256 de6528e958c9c2e0ae54970f9d140f786aeb36d850819fdecd69f3c8b49e0c89

See more details on using hashes here.

File details

Details for the file dotnetfile-0.2.10-py3-none-any.whl.

File metadata

  • Download URL: dotnetfile-0.2.10-py3-none-any.whl
  • Upload date:
  • Size: 54.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.9

File hashes

Hashes for dotnetfile-0.2.10-py3-none-any.whl
Algorithm Hash digest
SHA256 c12f6a852f5495592d2df7fafe6ba66779f51cdaf7585a7c7b58a6e1563547f1
MD5 eb2ae627860615e7c3df12574263ebee
BLAKE2b-256 28f6392904088e9ce6c45bd223e6550618e3967495b7ef538c8bb14355728a9a

See more details on using hashes here.

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