コンテンツにスキップ

Impacket registry-read.py

カテゴリ目次へ戻る / コマンド全体目次へ戻る

ローカルのレジストリ hive を読み取り専用で開き、キーや値を調べます。SYSTEM hive から boot key も算出できます。

項目内容
実装examples/registry-read.py
カテゴリ秘密情報 / DPAPI / レジストリ / ファイル解析
規模174 行
配布setup.py の scripts=examples/*.py によりスクリプトとしてインストール

オプションの最新の定義は python examples/registry-read.py -h で確認できます。

subcommand: enum_key、enum_values、get_value、get_class、walk

引数説明
-debugTurn DEBUG output ON
-tsAdds timestamp to every logging output
hiveregistry hive to open
-nameregistry key(必須)
-recursiverecursive search (default False)

winregistry.Registry で hive を parse し、enum_key、enum_values、get_value、get_class、walk subcommand を対応関数へ dispatch します。path を node へ解決し、value type ごとにデータを表示します。

registry hive file は cell allocator と index tree を持つ binary database です。 winregistry.Registry は root cell から key node を辿り、subkey list と value list の cell offset を解決します。このコマンドはその API を subcommand ごとに 呼び、remote Registry protocol は使用しません。

enum_key と enum_values は同じ key node の別 list を読み、get_value は value type と data cell を解釈します。get_class は key class data を取得し、 SYSTEM hive の boot key 算出では特定 LSA key の class 文字列を順番に連結・ 並べ替えます。表示文字列だけを使うのではなく raw byte/型を保持します。

walk は tree を再帰的に辿るため、壊れた index の循環、深すぎる tree、 削除/free cell、範囲外 offset を考慮します。hive transaction log を適用する tool ではないため、dirty hive の最新状態が完全に反映されるとは限りません。 read-only の前提を崩さず parser を tests/misc/test_winregistry.py と合わせて 変更します。

シンボル位置責務を追う入口
bootKey()32モジュール関数
getClass()48モジュール関数
getValue()63モジュール関数
enumValues()77モジュール関数
enumKey()99モジュール関数
walk()115モジュール関数
main()119モジュール関数
モジュール使用する主な名前
impacket.exampleslogger
impacketversion, winregistry
  • 主処理はローカルファイルの解析です。入力を信頼せず、offset、length、形式識別子を検証してからデータを参照してください。
  • 入力ファイルがない場合、壊れている場合、読み取りが途中で終わる場合、未対応の形式だった場合を区別します。

impacket.winregistry と標準 binary/NT path helper に依存します。CLI 関数は薄く、cell/index/value parsing の変更は library と tests/misc/test_winregistry.py 側で行います。

  • 構文: python -m py_compile examples/registry-read.py
  • CLI: python examples/registry-read.py -h
  • このコマンド専用のテストは見つかりません。共有モジュールのテストと、必要に応じて隔離環境での動作確認を選びます。