コンテンツにスキップ

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

DPAPI のマスターキー、資格情報、Vault、CREDHIST などを解析・復号します。一部の操作ではリモートホストから材料を取得します。

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

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

subcommand: backupkeys、masterkey、credential、vault、unprotect、credhist

引数説明
-debugTurn DEBUG output ON
-tsAdds timestamp to every logging output
-t / --target[[domain/]username[:password]@](必須)
-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)
-dc-ipIP Address of the domain controller. If omitted it will use the domain part (FQDN) specified in the target parameter
--exportexport keys to file
-fileMaster Key File to parse(必須)
-sidSID of the user
-pvkDomain backup privatekey to use for decryption
-keySpecific key to use for decryption
-passwordUser’s password. If you specified the SID and not the password it will be prompted
-systemSYSTEM hive to parse
-securitySECURITY hive to parse
-vcrdVault Credential file
-vpolVault Policy file
-entropyString with extra entropy needed for decryption
-entropy-fileFile with binary entropy contents (overwrites -entropy)
-outfileunprotect で復号したバイト列をファイルに保存します。省略時は hexdump を表示します。
-entryEntry index in CREDHIST

関連技術: DPAPI / SAM / LSA / NTDS の master key 階層、deriveKeysFromUser、Vault。

backupkeys、masterkey、credential、vault、unprotect、credhist subcommand から入力構造を選びます。各 binary file を対応 structure で parse し、password/SID/user key/domain PVK/DPAPI_SYSTEM などから候補 key を導出、MAC/署名を確認して復号・表示します。

DPAPI は一つの password で直接すべての secret を暗号化するのではなく、 user/machine key から master key を保護し、その master key で credential や Vault の個別 blob を保護する階層です。このコマンドの subcommand は階層の どの file を入力し、どの key source まで既知かに応じて分かれています。

masterkey は MasterKeyFile header と複数 section を解析し、SID+password、 NT/SHA key、DPAPI_SYSTEM、domain backup private key などから復号 key を導出 します。credential と unprotect は master key の SHA1 等を受け取り、 DPAPI_BLOB の algorithm、salt、HMAC、ciphertext を検証・復号します。 credhist は password 変更前の user key chain を遡るための形式です。

Vault は policy file (vpol) に暗号化された Vault key があり、その key で credential record (vcrd) の属性を復号します。domain backup key 経路は remote BKRP/LSA から private key material を取得・変換します。GUID で blob と master key を対応付け、MAC 検証に失敗した平文候補を成功として表示しないことが 全 subcommand 共通の要点です。

シンボル位置責務を追う入口
DPAPI64__init__()、getDPAPI_SYSTEM()、getLSA()、run()
モジュール使用する主な名前
impacket.uuidbin_to_string
impacketcrypto, version
impacket.smbconnectionSMBConnection
impacket.dcerpc.v5bkrp, lsad, transport
impacket.dcerpc.v5.rpcrtRPC_C_AUTHN_GSS_NEGOTIATE, RPC_C_AUTHN_LEVEL_PKT_PRIVACY
impacket.exampleslogger
impacket.examples.utilsparse_target
impacket.examples.secretsdumpLSASecrets, LocalOperations
impacket.structurehexdump
impacket.dpapiCREDENTIAL_BLOB, CREDHIST_FILE, CredHist, CredentialFile, DPAPI_BLOB, DPAPI_DOMAIN_RSA_MASTER_KEY, DomainKey, MasterKey, MasterKeyFile, PREFERRED_BACKUP_KEY, PRIVATE_KEY_BLOB, PVK_FILE_HDR, P_BACKUP_KEY, VAULT_KNOWN_SCHEMAS, VAULT_VCRD, VAULT_VPOL, VAULT_VPOL_KEYS, deriveKeysFromUser, deriveKeysFromUserkey, privatekeyblob_to_pkcs1
import 名配布パッケージ経路・宣言状態
Cryptodomepycryptodomex直接 import、宣言済み
sixsix直接 import、宣言済み
  • 照会や認証の試行が中心です。実行回数が多いと監査ログやアカウントロック、対象の負荷に影響します。
  • オプションによりローカルファイルを作成または更新します。既存ファイルの扱いと秘密情報を含む出力の権限を確認してください。
  • 失敗時は、名前解決、接続、認証、サービスの状態、権限のどこで止まったかを、プロトコルのステータスから切り分けます。

impacket.dpapi / crypto、Cryptodome、SMB/RPC bkrp / lsad、examples.secretsdump に依存します。DPAPI.run() の action 分岐と key source の優先順位が中心です。