Skip to content

Commit 0fcac4c

Browse files
committed
working on restoring empty upn
1 parent 17d1392 commit 0fcac4c

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

docs/metasploit-framework.wiki/ad-certificates/Attacking-AD-CS-ESC-Vulnerabilities.md

-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Setting Up An AD CS Target
32
Follow the instructions [[here|./ad-certificates/overview.md]] to set up an AD CS server
43
for testing purposes.
@@ -1104,12 +1103,6 @@ So `NEW_VALUE` as well as `ALT_DNS` will be set to `DC2.kerberos.issue`.
11041103

11051104

11061105

1107-
1108-
1109-
1110-
1111-
1112-
11131106
# Exploiting ESC13
11141107
To exploit ESC13, we need to target a certificate that has an issuance policy linked to a universal group in Active
11151108
Directory. Unlike some of the other ESC techniques, successfully exploiting ESC13 isn't necessarily guaranteed to yield

lib/msf/core/exploit/remote/ms_icpr.rb

+9-3
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def request_certificate(opts = {})
104104
if datastore['UPDATE_ESC9_ESC10_OBJECT']
105105
# Get the original value before updating
106106
opts[:original_value] = get_original_esc9_esc10_object_value
107+
print_status("Original #{datastore['UPDATE_ESC9_ESC10_OBJECT']} of #{datastore['TARGET_USERNAME']}: #{opts[:original_value]}")
107108
# Update the UPN or dnsHostname of the target user before requesting the cert in order to exploit ESC9 or ESC10
108109
print_status("Updating #{datastore['UPDATE_ESC9_ESC10_OBJECT']} of #{datastore['TARGET_USERNAME']} to #{datastore['NEW_VALUE']}")
109110
update_esc9_esc10_object(datastore['NEW_VALUE'])
@@ -523,8 +524,8 @@ def get_original_esc9_esc10_object_value
523524
ldap_query_module.datastore['ACTION'] = "RUN_SINGLE_QUERY"
524525

525526

526-
output = Rex::Ui::Text::Output::Buffer.new # ✅ Valid class
527-
output.extend(Rex::Ui::Text::Output::Buffer::Stdout) # Add `write` method
527+
output = Rex::Ui::Text::Output::Buffer.new
528+
output.extend(Rex::Ui::Text::Output::Buffer::Stdout)
528529

529530
original_output = self.user_output
530531
self.user_output = output
@@ -544,6 +545,10 @@ def get_original_esc9_esc10_object_value
544545
original_value = Regexp.last_match(1)
545546
print_good("Original value retrieved: #{original_value}")
546547
return original_value
548+
end
549+
if output.buf =~ /Query returned 1 result/
550+
# The Administrator account does not have it's UPN set by default
551+
return ''
547552
else
548553
fail_with(Msf::Module::Failure::NotFound, "Failed to retrieve the original value of #{datastore['UPDATE_ESC9_ESC10_OBJECT']}")
549554
end
@@ -561,6 +566,7 @@ def update_esc9_esc10_object(new_value)
561566
return
562567
end
563568

569+
564570
# Default to using the SMB credentials if LDAP credentials are not provided
565571
ldap_update_module = framework.modules.create(mod_refname)
566572
ldap_update_module.datastore['RHOST'] = datastore['RHOST']
@@ -572,13 +578,13 @@ def update_esc9_esc10_object(new_value)
572578
ldap_update_module.datastore['ATTRIBUTE'] = datastore['UPDATE_ESC9_ESC10_OBJECT']
573579
ldap_update_module.datastore['NEW_VALUE'] = new_value
574580

581+
575582
print_status("Running #{mod_refname}")
576583
ldap_update_module.run_simple(
577584
'LocalInput' => self.user_input,
578585
'LocalOutput' => self.user_output,
579586
'RunAsJob' => false
580587
)
581-
582588
end
583589

584590

modules/auxiliary/gather/ldap_update_object.rb

+11-3
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,20 @@ def update_object_attribute
6666
target_dn = result.first.dn
6767
print_good("Found target object DN: #{target_dn}")
6868

69-
ops = [
70-
[:replace, attribute.to_sym, new_value]
71-
]
69+
70+
if new_value.present?
71+
ops = [
72+
[:replace, attribute.to_sym, new_value]
73+
]
74+
else
75+
#TODO replacing with empty string / nil causes errors :delete is no what we want. Needed to reset empty UPN
76+
end
7277

7378
print_status("Attempting to update #{attribute} for #{target_dn} to #{new_value}...")
7479

80+
require 'pry-byebug'
81+
binding.pry
82+
7583
if ldap.modify(dn: target_dn, operations: ops)
7684
print_good("Successfully updated #{target_dn}'s #{attribute} to #{new_value}")
7785
else

0 commit comments

Comments
 (0)