binary-refinery

raw JSON →
0.10.11 verified Fri May 01 auth: no python

A toolkit to transform and refine (mostly) binary data. Current version 0.10.11, frequent releases. Provides a pipeline framework for unpacking, decoding, and transforming binary payloads, with built-in units for cryptography, compression, encoding, and more.

pip install binary-refinery
error ModuleNotFoundError: No module named 'binary_refinery'
cause Wrong import name; the Python package installs as 'binary-refinery' but the module is 'refinery'.
fix
pip install binary-refinery; then use 'import refinery'.
error AttributeError: module 'refinery' has no attribute 'b64'
cause Units are not available as attributes on the top-level module; must import 'units' submodule.
fix
from refinery import units; units.b64()
error TypeError: 'NoneType' object is not callable
cause Forgetting to instantiate a unit class (missing parentheses).
fix
data | units.b64() # with parentheses
breaking In version 0.9.x, many unit names changed (e.g., 'base64' became 'b64'). Scripts from 0.8.x will break.
fix Update unit names: e.g., base64 -> b64, hex -> hex, etc. Check migration guide.
gotcha The pipeline operator | does not behave like shell pipes: units must be instantiated (with parentheses) even if no arguments needed.
fix Use 'data | unit.Class()' not 'data | unit.Class'.
gotcha Importing 'refinery' works, but many submodules (e.g., 'refinery.units.crypto') are not importable directly; always use 'from refinery import units' and access via 'units.xxx'.
fix Use 'from refinery import units; units.aes()' instead of 'from refinery.units.crypto import aes'.
deprecated The 'malwares' unit has been deprecated in favor of generic units like 'xtrmem' and 'xtrfile'.
fix Replace 'malwares(...)' with specific units for memory extraction.

Basic pipeline: pipe binary data through refinery units using the | operator.

import os
import json
from refinery import units

# Process a binary payload: base64 decode, decompress, and display hex
payload = b'JVBERi0xLjQ...'  # truncated for example
result = payload | units.b64() | units.zlib() | units.hexview()
print(result)

# Use a variable for conditional branching (requires 'refinery.lib')
from refinery.lib import argformats
print(argformats),  # just to demonstrate import is available