This box was downloaded from VulnHub and is also on the TJnull list of practice boxes for OSCP preparation. The box involved the follows:
- Web enumeration with gobuster
- Wordpress exploit to gain initial shell
- Sudo exploit for privilege escalation
I always start my enumeration from the autorecon scan. Initial Nmap scan results are as below:
Scanned at 2022-04-20 05:50:19 EDT for 7s
Not shown: 998 closed tcp ports (reset)
PORT STATE SERVICE REASON VERSION
22/tcp open ssh syn-ack ttl 64 OpenSSH 7.2p2 Ubuntu 4ubuntu2.8 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 8d:c5:20:23:ab:10:ca:de:e2:fb:e5:cd:4d:2d:4d:72 (RSA)
80/tcp open http syn-ack ttl 64 Apache httpd 2.4.18 ((Ubuntu))
|_http-title: HacknPentest
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
|_http-server-header: Apache/2.4.18 (Ubuntu)
Uptime guess: 127.804 days (since Mon Dec 13 09:32:15 2021)
Network Distance: 1 hop
TCP Sequence Prediction: Difficulty=259 (Good luck!)
IP ID Sequence Generation: All zeros
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
TRACEROUTE
HOP RTT ADDRESS
1 0.31 ms 10.0.0.29
The initial scan shows only two ports open, port 80 and port 22. I will start the enumeration from port 80.
The Nmap script scan shows that there is a WordPress installation.
So, I quickly ran the wpscan on the WordPress server for user and vulnerable plugins enumeration. The following information was gathered.
- Wordpress version 5.2.2
- User name :
victor
Further, I couldn’t find anything. I started a gobuster scan and found a new web directory. /dev
It turns out to be a distract webpage.
Now I looked for other things but couldn’t find anything. Now I run gobuster looking for .php and .txt files in hope of finding something interesting. And I did find secret.txt file
The content of secret.txt file gave us another clue.
Following the link, it takes us to a GitHub page where I found the use of wfuzz to enumerate the correct parameter for a page. Following the command to our web-page and using the hint from secret.txt I found another clue.
10.0.0.29/index.php?file=location.txt
So we can use secrettier360 on another php page. According to our gobuster scan, there is /image.php page.
Tried using a few commands and it looks like the parameter is vulnerable to LFI. Lets try to read the content of /etc/passwd.
In the /etc/passwd file we can see user saket has the password.txt in his home folder.
Let’s read that file. found the password follow_the_ippsec.
I tried using this password in WordPress login and was successful logging in with user victor.
So looks like we can edit themes. But only secret.php file can be edited.
So I will upload the php reverse shell payload from pentest monkey to get the reverse shell.
http://10.0.0.29/wordpress/wp-content/themes/twentynineteen/secret.php
Looking around I found an enc executable file inside the saket home directory, which is password protected. Further enumeration, I found the backup_pass file inside opt/backup/server_database which consist password for enc file.
So it runs the copy command and copies files /root/enc.txt and /root/key.txt to the home of user saket.
Now checking the sudo -l command, I can see that the www-data user can run the sudo command to run that enc binary. ( Everything is Connected LOL)
Now running the binary with the sudo command copies those files to home directory of user saket. The content of those files is as below.
It looks like the enc is encrypted text and the key to decrypt is the md5 of the string ippsec. I was lost on this, looking for decrypting base64 with a key on the internet I came through this website, where I can decrypt a AES encrypted text.
The decrypted text is as below.
Dont worry saket one day we will reach toour destination very soon. And if you forget your username then use your
old password==> "tribute_to_ippsec"
Victor,
Looks like it is a password for the user saket. I changed the user to saket .
Now again running sudo -l command I can see the user saket can run a command with sudo without a password.
When I run that binary with sudo, it returns some error,
It says /tmp/challenge not found. I went to the directory /tmp and could not see any file with the name challenge. Can I just create a file with a bash command to get the root shell? Let’s try
Yes, got the root shell.