Skip to main content

Pure-Python parser for .NET BinaryFormatter (MS-NRBF) streams

Project description

python-nrbf

PyPI version Python versions License

A pure-Python parser for .NET BinaryFormatter streams (MS-NRBF spec). No dependencies beyond the standard library.

Installation

pip install nrbf

# YAML output support for nrbfdump
pip install "nrbf[yaml]"

Library usage

import nrbf

# From a file
with open("data.dat", "rb") as f:
    data = nrbf.load(f)

# From bytes
data = nrbf.loads(raw_bytes)

Both functions return plain Python objects — dict, list, str, int, float, bool, or None. The .NET type name is preserved in a __class__ key on dicts so you can identify types if needed.

System.Collections.Generic.List<T> and Dictionary<K,V> are automatically unwrapped to Python list and dict. .NET enum values are unwrapped to plain ints.

Command-line usage

nrbfdump is installed automatically with the package. It reads a BinaryFormatter file (or stdin) and prints it. It automatically decompresses gzip input.

usage: nrbfdump [FILE] [--format FORMAT]

positional arguments:
  FILE                  input file (default: stdin)

options:
  -h, --help            show this help message and exit
  --format, -f          json (default), pprint, yaml

Examples:

# Decode a file to JSON
nrbfdump data.dat

# Pipe a gzip-compressed file
cat data.dat.gz | nrbfdump

# Pretty-print for quick inspection
nrbfdump data.dat --format pprint

# YAML output (requires: pip install "nrbf[yaml]")
nrbfdump data.dat --format yaml

What's decoded

All MS-NRBF record types are supported:

  • All 16 primitive types (bool, int, float, double, DateTime, TimeSpan, Char, etc.)
  • Strings, object references, nulls
  • Single-dimensional and multi-dimensional arrays (primitive, object, string)
  • Classes with full member type info (ClassWithMembersAndTypes, SystemClassWithMembersAndTypes, ClassWithId)
  • System.Collections.Generic.List<T>list
  • System.Collections.Generic.Dictionary<K,V>dict
  • .NET enum values → int

License

MIT — see LICENSE.

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

nrbf-0.1.2.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

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

nrbf-0.1.2-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file nrbf-0.1.2.tar.gz.

File metadata

  • Download URL: nrbf-0.1.2.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for nrbf-0.1.2.tar.gz
Algorithm Hash digest
SHA256 0d0aab884f4b1ced82f054bca789d84ede8b2a718a44ead25be382dd709529ac
MD5 a25092a2f8b2c690e64f48ec74ac061e
BLAKE2b-256 e7b3b4f54daa3411ac5a02056f0ba47f9180b8abeb4aac5579f548d97c2ba8d7

See more details on using hashes here.

File details

Details for the file nrbf-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: nrbf-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for nrbf-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e3fd1c0b9cfc3e7025f94b37bbea1afcef4b81b153f82d66764f4e47f680c994
MD5 6b1723e50c4d29b84f68163313d84e4a
BLAKE2b-256 7d0780af583b8db0ab2887dbf6d625184e37ec844f52dd3f0ed531d76429e1ab

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