Skip to content

Commit 42e82cc

Browse files
committed
Rubocop fixes
1 parent 7275d57 commit 42e82cc

File tree

1 file changed

+45
-51
lines changed

1 file changed

+45
-51
lines changed

modules/auxiliary/scanner/http/jboss_vulnscan.rb

Lines changed: 45 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,16 @@
77
require 'msf/core'
88

99
class Metasploit3 < Msf::Auxiliary
10-
1110
include Msf::Exploit::Remote::HttpClient
1211
include Msf::Auxiliary::Scanner
1312
include Msf::Auxiliary::Report
1413

1514
def initialize(info = {})
1615
super(update_info(info,
1716
'Name' => 'JBoss Vulnerability Scanner',
18-
'Description' => %q{
17+
'Description' => %q(
1918
This module scans a JBoss instance for a few vulnerablities.
20-
},
19+
),
2120
'Author' =>
2221
[
2322
'Tyler Krpata',
@@ -32,31 +31,29 @@ def initialize(info = {})
3231

3332
register_options(
3433
[
35-
OptString.new('VERB', [ true, "Verb for auth bypass testing", "HEAD"]),
34+
OptString.new('VERB', [ true, "Verb for auth bypass testing", "HEAD"])
3635
], self.class)
3736
end
3837

39-
4038
def run_host(ip)
41-
4239
res = send_request_cgi(
4340
{
44-
'uri' => "/"+Rex::Text.rand_text_alpha(12),
41+
'uri' => "/" + Rex::Text.rand_text_alpha(12),
4542
'method' => 'GET',
46-
'ctype' => 'text/plain',
47-
43+
'ctype' => 'text/plain'
4844
}, 20)
4945

5046
if res
5147

52-
info = http_fingerprint({ :response => res })
48+
info = http_fingerprint(:response => res)
5349
print_status(info)
5450

55-
if(res.body and />(JBoss[^<]+)/.match(res.body) )
51+
if res.body && />(JBoss[^<]+)/.match(res.body)
5652
print_error("#{rhost}:#{rport} JBoss error message: #{$1}")
5753
end
5854

59-
apps = [ '/jmx-console/HtmlAdaptor',
55+
apps = [
56+
'/jmx-console/HtmlAdaptor',
6057
'/status',
6158
'/web-console/ServerInfo.jsp',
6259
# apps added per Patrick Hof
@@ -78,22 +75,21 @@ def run_host(ip)
7875
4444 => 'RMI invoker'
7976
}
8077
print_status("#{rhost}:#{rport} Checking services...")
81-
ports.each do |port,service|
82-
status = test_connection(ip,port) == :up ? "open" : "closed";
78+
ports.each do |port, service|
79+
status = test_connection(ip, port) == :up ? "open" : "closed"
8380
print_status("#{rhost}:#{rport} #{service} tcp/#{port}: #{status}")
8481
end
8582
end
8683
end
8784

8885
def check_app(app)
89-
9086
res = send_request_cgi({
9187
'uri' => app,
9288
'method' => 'GET',
93-
'ctype' => 'text/plain',
89+
'ctype' => 'text/plain'
9490
}, 20)
9591

96-
if (res)
92+
if res
9793
case
9894
when res.code == 200
9995
print_good("#{rhost}:#{rport} #{app} does not require authentication (200)")
@@ -115,35 +111,34 @@ def check_app(app)
115111
end
116112
end
117113

118-
def jboss_as_default_creds()
114+
def jboss_as_default_creds
119115
print_status("#{rhost}:#{rport} Checking for JBoss AS default creds")
120116

121-
session = jboss_as_session_setup(rhost, rport)
122-
if session.nil?
123-
return
124-
end
117+
session = jboss_as_session_setup(rhost, rport)
118+
return false if session.nil?
125119

126-
# Default AS creds
127-
username = "admin"
128-
password = "admin"
129-
130-
res = send_request_raw({
131-
'uri' => "/admin-console/login.seam",
132-
'method' => "POST",
133-
'version' => '1.1',
134-
'vhost' => "#{rhost}",
135-
'headers' => { "Content-Type" => "application/x-www-form-urlencoded",
136-
"Cookie" => "JSESSIONID=#{session["jsessionid"]}"},
137-
'data' => "login_form=login_form&login_form%3Aname=#{username}&login_form%3Apassword=#{password}&login_form%3Asubmit=Login&javax.faces.ViewState=#{session["viewstate"]}"
138-
}, 20)
120+
# Default AS creds
121+
username = "admin"
122+
password = "admin"
139123

140-
# Valid creds if 302 redirected to summary.seam and not error.seam
141-
if (res and res.code == 302 and /error.seam/m !~ res.headers.to_s and /summary.seam/m =~ res.headers.to_s)
142-
print_good("#{rhost}:#{rport} Authenticated using #{username}:#{password} at /admin-console/")
143-
add_creds(username, password)
144-
else
145-
print_status("#{rhost}:#{rport} Could not guess admin credentials")
146-
end
124+
res = send_request_raw({
125+
"uri" => "/admin-console/login.seam",
126+
"method" => "POST",
127+
"version" => "1.1",
128+
"vhost" => "#{rhost}",
129+
"headers" => { "Content-Type" => "application/x-www-form-urlencoded",
130+
"Cookie" => "JSESSIONID=#{session['jsessionid']}"
131+
},
132+
"data" => "login_form=login_form&login_form%3Aname=#{username}&login_form%3Apassword=#{password}&login_form%3Asubmit=Login&javax.faces.ViewState=#{session["viewstate"]}"
133+
}, 20)
134+
135+
# Valid creds if 302 redirected to summary.seam and not error.seam
136+
if res && res.code == 302 && /error.seam/m !~ res.headers.to_s && /summary.seam/m =~ res.headers.to_s
137+
print_good("#{rhost}:#{rport} Authenticated using #{username}:#{password} at /admin-console/")
138+
add_creds(username, password)
139+
else
140+
print_status("#{rhost}:#{rport} Could not guess admin credentials")
141+
end
147142
end
148143

149144
def add_creds(username, password)
@@ -173,10 +168,10 @@ def jboss_as_session_setup(rhost, rport)
173168
'uri' => "/admin-console/login.seam",
174169
'method' => "GET",
175170
'version' => "1.1",
176-
'vhost' => "#{rhost}",
171+
'vhost' => "#{rhost}"
177172
}, 20)
178173

179-
if (res)
174+
if res
180175
begin
181176
viewstate = /javax.faces.ViewState" value="(.*)" auto/.match(res.body).captures[0]
182177
jsessionid = /JSESSIONID=(.*);/.match(res.headers.to_s).captures[0]
@@ -197,7 +192,7 @@ def bypass_auth(app)
197192
'version' => '1.0' # 1.1 makes the head request wait on timeout for some reason
198193
}, 20)
199194

