Skip to content

Commit 25840c4

Browse files
committed
Rubocop
1 parent f4a1e98 commit 25840c4

File tree

1 file changed

+16
-18
lines changed
  • lib/metasploit/framework/login_scanner

1 file changed

+16
-18
lines changed

lib/metasploit/framework/login_scanner/gitlab.rb

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,28 @@
33
module Metasploit
44
module Framework
55
module LoginScanner
6-
76
# Gitlab login scanner
87
class Gitlab < HTTP
9-
108
# Inherit LIKELY_PORTS,LIKELY_SERVICE_NAMES, and REALM_KEY from HTTP
119
CAN_GET_SESSION = false
1210
DEFAULT_PORT = 80
1311
PRIVATE_TYPES = [ :password ]
1412

1513
# (see Base#set_sane_defaults)
1614
def set_sane_defaults
17-
self.uri = '/users/sign_in' if self.uri.nil?
18-
self.method = 'POST' if self.method.nil
15+
self.uri = '/users/sign_in' if uri.nil?
16+
self.method = 'POST' if method.nil
1917

2018
super
2119
end
2220

2321
def attempt_login(credential)
2422
result_opts = {
25-
credential: credential,
26-
host: host,
27-
port: port,
28-
protocol: 'tcp',
29-
service_name: ssl ? 'https' : 'http'
23+
credential: credential,
24+
host: host,
25+
port: port,
26+
protocol: 'tcp',
27+
service_name: ssl ? 'https' : 'http'
3028
}
3129
begin
3230
cli = Rex::Proto::Http::Client.new(host,
@@ -42,11 +40,11 @@ def attempt_login(credential)
4240
cli.connect
4341

4442
# Get a valid session cookie and authenticity_token for the next step
45-
req = cli.request_cgi({
43+
req = cli.request_cgi(
4644
'method' => 'GET',
4745
'cookie' => 'request_method=GET',
48-
'uri' => self.uri
49-
})
46+
'uri' => uri
47+
)
5048

5149
res = cli.send_recv(req)
5250

@@ -55,20 +53,20 @@ def attempt_login(credential)
5553
elsif res.body.include? 'user[login]'
5654
user_field = 'user[login]'
5755
else
58-
raise RuntimeError, 'Not a valid Gitlab login page'
56+
fail RuntimeError, 'Not a valid Gitlab login page'
5957
end
6058

6159
local_session_cookie = res.get_cookies.scan(/(_gitlab_session=[A-Za-z0-9%-]+)/).flatten[0]
6260
auth_token = res.body.scan(/<input name="authenticity_token" type="hidden" value="(.*?)"/).flatten[0]
6361

64-
raise RuntimeError, 'Unable to get Session Cookie' unless local_session_cookie
65-
raise RuntimeError, 'Unable to get Authentication Token' unless auth_token
62+
fail RuntimeError, 'Unable to get Session Cookie' unless local_session_cookie
63+
fail RuntimeError, 'Unable to get Authentication Token' unless auth_token
6664

6765
# Perform the actual login
68-
req = cli.request_cgi({
66+
req = cli.request_cgi(
6967
'method' => 'POST',
7068
'cookie' => local_session_cookie,
71-
'uri' => self.uri,
69+
'uri' => uri,
7270
'vars_post' =>
7371
{
7472
'utf8' => "\xE2\x9C\x93",
@@ -77,7 +75,7 @@ def attempt_login(credential)
7775
'user[password]' => credential.private,
7876
'user[remember_me]' => 0
7977
}
80-
})
78+
)
8179

8280
res = cli.send_recv(req)
8381
if res && res.code == 302

0 commit comments

Comments
 (0)