Skip to content

Commit f951f25

Browse files
committed
Land rapid7#19381, Fix gitlab_login scanner
This fixes the gitlab_login scanner so that it uses the proper datastore options Username and Password which are the standard for login scanners. Before this fix the scanner was using HttpUsername and HttpPassword and ignoring the datastore options Username and Password
2 parents b77b640 + 38b9278 commit f951f25

File tree

2 files changed

+104
-19
lines changed

2 files changed

+104
-19
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
## Vulnerable Application
2+
3+
This module was successfully tested on:
4+
5+
* gitlab-ce (v17.2.2-ce.0) installed with Docker on Kali Linux 6.6.15
6+
7+
### Description
8+
9+
This module is a brute-force login scanner that attempts to authenticate to the GitLab with username and password combinations.
10+
11+
## Installation (latest version of gitlab-ce at the time of this writing)
12+
13+
1. `docker pull gitlab/gitlab-ce:17.2.2-ce.0`
14+
2. `sudo mkdir -p /srv/gitlab/config /srv/gitlab/logs /srv/gitlab/data`
15+
3. Run the GitLab.
16+
```
17+
docker run --detach \
18+
--hostname localhost \
19+
--publish 443:443 --publish 80:80 --publish 22:22 \
20+
--name gitlab \
21+
--restart always \
22+
--volume /srv/gitlab/config:/etc/gitlab \
23+
--volume /srv/gitlab/logs:/var/log/gitlab \
24+
--volume /srv/gitlab/data:/var/opt/gitlab \
25+
gitlab/gitlab-ce:17.2.2-ce.0
26+
```
27+
4. (Get initial password)
28+
`docker exec gitlab cat etc/gitlab/initial_root_password | grep Password:`
29+
30+
## Verification Steps
31+
32+
1. Install GitLab and start it
33+
2. Start `msfconsole`
34+
3. Do: `use auxiliary/scanner/http/gitlab_login`
35+
4. Do: `set rhosts`
36+
5. Do: set usernames and passwords via the `username` and `password` options, or pass a list via `user_file` and `pass_file` options
37+
5. Do: `run`
38+
6. You will hopefully see something similar to:
39+
40+
```
41+
[+] 192.168.56.6:80 - Login Successful: root:strongpasswordcannotguess
42+
```
43+
44+
## Options
45+
46+
## Scenarios
47+
48+
### Single set of credentials being passed
49+
```
50+
msf6 > use auxiliary/scanner/http/gitlab_login
51+
msf6 auxiliary(scanner/http/gitlab_login) > run rhosts=192.168.56.6 username=root password=strongpasswordcannotguess
52+
53+
[*] 192.168.56.6:80 - GitLab v7 login page
54+
[!] No active DB -- Credential data will not be saved!
55+
[+] 192.168.56.6:80 - Login Successful: root:strongpasswordcannotguess
56+
[*] Scanned 1 of 1 hosts (100% complete)
57+
[*] Auxiliary module execution completed
58+
```
59+
60+
### Multiple credentials being passed
61+
```
62+
msf6 > use auxiliary/scanner/http/gitlab_login
63+
msf6 auxiliary(scanner/http/gitlab_login) > run rhosts=192.168.56.6 user_file=/tmp/user.txt pass_file=/tmp/pass.txt
64+
65+
[*] 192.168.56.6:80 - GitLab v7 login page
66+
[!] No active DB -- Credential data will not be saved!
67+
[-] 192.168.56.6:80 - LOGIN FAILED: root:123456 (Incorrect)
68+
[-] 192.168.56.6:80 - LOGIN FAILED: root:123456789 (Incorrect)
69+
[-] 192.168.56.6:80 - LOGIN FAILED: root:picture1 (Incorrect)
70+
[-] 192.168.56.6:80 - LOGIN FAILED: root:password (Incorrect)
71+
[-] 192.168.56.6:80 - LOGIN FAILED: root:12345678 (Incorrect)
72+
[+] 192.168.56.6:80 - Login Successful: root:strongpasswordcannotguess
73+
[-] 192.168.56.6:80 - LOGIN FAILED: admin:123456 (Incorrect)
74+
[-] 192.168.56.6:80 - LOGIN FAILED: admin:123456789 (Incorrect)
75+
[-] 192.168.56.6:80 - LOGIN FAILED: admin:picture1 (Incorrect)
76+
[-] 192.168.56.6:80 - LOGIN FAILED: admin:password (Incorrect)
77+
[-] 192.168.56.6:80 - LOGIN FAILED: admin:12345678 (Incorrect)
78+
[-] 192.168.56.6:80 - LOGIN FAILED: admin:strongpasswordcannotguess (Incorrect)
79+
[-] 192.168.56.6:80 - LOGIN FAILED: test:123456 (Incorrect)
80+
[-] 192.168.56.6:80 - LOGIN FAILED: test:123456789 (Incorrect)
81+
[-] 192.168.56.6:80 - LOGIN FAILED: test:picture1 (Incorrect)
82+
[-] 192.168.56.6:80 - LOGIN FAILED: test:password (Incorrect)
83+
[-] 192.168.56.6:80 - LOGIN FAILED: test:12345678 (Incorrect)
84+
[-] 192.168.56.6:80 - LOGIN FAILED: test:strongpasswordcannotguess (Incorrect)
85+
[*] Scanned 1 of 1 hosts (100% complete)
86+
[*] Auxiliary module execution completed
87+
```

