Corrosion 2 Walkthrough

Corrosion - 2 Writeup#

This is a medium difficulty machine that involves exploiting a Tomcat server, escalating privileges through SUID binaries, and ultimately gaining root access.

Enumeration#

Initial Nmap Scan#

I started with an Nmap scan and found three open ports: SSH (22), HTTP (80), and HTTP (8080). The HTTP service on port 8080 was running Tomcat.

Nmap Results

User Enumeration#

Manually checking the machine, I discovered that there are three users present: randy ,jaye and tomcat.

User Enumeration

Site Enumeration and Brute-forcing#

Next, I enumerated the site and found a login prompt at /manager. The default credentials didn’t work, so I brute-forced the login and discovered some credentials, but none of them were successful.

Login Prompt

Directory Brute-forcing#

Running gobuster revealed an interesting zip file that seemed unusual.

Zip File Found

Cracking the Zip File#

I downloaded the file, but it was password protected. Using fcrackzip (or zip2john), I cracked it and found credentials for admin and manager. Logging in using these credentials was successful.

Zip Cracked

Successful Login

Gaining a Reverse Shell#

After logging in, I enumerated the site further and found a Manager Authenticated Upload feature. This allowed me to upload a shell and get a Meterpreter session.

Uploading Shell

Reverse Shell

Privilege Escalation#

I uploaded linpeas to the server to check for SUID binaries. After exploring a few of them, nothing seemed useful at first.

Linpeas Output

Switching Users#

After some time, I attempted to switch to the jaye user using the same password found earlier. It worked!

Switch to Jaye

Exploring Jaye’s Home Directory#

In jaye’s home directory, I found a folder with an interesting SUID file. This file accepts a string and filename as input. By using a simple trick, I passed an empty string to it, which allowed me to read /etc/shadow.

SUID Binary Exploit

Cracking the Hash#

It’s a SHA-512 with salt take some time to crack I tried to extract the randy hash and successfully cracked it. The password was 07051986randy. With this, I could escalate to root.

Hash Cracked

Final Privilege Escalation#

Using sudo -l, I noticed that I could run randombase64.py as root. Searching for more base64 file in the system, I found it to be a SUID perm. After some tinkering, I managed to spawn a root shell by executing os.system(’/bin/bash’) in file.

Privilege Escalation

Root Shell#

Finally, I gained a root shell!

Root Shell

  • Sagar Sehrawat

Adapted from sagar-sehrawat/VulnHub-Machine-Solutions under MIT.

Find us elsewhere

Merch, stickers, and moreSupport the work at the Solvere Labs shop