@@ -42,11 +42,15 @@ def initialize(info = {})
42
42
info ,
43
43
'Name' => 'AD CS Certificate Template Management' ,
44
44
'Description' => %q{
45
- This module can read, write , update, and delete AD CS certificate templates from a Active Directory Domain
45
+ This module can create, read , update, and delete AD CS certificate templates from a Active Directory Domain
46
46
Controller.
47
47
48
48
The READ, UPDATE, and DELETE actions will write a copy of the certificate template to disk that can be
49
- restored using the CREATE or UPDATE actions.
49
+ restored using the CREATE or UPDATE actions. The CREATE and UPDATE actions require a certificate template data
50
+ file to be specified to define the attributes. Template data files are provided to create a template that is
51
+ vulnerable to ESC1, ESC2, and ESC3.
52
+
53
+ This module is capable of exploiting ESC4.
50
54
} ,
51
55
'Author' => [
52
56
'Will Schroeder' , # original idea/research
@@ -69,7 +73,8 @@ def initialize(info = {})
69
73
'Notes' => {
70
74
'Stability' => [ ] ,
71
75
'SideEffects' => [ CONFIG_CHANGES ] ,
72
- 'Reliability' => [ ]
76
+ 'Reliability' => [ ] ,
77
+ 'AKA' => [ 'Certifry' , 'Certipy' ]
73
78
}
74
79
)
75
80
)
@@ -327,16 +332,16 @@ def action_read
327
332
328
333
print_status ( 'Certificate Template:' )
329
334
print_status ( " distinguishedName: #{ obj [ 'distinguishedname' ] . first } " )
330
- print_status ( " displayName: #{ obj [ 'displayname' ] . first } " ) if obj [ 'displayname' ] . first . present?
335
+ print_status ( " displayName: #{ obj [ 'displayname' ] . first } " ) if obj [ 'displayname' ] . present?
331
336
if obj [ 'objectguid' ] . first . present?
332
337
object_guid = Rex ::Proto ::MsDtyp ::MsDtypGuid . read ( obj [ 'objectguid' ] . first )
333
338
print_status ( " objectGUID: #{ object_guid } " )
334
339
end
335
340
336
- mspki_flag = obj [ 'mspki-certificate-name-flag' ] . first
337
- if mspki_flag . present?
338
- mspki_flag = [ obj [ 'mspki-certificate-name-flag' ] . first . to_i ] . pack ( 'l' ) . unpack1 ( 'L' )
339
- print_status ( " msPKI-Certificate-Name-Flag: 0x#{ mspki_flag . to_s ( 16 ) . rjust ( 8 , '0' ) } " )
341
+ pki_flag = obj [ 'mspki-certificate-name-flag' ] & .first
342
+ if pki_flag . present?
343
+ pki_flag = [ obj [ 'mspki-certificate-name-flag' ] . first . to_i ] . pack ( 'l' ) . unpack1 ( 'L' )
344
+ print_status ( " msPKI-Certificate-Name-Flag: 0x#{ pki_flag . to_s ( 16 ) . rjust ( 8 , '0' ) } " )
340
345
%w[
341
346
CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT
342
347
CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT_ALT_NAME
@@ -352,16 +357,16 @@ def action_read
352
357
CT_FLAG_SUBJECT_REQUIRE_DIRECTORY_PATH
353
358
CT_FLAG_OLD_CERT_SUPPLIES_SUBJECT_AND_ALT_NAME
354
359
] . each do |flag_name |
355
- if mspki_flag & Rex ::Proto ::MsCrtd . const_get ( flag_name ) != 0
360
+ if pki_flag & Rex ::Proto ::MsCrtd . const_get ( flag_name ) != 0
356
361
print_status ( " * #{ flag_name } " )
357
362
end
358
363
end
359
364
end
360
365
361
- mspki_flag = obj [ 'mspki-enrollment-flag' ] . first
362
- if mspki_flag . present?
363
- mspki_flag = [ obj [ 'mspki-enrollment-flag' ] . first . to_i ] . pack ( 'l' ) . unpack1 ( 'L' )
364
- print_status ( " msPKI-Enrollment-Flag: 0x#{ mspki_flag . to_s ( 16 ) . rjust ( 8 , '0' ) } " )
366
+ pki_flag = obj [ 'mspki-enrollment-flag' ] & .first
367
+ if pki_flag . present?
368
+ pki_flag = [ obj [ 'mspki-enrollment-flag' ] . first . to_i ] . pack ( 'l' ) . unpack1 ( 'L' )
369
+ print_status ( " msPKI-Enrollment-Flag: 0x#{ pki_flag . to_s ( 16 ) . rjust ( 8 , '0' ) } " )
365
370
%w[
366
371
CT_FLAG_INCLUDE_SYMMETRIC_ALGORITHMS
367
372
CT_FLAG_PEND_ALL_REQUESTS
@@ -381,16 +386,16 @@ def action_read
381
386
CT_FLAG_ISSUANCE_POLICIES_FROM_REQUEST
382
387
CT_FLAG_SKIP_AUTO_RENEWAL
383
388
] . each do |flag_name |
384
- if mspki_flag & Rex ::Proto ::MsCrtd . const_get ( flag_name ) != 0
389
+ if pki_flag & Rex ::Proto ::MsCrtd . const_get ( flag_name ) != 0
385
390
print_status ( " * #{ flag_name } " )
386
391
end
387
392
end
388
393
end
389
394
390
- mspki_flag = obj [ 'mspki-private-key-flag' ] . first
391
- if mspki_flag . present?
392
- mspki_flag = [ obj [ 'mspki-private-key-flag' ] . first . to_i ] . pack ( 'l' ) . unpack1 ( 'L' )
393
- print_status ( " msPKI-Private-Key-Flag: 0x#{ mspki_flag . to_s ( 16 ) . rjust ( 8 , '0' ) } " )
395
+ pki_flag = obj [ 'mspki-private-key-flag' ] & .first
396
+ if pki_flag . present?
397
+ pki_flag = [ obj [ 'mspki-private-key-flag' ] . first . to_i ] . pack ( 'l' ) . unpack1 ( 'L' )
398
+ print_status ( " msPKI-Private-Key-Flag: 0x#{ pki_flag . to_s ( 16 ) . rjust ( 8 , '0' ) } " )
394
399
%w[
395
400
CT_FLAG_REQUIRE_PRIVATE_KEY_ARCHIVAL
396
401
CT_FLAG_EXPORTABLE_KEY
@@ -407,27 +412,16 @@ def action_read
407
412
CT_FLAG_EK_VALIDATE_KEY
408
413
CT_FLAG_HELLO_LOGON_KEY
409
414
] . each do |flag_name |
410
- if mspki_flag & Rex ::Proto ::MsCrtd . const_get ( flag_name ) != 0
415
+ if pki_flag & Rex ::Proto ::MsCrtd . const_get ( flag_name ) != 0
411
416
print_status ( " * #{ flag_name } " )
412
417
end
413
418
end
414
419
end
415
420
416
- mspki_flag = obj [ 'mspki-ra-signature' ] . first
417
- if mspki_flag . present?
418
- mspki_flag = [ obj [ 'mspki-ra-signature' ] . first . to_i ] . pack ( 'l' ) . unpack1 ( 'L' )
419
- print_status ( " msPKI-RA-Signature: 0x#{ mspki_flag . to_s ( 16 ) . rjust ( 8 , '0' ) } " )
420
- end
421
-
422
- if obj [ 'pkiextendedkeyusage' ] . present?
423
- print_status ( ' pKIExtendedKeyUsage:' )
424
- obj [ 'pkiextendedkeyusage' ] . each do |value |
425
- if ( oid = Rex ::Proto ::CryptoAsn1 ::OIDs . value ( value ) ) && oid . label . present?
426
- print_status ( " * #{ value } (#{ oid . label } )" )
427
- else
428
- print_status ( " * #{ value } " )
429
- end
430
- end
421
+ pki_flag = obj [ 'mspki-ra-signature' ] &.first
422
+ if pki_flag . present?
423
+ pki_flag = [ pki_flag . to_i ] . pack ( 'l' ) . unpack1 ( 'L' )
424
+ print_status ( " msPKI-RA-Signature: 0x#{ pki_flag . to_s ( 16 ) . rjust ( 8 , '0' ) } " )
431
425
end
432
426
433
427
if obj [ 'mspki-certificate-policy' ] . present?
@@ -448,6 +442,31 @@ def action_read
448
442
end
449
443
end
450
444
end
445
+
446
+ if obj [ 'mspki-template-schema-version' ] . present?
447
+ print_status ( " msPKI-Template-Schema-Version: #{ obj [ 'mspki-template-schema-version' ] . first . to_i } " )
448
+ end
449
+
450
+ pki_flag = obj [ 'pkikeyusage' ] &.first
451
+ if pki_flag . present?
452
+ pki_flag = [ pki_flag . to_i ] . pack ( 'l' ) . unpack1 ( 'L' )
453
+ print_status ( " pKIKeyUsage: 0x#{ pki_flag . to_s ( 16 ) . rjust ( 8 , '0' ) } " )
454
+ end
455
+
456
+ if obj [ 'pkiextendedkeyusage' ] . present?
457
+ print_status ( ' pKIExtendedKeyUsage:' )
458
+ obj [ 'pkiextendedkeyusage' ] . each do |value |
459
+ if ( oid = Rex ::Proto ::CryptoAsn1 ::OIDs . value ( value ) ) && oid . label . present?
460
+ print_status ( " * #{ value } (#{ oid . label } )" )
461
+ else
462
+ print_status ( " * #{ value } " )
463
+ end
464
+ end
465
+ end
466
+
467
+ if obj [ 'pkimaxissuingdepth' ] . present?
468
+ print_status ( " pKIMaxIssuingDepth: #{ obj [ 'pkimaxissuingdepth' ] . first . to_i } " )
469
+ end
451
470
end
452
471
453
472
def action_update
0 commit comments