Skip to content

Commit a10fa02

Browse files
committed
Land rapid7#5606, @wchen-r7's glassfish fixes
2 parents b46e1be + 3b5e2a0 commit a10fa02

File tree

2 files changed

+288
-311
lines changed

2 files changed

+288
-311
lines changed

lib/metasploit/framework/login_scanner/glassfish.rb

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Glassfish < HTTP
1414

1515
# @!attribute [r] version
1616
# @return [String] Glassfish version
17-
attr_reader :version
17+
attr_accessor :version
1818

1919
# @!attribute jsession
2020
# @return [String] Cookie session
@@ -137,6 +137,23 @@ def try_glassfish_2(credential)
137137
end
138138

139139

140+
# Tries to login to Glassfish version 9
141+
#
142+
# @param credential [Metasploit::Framework::Credential] The credential object
143+
# @return [Hash]
144+
# * :status [Metasploit::Model::Login::Status]
145+
# * :proof [String] the HTTP response body
146+
def try_glassfish_9(credential)
147+
res = try_login(credential)
148+
149+
if res && res.code.to_i == 302 && res.headers['Location'].to_s !~ /loginError\.jsf$/
150+
return {:status => Metasploit::Model::Login::Status::SUCCESSFUL, :proof => res.body}
151+
end
152+
153+
{:status => Metasploit::Model::Login::Status::INCORRECT, :proof => res.body}
154+
end
155+
156+
140157
# Tries to login to Glassfish version 3 or 4 (as of now it's the latest)
141158
#
142159
# @param (see #try_glassfish_2)
@@ -176,12 +193,15 @@ def attempt_login(credential)
176193

177194
begin
178195
case self.version
179-
when /^[29]\.x$/
196+
when /^2\.x$/
180197
status = try_glassfish_2(credential)
181198
result_opts.merge!(status)
182199
when /^[34]\./
183200
status = try_glassfish_3(credential)
184201
result_opts.merge!(status)
202+
when /^9\.x$/
203+
status = try_glassfish_9(credential)
204+
result_opts.merge!(status)
185205
end
186206
rescue ::EOFError, Errno::ECONNRESET, Rex::ConnectionError, OpenSSL::SSL::SSLError, ::Timeout::Error => e
187207
result_opts.merge!(status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT, proof: e)
@@ -190,8 +210,8 @@ def attempt_login(credential)
190210
Result.new(result_opts)
191211
end
192212

193-
#
194-
# Extract the target's glassfish version from the HTTP Server header
213+
214+
# Extract the target's glassfish version from the HTTP Server Sun Java System Application Server 9.1header
195215
# (ex: Sun Java System Application Server 9.x)
196216
#
197217
# @param banner [String] `Server` header from a Glassfish service response

0 commit comments

Comments
 (0)