From nmap, there is a http service.

Local Picture

This is the web page.

Local Picture

There is a directory /moodle.

Local Picture

And a login page.

Local Picture

With a calendar export function.

Local Picture

From the calendar, we can see that it is running version 2017111301.

Local Picture

It is Moodle 3.4.1.

Local Picture

From searchsploit, I found a RCE script for this version, however, it needs username and password to be executed.

Local Picture

Go back to the web page. There are .png images in gallery.html.

Local Picture

One of the image is not an image actually, and the browser gives the error. It is a text file containing information about the credential.

Local Picture

I use wfuzz and get the correct credential.

Local Picture

Now, I can login as Giovanni.

Local Picture

This is the RCE script, and I am going to create a reverse shell.

Local Picture

Local Picture

I successfully get the reverse shell as www-data.

Local Picture

From /etc/phpmyadmin/config-db.php, we get the phpmyadmin credential.

Local Picture

In /var/www/html/moodle/config.php, there is root credential for MariaDB.

Local Picture

We get giovanni’s bcrypt hash and md5 hash from MariaDB.

Local Picture

We can crack the md5 hash online.

Local Picture

Now, I am giovanni, and there is a work directory.

Local Picture

From pspy, we can see that root runs backup.sh every minute.

Local Picture

From the shell script, it compress the directory courses to tmp, decompress it, and gives permission 777 to every file under that directory. At first, I cannot edit backup.sh. So, I create a symbolic link to backup.sh in tmp directory, and backup.sh becomes writable a minute later.

Local Picture

I add some commands to get a SUID bash at the beginning of backup.sh, and I get a privileged bash a minute later.

Local Picture