コンテンツにスキップ

Impacket regsecrets.py

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

Remote Registry 経由で SAM ハッシュと LSA の秘密情報・キャッシュを取得します。NTDS は対象にしません。

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

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

引数説明
target[[domain/]username[:password]@]
-tsAdds timestamp to every logging output
-debugTurn DEBUG output ON
-systemSYSTEM hive to parse
-bootkeybootkey for SYSTEM hive
-nosamDo not retrieve SAM information
-nocacheDo not retrieve MSCache information
-nolsaDo not retrieve LSASecrets
-throttleThrottle in seconds between operations
-outputfilebase output filename. Extensions will be added for sam, secrets and cached
-historyDump password history (NTDS and SAM hashes), and LSA secrets OldVal
-hashesNTLM hashes, format is LMHASH:NTHASH
-no-passdon’t ask for password (useful for -k)
-kUse Kerberos authentication. Grabs credentials from ccache file (KRB5CCNAME) based on target parameters. If valid credentials cannot be found, it will use the ones specified in the command line
-aesKeyAES key to use for Kerberos Authentication (128 or 256 bits)
-keytabRead keys for SPN from keytab file
-dc-ipIP Address of the domain controller. If ommited it use the domain part (FQDN) specified in the target parameter
-target-ipIP Address of the target machine. If omitted it will use whatever was specified as target. This is useful when target is the NetBIOS name and you cannot resolve it

SMB 接続後、RemoteOperations が boot key と registry data へのアクセスを準備します。指定済み SYSTEM/bootkey を優先し、SAMHashes と LSASecrets を option に応じて実行、履歴や出力 file を処理します。最後に temp hive、RemoteRegistry 状態、connection を cleanup します。

SAM/LSA secret の復号には対象 machine 固有の boot key が必要です。 DumpSecrets は SMB session を作り、RemoteOperations で SYSTEM hive の LSA class dataから boot key を再構成します。明示 -bootkey や local SYSTEM file があれば、remote 取得を省く経路へ切り替わります。

SAMHashes は SAM domain account encryption key を boot key から導出し、 各 user の RID を使って LM/NT hash field を復号します。LSASecrets は SECURITY policy key を導出し、LSA secret と cached domain logon record を version/algorithm に応じて解きます。SAM と LSA cache は同じ hiveでも同じ 暗号形式ではありません。

remote 取得では Registry service と temporary hive/file access を使う場合が あります。-nosam、-nocache、-nolsa は decoder だけでなく不要な remote 操作も省くべきです。output file は秘密情報を含むため、部分成功時に何を保存 したかを明示し、cleanup() で service state と temp resource を戻します。

シンボル位置責務を追う入口
DumpSecrets66__init__()、connect()、dump()、cleanup()
モジュール使用する主な名前
impacketversion
impacket.exampleslogger
impacket.examples.utilsparse_target
impacket.smbconnectionSMBConnection
impacket.examples.regsecretsLSASecrets, RemoteOperations, SAMHashes
impacket.krb5.keytabKeytab
  • 照会や認証の試行が中心です。実行回数が多いと監査ログやアカウントロック、対象の負荷に影響します。
  • オプションによりローカルファイルを作成または更新します。既存ファイルの扱いと秘密情報を含む出力の権限を確認してください。
  • remote service、task、file、share、WMI/RPC resource などの一時資源を利用する経路があります。異常終了時の回収も動作契約です。
  • 失敗時は、名前解決、接続、認証、サービスの状態、権限のどこで止まったかを、プロトコルのステータスから切り分けます。
  • 後始末に関係する実装として cleanup() があります。新しい早期 return や例外経路でも到達するか確認します。

SMBConnection、impacket.examples.regsecrets の RemoteOperations / SAMHashes / LSASecrets、keytab に依存します。CLI DumpSecrets は secret decoder 自体ではなく orchestration を所有します。

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