Once the shell has been execute, we get a shell as www-data
Exploitation
By looking at the hostname and the contents of the “/” directory, we know that we are inside a docker container.
Looking inside the /var/www/html/ directory, we find that there is a file called ThisFileSeemsInteresting.txt. This file contains the 1st flag.
Looking at the home directory, we find that there is the directory for plot_admin.
Inside /home/plot_admin, there is a file called note.txt, However, it is owned by root and only accessible by root. Therefore, we need to escalate our privileges.
Privilege Escalation - Container 1
Trying sudo -l gets nothing, as there are no ‘NOPASSWD’ entries for www-data user.
When looking for SUID binaries, we find that /usr/bin/find has SUID set. Therefore, we leverage that to escalate our privileges.
Now, we can read the note.txt file inside /home/plot_admin
Here, we find our 2nd flag and reference to /var/backups
The /var/backups directory contains a file called .thisisyourpresent
Looking at the contents of this file, we can see plot_admin and some encoded text.
We use CyberChef to decode the text and find that it is SSH key encoded as Base64.
We try using this key to authenticate as the user plot_admin using SSH on port 22, no luck. However, we can login over port 2222. This brings us to another docker container.
Gaining Access - Container 2
In the home directory of plot_admin user, we find that there is flag3.txt file, but again it is owned by root and only accessible to the owner.
We run sudo -l to see if the current user can run any sudo commands without password, no luck.
Looking through the file system for helpful information, we find that there is a .notes.zip file inside /opt directory. However, it is encrypted.
We can use zip2john for extracting hash password for the zip file. zip2john .notes.zip > notes_hash
We can then crack the hash using john:
john --wordlist=/usr/share/wordlists/rockyou.txt note_hash
We can use the password obtained to extract the contents of zip file.
Inside the extracted file, we have a string which looks like a secret/password.
Privilege Escalation - Container 2
We try to use the string found inside notes.txt as plot_admin's password, it works.
We run sudo -l again and find that plot_admin can run any command with sudo.
We use sudo su to spawn root shell.
Now, we can read the contents of the flag3.txt file.
Docker Escape
Since, we are still inside a container, we try to escape.
By running fdisk -l, we find that we can see the host disk, /dev/xvda2/
As we are root, we try to mount /dev/xvda2 to /mnt inside the container.
Finally, we find that the mount was successful and we can access all the files on the host system.
We can read the /mnt/root/root.txt file to get the root flag.
Hope you enjoyed reading this writeup. 😀 Happy Hunting!