Skip to content

Commit d05cae5

Browse files
committed
Land rapid7#5329, @wchen-r7's add configurable options to jenkins_login
2 parents 2882374 + 1cc44cf commit d05cae5

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

lib/metasploit/framework/login_scanner/jenkins.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ def set_sane_defaults
1717
self.uri = "/j_acegi_security_check" if self.uri.nil?
1818
self.method = "POST" if self.method.nil?
1919

20+
if self.uri[0] != '/'
21+
self.uri = "/#{self.uri}"
22+
end
23+
2024
super
2125
end
2226

@@ -37,15 +41,15 @@ def attempt_login(credential)
3741
configure_http_client(cli)
3842
cli.connect
3943
req = cli.request_cgi({
40-
'method'=>'POST',
41-
'uri'=>'/j_acegi_security_check',
44+
'method'=> method,
45+
'uri'=> uri,
4246
'vars_post'=> {
4347
'j_username' => credential.public,
44-
'j_password'=>credential.private
48+
'j_password'=> credential.private
4549
}
4650
})
4751
res = cli.send_recv(req)
48-
if res && !res.headers['location'].include?('loginError')
52+
if res && res.headers['location'] && !res.headers['location'].include?('loginError')
4953
result_opts.merge!(status: Metasploit::Model::Login::Status::SUCCESSFUL, proof: res.headers)
5054
else
5155
result_opts.merge!(status: Metasploit::Model::Login::Status::INCORRECT, proof: res)

modules/auxiliary/scanner/http/jenkins_login.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ def initialize
2323

2424
register_options(
2525
[
26+
OptString.new('LOGIN_URL', [true, 'The URL that handles the login process', '/j_acegi_security_check']),
27+
OptEnum.new('HTTP_METHOD', [true, 'The HTTP method to use for the login', 'POST', ['GET', 'POST']]),
2628
Opt::RPORT(8080)
2729
], self.class)
2830

@@ -44,6 +46,8 @@ def run_host(ip)
4446

4547
scanner = Metasploit::Framework::LoginScanner::Jenkins.new(
4648
configure_http_login_scanner(
49+
uri: datastore['LOGIN_URL'],
50+
method: datastore['HTTP_METHOD'],
4751
cred_details: cred_collection,
4852
stop_on_success: datastore['STOP_ON_SUCCESS'],
4953
bruteforce_speed: datastore['BRUTEFORCE_SPEED'],

0 commit comments

Comments
 (0)