200-
if (res and res.code == 200)
195+
if res && res.code == 200
201196
print_good("#{rhost}:#{rport} Got authentication bypass via HTTP verb tampering")
202197
else
203198
print_status("#{rhost}:#{rport} Could not get authentication bypass via HTTP verb tampering")
@@ -209,30 +204,29 @@ def basic_auth_default_creds(app)
209204
'uri' => app,
210205
'method' => 'GET',
211206
'ctype' => 'text/plain',
212-
'authorization' => basic_auth('admin','admin')
207+
'authorization' => basic_auth('admin', 'admin')
213208
}, 20)
214209

215-
if (res and res.code == 200)
210+
if res && res.code == 200
216211
print_good("#{rhost}:#{rport} Authenticated using admin:admin at #{app}")
217-
add_creds("admin","admin")
212+
add_creds("admin", "admin")
218213
else
219214
print_status("#{rhost}:#{rport} Could not guess admin credentials")
220215
end
221216
end
222217

223218
# function stole'd from mssql_ping
224-
def test_connection(ip,port)
219+
def test_connection(ip, port)
225220
begin
226221
sock = Rex::Socket::Tcp.create(
227222
'PeerHost' => ip,
228223
'PeerPort' => port,
229224
'Timeout' => 20
230-
)
225+
)
231226
rescue Rex::ConnectionError
232227
return :down
233228
end
234229
sock.close
235230
return :up
236231
end
237-
238232
end

0 commit comments

Comments
 (0)