Skip to content

Commit c0a3691

Browse files
committed
Adding Jenkins-CI Login Scanner
Per Github issue rapid7#3871 (RM8774), I have added a login scanner module for Jenkins-CI installations.
1 parent a65ee6c commit c0a3691

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
require 'pry'
6+
require 'msf/core'
7+
8+
class Metasploit3 < Msf::Auxiliary
9+
10+
include Msf::Exploit::Remote::HttpClient
11+
include Msf::Auxiliary::Report
12+
include Msf::Auxiliary::AuthBrute
13+
include Msf::Auxiliary::Scanner
14+
15+
def initialize
16+
super(
17+
'Name' => 'Jenkins-CI Login Utility',
18+
'Description' => 'This module simply attempts to login to a Jenkins-CI instance using a specific user/pass.',
19+
'Author' => [ 'NS', 'Nicholas Starke <starke.nicholas[at]gmail.com>', 'nstarke' ],
20+
'License' => MSF_LICENSE
21+
)
22+
23+
register_options(
24+
[
25+
Opt::RPORT(8080),
26+
OptAddress.new('RHOST', [ true, "The target address", true])
27+
], self.class)
28+
29+
register_autofilter_ports([ 80, 443, 8080, 8081, 8000 ])
30+
deregister_options('RHOSTS')
31+
end
32+
33+
def run
34+
each_user_pass do |user, pass|
35+
next if (user.blank? or pass.blank?)
36+
vprint_status("Trying #{user} : #{pass}")
37+
if (datastore['SSL'].to_s.match(/^(t|y|1)/i))
38+
protocol = 'https://'
39+
else
40+
protocol = 'http://'
41+
do_login(user, pass)
42+
end
43+
end
44+
end
45+
46+
def do_login(user, pass)
47+
begin
48+
post_data = {
49+
'j_username' => user,
50+
'j_password' => pass
51+
}
52+
res = send_request_cgi({
53+
'uri' => '/j_acegi_security_check',
54+
'method' => 'POST',
55+
'vars_post' => post_data
56+
})
57+
rescue ::Rex::ConnectionError => e
58+
vprint_error("#{rhost}:#{rport}#{url} - #{e}")
59+
return
60+
end
61+
if not res
62+
vprint_error("#{rhost}:#{rport}#{url} - #{e}")
63+
return
64+
end
65+
if !res.headers['location'].include? 'loginError'
66+
print_good("SUCCESSFUL LOGIN. '#{user} : #{pass}'")
67+
report_hash = {
68+
:host => datastore['RHOST'],
69+
:port => datastore['RPORT'],
70+
:sname => 'jenkins',
71+
:user => user,
72+
:pass => pass,
73+
:active => true,
74+
:type => 'password'
75+
}
76+
report_auth_info(report_hash)
77+
return :next_user
78+
end
79+
end
80+
end

0 commit comments

Comments
 (0)