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 and pefile
.
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/
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:
- Bob Jung (parser library)
- Yaron Samuel (parser library) @yaron_samuel
- Dominik Reichel (parser and interface libraries) @TheEnergyStory
This project is a work in progress. If you find any issues or have any suggestions, please report them to the GitHub project page.
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
File details
Details for the file dotnetfile-0.2.4.tar.gz
.
File metadata
- Download URL: dotnetfile-0.2.4.tar.gz
- Upload date:
- Size: 40.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d44a3c7b5ab19858d1e27e238b64f2343a02c103b1a0280a1b58e5e7cc8dd8a3 |
|
MD5 | d74558a90e94f01ca34a2114b501610e |
|
BLAKE2b-256 | 8cdfbac94fb8bb96ec49fee487ed16cb89ba2eeec5202c80e337fc24b24e086c |
File details
Details for the file dotnetfile-0.2.4-py3-none-any.whl
.
File metadata
- Download URL: dotnetfile-0.2.4-py3-none-any.whl
- Upload date:
- Size: 41.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d721b104b615c6141110dd2638fae79f2f5683795cfe1008a68afe9a1ca32271 |
|
MD5 | d8d34c8471ede66f434ead084713561a |
|
BLAKE2b-256 | 0946a7849897aa4fa4622e87c3190ceaa4a55256631b1deb00f100099ce52ddc |