Jerry Writeup w/o Metasploit

Reconnaissance

Run the nmapAutomatoarrow-up-rightr script to enumerate open ports and services running on those ports.

  • All: Runs all the scans consecutively.

We get back the following result.

We have one port open.

  • Port 8080: running Apache Tomcat/Coyote JSP engine 1.1

Before we move on to enumeration, let’s make some mental notes about the scan results.

  • Port 8080 is running Apache Tomcat and the nmap scan found the /manager/html page, which is the login page to the Manager interface. The nikto scan identified that this page is using the default credentials tomcat/s3cret. Apache Tomcat by design allows you to run code, so we can simply deploy a war file that sends a reverse shell back to our attack machine.

Since we already have a way to get code execution on the box, we can just move on to the exploitation phase.

Exploitation

Visit the /manager/html page and log in with the credentials tomcat/s3cret.

Generate a war file that contains a reverse shell using msfvenom.

Upload the file on the Tomcat Application Manager and deploy it.

Set up a listener on the target machine.

Click on the war file in the Tomcat Application Manager to execute our shell.

We get a shell with SYSTEM privileges! That was easy! We don’t even have to escalate our privileges for this box.

Grab the user.txt and root.txt flags.

Lessons Learned

To get SYSTEM on this box, we exploited two vulnerabilities.

  • Use of Default Credentials. There was an exposed port that was running Apache Tomcat. The administrator had used default credentials for the manager interface. This allowed us to access the interface and deploy a war file that gave us access to the server. Since default credentials are publicly available and can be easily obtained, the administrator should have instead used a sufficiently long password that is difficult to crack.

  • Least Privilege Violation. Tomcat doesn’t need SYSTEM privileges to function properly. Instead it should have been run under a tomcat user account that has limited privileges. This way, even if we did get access to the box, we would have needed to find a way to escalate privileges, instead of immediately getting SYSTEM access without having to work for it. The administrator should have conformed to the principle of least privilege.

Last updated