Skip to content

Commit 30de4cd

Browse files
committed
Fix get_login_hidden
1 parent ff3a21b commit 30de4cd

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

modules/auxiliary/scanner/http/joomla_bruteforce_login.rb

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def do_web_login(user, pass)
129129
vprint_status("#{target_url} - Searching Joomla Login Response...")
130130
res = get_login_response
131131

132-
unless res && res.code = 200 && res.headers['Set-Cookie']
132+
unless res && res.code = 200 && !res.get_cookies.blank?
133133
vprint_error("#{target_url} - Failed to find Joomla Login Response")
134134
return nil
135135
end
@@ -138,14 +138,14 @@ def do_web_login(user, pass)
138138
hidden_value = get_login_hidden(res)
139139
if hidden_value.nil?
140140
vprint_error("#{target_url} - Failed to find Joomla Login Form")
141-
return
141+
return nil
142142
end
143143

144144
vprint_status("#{target_url} - Searching Joomla Login Cookies...")
145145
cookie = get_login_cookie(res)
146146
if cookie.blank?
147147
vprint_error("#{target_url} - Failed to find Joomla Login Cookies")
148-
return
148+
return nil
149149
end
150150

151151
vprint_status("#{target_url} - Login with cookie ( #{cookie} ) and Hidden ( #{hidden_value}=1 )")
@@ -235,31 +235,31 @@ def get_login_cookie(res)
235235
def get_login_hidden(res)
236236
return nil unless res.kind_of?(Rex::Proto::Http::Response)
237237

238-
if res.body && res.body.to_s =~ /<form action=([^\>]+)\>(.*)<\/form>/mi
238+
return nil if res.body.blank?
239239

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)
242242

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
247247

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
252252

253+
begin
253254
input_hidden = form[2].split(/<input type="hidden"([^\>]+)\/>/mi)
254-
255255
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
260258
end
261259

262-
nil
260+
valor_input_id = input_id[1]
261+
262+
return valor_input_id
263263
end
264264

265265
end

0 commit comments

Comments
 (0)