Skip to content

Commit 75a34c4

Browse files
committed
added a new aux module to quickly scan for Jenkins servers on the local broadcast network by sending out a udp packet to port 33848 on the broadcast address. Any Jenkins server should respond with XML data containing the Jenkins server version.
1 parent 8156859 commit 75a34c4

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
8+
class MetasploitModule < Msf::Auxiliary
9+
include Msf::Exploit::Remote::Udp
10+
include Msf::Auxiliary::Report
11+
12+
def initialize(info = {})
13+
super(
14+
update_info(
15+
info,
16+
'Name' => 'Jenkins Server Broadcast Enumeration',
17+
'Description' => %q(
18+
This module sends out a udp broadcast packet querying for
19+
any Jenkins servers on the local network.
20+
Be advised that while this module does not identify the
21+
port on which Jenkins is running, the default port for
22+
Jenkins is 8080.
23+
),
24+
'Author' =>
25+
[
26+
'Adam Compton <[email protected]>',
27+
'Matt Schmidt <[email protected]>'
28+
],
29+
'References' =>
30+
[
31+
[ 'URL', 'https://wiki.jenkins-ci.org/display/JENKINS/Auto-discovering+Jenkins+on+the+network' ]
32+
],
33+
'License' => MSF_LICENSE
34+
)
35+
)
36+
deregister_options('RHOST', 'RPORT')
37+
end
38+
39+
def parse_reply(pkt)
40+
# if empty packet, exit
41+
return if !pkt[1]
42+
43+
# strip to just the IPv4 address
44+
if pkt[1] =~ /^::ffff:/
45+
pkt[1] = pkt[1].sub(/^::ffff:/, '')
46+
end
47+
48+
# check for and extract the version string
49+
ver = nil
50+
if !ver && pkt[0] =~ /version>(.*)<\/version/i
51+
ver = $1
52+
end
53+
54+
# if a version was identified, then out and store to DB
55+
if ver
56+
print_status("Found Jenkins Server at: #{pkt[1]} version : #{ver}")
57+
report_host(
58+
host: pkt[1],
59+
info: "Jenkins v.#{ver} (port typically 8080)"
60+
)
61+
end
62+
end
63+
64+
def run
65+
print_status('Sending Jenkins UDP Broadcast Probe ...')
66+
67+
# create a udp socket
68+
self.udp_sock = Rex::Socket::Udp.create(
69+
'Context' => { 'Msf' => framework, 'MsfExploit' => self }
70+
)
71+
add_socket(self.udp_sock)
72+
73+
# send a dummy packet to broadcast on port 33848
74+
udp_sock.sendto('\n', '255.255.255.255', 33848, 0)
75+
76+
# loop a few times to account for slow responders
77+
iter = 0
78+
while (r = udp_sock.recvfrom(65535, 0.1)) && (iter < 10)
79+
parse_reply(r)
80+
iter += 1
81+
end
82+
end
83+
end

0 commit comments

Comments
 (0)