Skip to content

Commit 1af12fd

Browse files
committed
Glassfish version 9
1 parent 6046994 commit 1af12fd

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

lib/metasploit/framework/login_scanner/glassfish.rb

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,33 @@ 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+
if res && res.code == 302
149+
opts = {
150+
'uri' => '/applications/upload.jsf',
151+
'method' => 'GET',
152+
'headers' => {
153+
'Cookie' => "JSESSIONID=#{self.jsession}"
154+
}
155+
}
156+
157+
res = send_request(opts)
158+
if res && res.code.to_i == 302 && res.headers['Location'].to_s !~ /loginError\.jsf$/
159+
return {:status => Metasploit::Model::Login::Status::SUCCESSFUL, :proof => res.body}
160+
end
161+
end
162+
163+
{:status => Metasploit::Model::Login::Status::INCORRECT, :proof => res.body}
164+
end
165+
166+
140167
# Tries to login to Glassfish version 3 or 4 (as of now it's the latest)
141168
#
142169
# @param (see #try_glassfish_2)
@@ -176,12 +203,15 @@ def attempt_login(credential)
176203

177204
begin
178205
case self.version
179-
when /^[29]\.x$/
206+
when /^2\.x$/
180207
status = try_glassfish_2(credential)
181208
result_opts.merge!(status)
182209
when /^[34]\./
183210
status = try_glassfish_3(credential)
184211
result_opts.merge!(status)
212+
when /^9\.x$/
213+
status = try_glassfish_9(credential)
214+
result_opts.merge!(status)
185215
end
186216
rescue ::EOFError, Errno::ECONNRESET, Rex::ConnectionError, OpenSSL::SSL::SSLError, ::Timeout::Error => e
187217
result_opts.merge!(status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT, proof: e)
@@ -191,7 +221,7 @@ def attempt_login(credential)
191221
end
192222

193223
#
194-
# Extract the target's glassfish version from the HTTP Server header
224+
# Extract the target's glassfish version from the HTTP Server Sun Java System Application Server 9.1header
195225
# (ex: Sun Java System Application Server 9.x)
196226
#
197227
# @param banner [String] `Server` header from a Glassfish service response

0 commit comments

Comments
 (0)