@@ -129,7 +129,7 @@ def do_web_login(user, pass)
129
129
vprint_status ( "#{ target_url } - Searching Joomla Login Response..." )
130
130
res = get_login_response
131
131
132
- unless res && res . code = 200 && res . headers [ 'Set-Cookie' ]
132
+ unless res && res . code = 200 && ! res . get_cookies . blank?
133
133
vprint_error ( "#{ target_url } - Failed to find Joomla Login Response" )
134
134
return nil
135
135
end
@@ -138,14 +138,14 @@ def do_web_login(user, pass)
138
138
hidden_value = get_login_hidden ( res )
139
139
if hidden_value . nil?
140
140
vprint_error ( "#{ target_url } - Failed to find Joomla Login Form" )
141
- return
141
+ return nil
142
142
end
143
143
144
144
vprint_status ( "#{ target_url } - Searching Joomla Login Cookies..." )
145
145
cookie = get_login_cookie ( res )
146
146
if cookie . blank?
147
147
vprint_error ( "#{ target_url } - Failed to find Joomla Login Cookies" )
148
- return
148
+ return nil
149
149
end
150
150
151
151
vprint_status ( "#{ target_url } - Login with cookie ( #{ cookie } ) and Hidden ( #{ hidden_value } =1 )" )
@@ -235,31 +235,31 @@ def get_login_cookie(res)
235
235
def get_login_hidden ( res )
236
236
return nil unless res . kind_of? ( Rex ::Proto ::Http ::Response )
237
237
238
- if res . body && res . body . to_s =~ /<form action=([^ \> ]+) \> (.*)< \/ form>/mi
238
+ return nil if res . body . blank?
239
239
240
- vprint_status ( "#{ target_url } - Testing Joomla 2.5 Form..." )
241
- form = res . body . split ( /<form action=([^\> ]+) method="post" id="form-login"\> (.*)<\/ form>/mi )
240
+ vprint_status ( "#{ target_url } - Testing Joomla 2.5 Form..." )
241
+ form = res . body . split ( /<form action=([^\> ]+) method="post" id="form-login"\> (.*)<\/ form>/mi )
242
242
243
- if form . length == 1 #is not Joomla 2.5
244
- vprint_status ( "#{ target_url } - Testing Form Joomla 3.0 Form..." )
245
- form = res . body . split ( /<form action=([^\> ]+) method="post" id="form-login" class="form-inline"\> (.*)<\/ form>/mi )
246
- end
243
+ if form . length == 1 #is not Joomla 2.5
244
+ vprint_status ( "#{ target_url } - Testing Form Joomla 3.0 Form..." )
245
+ form = res . body . split ( /<form action=([^\> ]+) method="post" id="form-login" class="form-inline"\> (.*)<\/ form>/mi )
246
+ end
247
247
248
- unless form
249
- vprint_error ( "#{ target_url } - Joomla Authentication Form Not Found " )
250
- form = res . body . split ( /<form id="login-form" action=([^\> ]+)\> (.*)<\/ form>/mi )
251
- end
248
+ if form . length == 1
249
+ vprint_error ( "#{ target_url } - Last chance to find a login form... " )
250
+ form = res . body . split ( /<form id="login-form" action=([^\> ]+)\> (.*)<\/ form>/mi )
251
+ end
252
252
253
+ begin
253
254
input_hidden = form [ 2 ] . split ( /<input type="hidden"([^\> ]+)\/ >/mi )
254
-
255
255
input_id = input_hidden [ 7 ] . split ( "\" " )
256
-
257
- valor_input_id = input_id [ 1 ]
258
-
259
- return valor_input_id
256
+ rescue NoMethodError
257
+ return nil
260
258
end
261
259
262
- nil
260
+ valor_input_id = input_id [ 1 ]
261
+
262
+ return valor_input_id
263
263
end
264
264
265
265
end
0 commit comments