@@ -22,31 +22,35 @@ class Glassfish < HTTP
22
22
23
23
# (see Base#check_setup)
24
24
def check_setup
25
- res = send_request ( { 'uri' => '/common/index.jsf' } )
26
- return "Connection failed" if res . nil?
27
- if !( [ 200 , 302 ] . include? ( res . code ) )
28
- return "Unexpected HTTP response code #{ res . code } (is this really Glassfish?)"
29
- end
30
-
31
- # If remote login is enabled on 4.x, it redirects to https on the
32
- # same port.
33
- if !self . ssl && res . headers [ 'Location' ] =~ /^https:/
34
- self . ssl = true
25
+ begin
35
26
res = send_request ( { 'uri' => '/common/index.jsf' } )
36
- if res . nil?
37
- return "Connection failed after SSL redirection"
27
+ return "Connection failed" if res . nil?
28
+ if !( [ 200 , 302 ] . include? ( res . code ) )
29
+ return "Unexpected HTTP response code #{ res . code } (is this really Glassfish?)"
38
30
end
39
- if res . code != 200
40
- return "Unexpected HTTP response code #{ res . code } after SSL redirection (is this really Glassfish?)"
31
+
32
+ # If remote login is enabled on 4.x, it redirects to https on the
33
+ # same port.
34
+ if !self . ssl && res . headers [ 'Location' ] =~ /^https:/
35
+ self . ssl = true
36
+ res = send_request ( { 'uri' => '/common/index.jsf' } )
37
+ if res . nil?
38
+ return "Connection failed after SSL redirection"
39
+ end
40
+ if res . code != 200
41
+ return "Unexpected HTTP response code #{ res . code } after SSL redirection (is this really Glassfish?)"
42
+ end
41
43
end
42
- end
43
44
44
- res = send_request ( { 'uri' => '/login.jsf' } )
45
- return "Connection failed" if res . nil?
46
- extract_version ( res . headers [ 'Server' ] )
45
+ res = send_request ( { 'uri' => '/login.jsf' } )
46
+ return "Connection failed" if res . nil?
47
+ extract_version ( res . headers [ 'Server' ] )
47
48
48
- if @version . nil? || @version !~ /^[2349]/
49
- return "Unsupported version ('#{ @version } ')"
49
+ if @version . nil? || @version !~ /^[2349]/
50
+ return "Unsupported version ('#{ @version } ')"
51
+ end
52
+ rescue ::EOFError , Errno ::ETIMEDOUT , Rex ::ConnectionError , ::Timeout ::Error
53
+ return "Unable to connect to target"
50
54
end
51
55
52
56
false
@@ -194,8 +198,8 @@ def attempt_login(credential)
194
198
# @return [nil] If the banner did not match any of the expected values
195
199
def extract_version ( banner )
196
200
# Set version. Some GlassFish servers return banner "GlassFish v3".
197
- if banner =~ /GlassFish Server(?: Open Source Edition)? [[:blank:]]*(\d \. \d )/
198
- @version = $1
201
+ if banner =~ /( GlassFish Server| Open Source Edition)[[:blank:]]*(\d \. \d )/
202
+ @version = $2
199
203
elsif banner =~ /GlassFish v(\d )/
200
204
@version = $1
201
205
elsif banner =~ /Sun GlassFish Enterprise Server v2/
0 commit comments