Last updated
Last updated
Nmap scan:
Another web-based exploit.
When we check the web port, we see that it is running Cacti.
The version run is actually vulnerable to one unauthenticated RCE exploit, and there are tons of PoCs online to use.
This has to do with the polling of Cacti, and we just need to modify the exploit to point to our own IP address to get a shell.
We got a shell on the docker, so the next step is to escape it.
Within the /
directory, we can find a bash script:
Here's the content of it:
So we have a database password and we can enumerate the database. This docker doesn't have python
, so we cannot spawn a shell via pty
. Instead, we have to use the -e
flag to enumerate the database since we don't have a proper shell.
We can extract the hashed password for the users within the database:
I ran john
on the hashes, and managed to crack one of them to get funkymonkey
.
With this and a username, we can ssh
into the machine as marcus
. Then, grab the user flag.
Within the /var/mail
folder, there's some mail for marcus
:
The first 2 vulnerabilities are not relevant, but the last one was rather interesting.
In short, it appears that when dockers are created, some of the SUID binaries are carried over. In that case, we can enumerate the SUID binaries on the machine and find these using LinPEAS:
capsh
has the SUID binary set, which is not the norm. Based on GTFOBins, we can run this command to spawn a root shell:
Great! Now we are root on the docker. Now, we can find the mounted point of this docker from the main machine, and we can create a bash
SUID binary to get a shell.
First we need to find the mount point using df
:
At/var/lib/docker/overlay2/c41d5854e43bd996e128d647cb526b73d04c9ad6325201c85f73fdba372cb2f1/merged
would bring us to the file system of the docker container. Then, using our root shell on docker, we can just use chmod u+s /bin/bash
to spawn a SUID binary for the main machine to use.
This works because of the CVE allowing for us to create SUID binaries across machines.
We can see the SUID bash
binary here:
We can get a root shell easily:
Rooted!