Skip to main content

Parse .NET executable files.

Project description

dnfile

https://img.shields.io/pypi/v/dnfile.svg

Parse .NET executable files.

  • Free software: MIT license

Features

  • Parse as much as we can, even if the file is partially malformed.

  • Easy to use. Developed with IDE autocompletion in mind.

Quick Start

pip install dnfile

Then create a simple program that loads a .NET binary, parses it, and displays information about the streams and Metadata Tables.

import sys
import dnfile

filepath = sys.argv[1]

pe = dnfile.dnPE(filepath)
pe.print_info()

Everything is an object, and raw structure values are stored in an object’s “struct” attribute. The CLR directory entry object is accessible from the “net” attribute of a dnPE object.

pe = dnfile.dnPE(FILEPATH)

# access the directory entry raw structure values
pe.net.struct

# access the metadata raw structure values
pe.net.metadata.struct

# access the streams
for s in pe.net.metadata.streams_list:
    if isinstance(s, dnfile.stream.MetaDataTables):
        # how many Metadata tables are defined in the binary?
        num_of_tables = len(s.tables_list)

# the last Metadata tables stream can also be accessed by a shortcut
num_of_tables = len(pe.net.mdtables.tables_list)

TODO

  • parse .NET resources

  • more tests

  • Documentation on readthedocs

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

DEV

  • Working…

0.10.0 (2022)

  • BREAKING CHANGE: structure attributes no longer exist by default

  • BREAKING CHANGE: objects’ attributes always exist, but may be None

  • BUGFIX: use last stream if multiple of same name

  • CI: added mypy type checking

  • when duplicate stream names, behave like runtime and use last one for shortcuts

  • add user_strings shortcut

  • able to access MetaDataTables like a 0-based list, with square brackets

  • added use of logging module for warnings

  • better type hints for IDEs

  • more better source comments

  • more tests

0.9.0 (2021)

  • bugfix: row indices parsed in structures are one-based, not zero-based

  • bugfix: TypeDefRow was not parsing Extends coded index

  • bugfix: incorrect BLOBS_MASK and add EXTRA_DATA skip if flag set

  • added CI using github workflow

  • added tests and submodule dnfile-testfiles

  • added style consistency using pycodestyle and isort

  • added more examples

  • parse MetaData tables’ list-type indexes into lists of MDTableRow objects

0.8.0 (2021)

  • bugfix: Metadata Table indexes (i.e. indexes into other tables) were off by one

0.7.1 (2021)

  • bugfix: coded index always None

0.7.0 (2021)

  • bugfix: improper data length check

0.6.0 (2021)

  • bugfix: referenced wrong object

  • parse utf-16 strings in #US stream

0.5.0 (2021-01-29)

  • First release.

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

dnfile-0.10.0.tar.gz (35.4 kB view details)

Uploaded Source

Built Distribution

dnfile-0.10.0-py2.py3-none-any.whl (39.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file dnfile-0.10.0.tar.gz.

File metadata

  • Download URL: dnfile-0.10.0.tar.gz
  • Upload date:
  • Size: 35.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/28.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.51.0 importlib-metadata/4.8.2 keyring/21.5.0 rfc3986/1.4.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for dnfile-0.10.0.tar.gz
Algorithm Hash digest
SHA256 4f7c07838dff7b5e4b64a39a2cc06a615d94abf1bdba0f05f429384cba815c60
MD5 c5965d24ab246f9f7dfcc1529e082aa9
BLAKE2b-256 3c7de7e5c70577748d1bab8eb2bc1674c68745e465b6fc0dbcb0f6a954ce8f54

See more details on using hashes here.

Provenance

File details

Details for the file dnfile-0.10.0-py2.py3-none-any.whl.

File metadata

  • Download URL: dnfile-0.10.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 39.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/28.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.51.0 importlib-metadata/4.8.2 keyring/21.5.0 rfc3986/1.4.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for dnfile-0.10.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 010fd99f2a38baf66c1fc605449698ecf60cc46ff508b3d0d03ca02babc549e0
MD5 19fd903eaa6bc6f91588266ebe853474
BLAKE2b-256 17b522c2d7e4720ad99816e368355879677a05f01962170024acfb94ebdae7a6

See more details on using hashes here.

Provenance

Supported by

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