modules/auxiliary/scanner/http/gitlab_login.rb

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,45 @@ class MetasploitModule < Msf::Auxiliary
1414

1515
def initialize
1616
super(
17-
'Name' => 'GitLab Login Utility',
17+
'Name' => 'GitLab Login Utility',
1818
'Description' => 'This module attempts to login to a GitLab instance using a specific user/pass.',
19-
'Author' => [ 'Ben Campbell' ],
20-
'License' => MSF_LICENSE,
21-
'References' =>
22-
[
23-
['URL', 'https://labs.f-secure.com/archive/gitlab-user-enumeration/']
24-
]
19+
'Author' => [ 'Ben Campbell' ],
20+
'License' => MSF_LICENSE,
21+
'References' => [
22+
['URL', 'https://labs.f-secure.com/archive/gitlab-user-enumeration/']
23+
]
2524
)
2625

2726
register_options(
2827
[
2928
Opt::RPORT(80),
30-
OptString.new('HttpUsername', [ true, 'The username to test', 'root' ]),
31-
OptString.new('HttpPassword', [ true, 'The password to test', '5iveL!fe' ]),
3229
OptString.new('TARGETURI', [true, 'The path to GitLab', '/'])
33-
])
30+
]
31+
)
3432

3533
register_autofilter_ports([ 80, 443 ])
3634
end
3735

3836
def run_host(ip)
3937
uri = normalize_uri(target_uri.path.to_s, 'users', 'sign_in')
4038
res = send_request_cgi(
41-
'method' => 'GET',
42-
'cookie' => 'request_method=GET',
43-
'uri' => uri
39+
'method' => 'GET',
40+
'cookie' => 'request_method=GET',
41+
'uri' => uri
4442
)
4543

4644
if res && res.body && res.body.include?('user[email]')
47-
vprint_status("GitLab v5 login page")
45+
vprint_status('GitLab v5 login page')
4846
elsif res && res.body && res.body.include?('user[login]')
49-
vprint_status("GitLab v7 login page")
47+
vprint_status('GitLab v7 login page')
5048
else
5149
vprint_error('Not a valid GitLab login page')
5250
return
5351
end
5452

5553
cred_collection = build_credential_collection(
56-
username: datastore['HttpUsername'],
57-
password: datastore['HttpPassword']
54+
username: datastore['USERNAME'],
55+
password: datastore['PASSWORD']
5856
)
5957

6058
scanner = Metasploit::Framework::LoginScanner::GitLab.new(
@@ -70,8 +68,8 @@ def run_host(ip)
7068
scanner.scan! do |result|
7169
credential_data = result.to_h
7270
credential_data.merge!(
73-
module_fullname: fullname,
74-
workspace_id: myworkspace_id
71+
module_fullname: fullname,
72+
workspace_id: myworkspace_id
7573
)
7674
if result.success?
7775
credential_core = create_credential(credential_data)

0 commit comments

Comments
 (0)