Skip to content

Impacket registry-read.py

Back to the category index / Back to the command index

Opens a local registry hive read-only to inspect keys and values. It can also derive the boot key from a SYSTEM hive.

ItemDetails
Implementationexamples/registry-read.py
CategorySecrets / DPAPI / registry / file analysis
Size174 lines
DistributionInstalled as a script through scripts=examples/*.py in setup.py

Run python examples/registry-read.py -h for the current option definitions.

Subcommands: enum_key, enum_values, get_value, get_class, walk

ArgumentDescription
-debugEnable debug output
-tsAdd a timestamp to each log message
hiveRegistry hive to open
-nameRegistry key; required
-recursiveSearch recursively (default: False)

The tool parses the hive with winregistry.Registry and dispatches enum_key, enum_values, get_value, get_class, and walk to their corresponding functions. It resolves paths to nodes and displays data according to value type.

A registry hive file is a binary database with a cell allocator and index tree. winregistry.Registry follows key nodes from the root cell and resolves cell offsets for subkey and value lists. This command calls that API for each subcommand; it does not use the remote Registry protocol.

enum_key and enum_values read different lists from the same key node, while get_value interprets the value type and data cell. get_class retrieves key class data. To derive a boot key from a SYSTEM hive, it concatenates class strings from specific LSA keys in order and rearranges them. Preserve raw bytes and types, not only display strings.

walk traverses the tree recursively, so account for cycles in damaged indexes, excessively deep trees, deleted or free cells, and out-of-range offsets. This tool does not apply hive transaction logs, so the latest state of a dirty hive may not be fully reflected. Keep parsing read-only and make changes together with tests/misc/test_winregistry.py.

SymbolLocationWhere to trace its responsibility
bootKey()32Module function
getClass()48Module function
getValue()63Module function
enumValues()77Module function
enumKey()99Module function
walk()115Module function
main()119Module function
ModuleMain names used
impacket.exampleslogger
impacketversion, winregistry

Output, side effects, and required privileges

Section titled “Output, side effects, and required privileges”
  • The main operation parses local files. Treat input as untrusted: validate offsets, lengths, and format identifiers before accessing data.
  • Distinguish a missing input file, a damaged file, an incomplete read, and an unsupported format.

The code depends on impacket.winregistry and standard binary and NT path helpers. The CLI functions are thin wrappers; make changes to cell, index, or value parsing in the library and tests/misc/test_winregistry.py.

  • Syntax: python -m py_compile examples/registry-read.py
  • CLI: python examples/registry-read.py -h
  • No test specific to this command was found. Choose shared-module tests and, if needed, a run in an isolated environment.