Skip to content

Commit dfb271d

Browse files
committed
Don't crash when attributes are missing
1 parent 1731565 commit dfb271d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

modules/auxiliary/admin/ldap/ad_cs_cert_template.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,13 +327,13 @@ def action_read
327327

328328
print_status('Certificate Template:')
329329
print_status(" distinguishedName: #{obj['distinguishedname'].first}")
330-
print_status(" displayName: #{obj['displayname'].first}") if obj['displayname'].first.present?
330+
print_status(" displayName: #{obj['displayname'].first}") if obj['displayname'].present?
331331
if obj['objectguid'].first.present?
332332
object_guid = Rex::Proto::MsDtyp::MsDtypGuid.read(obj['objectguid'].first)
333333
print_status(" objectGUID: #{object_guid}")
334334
end
335335

336-
mspki_flag = obj['mspki-certificate-name-flag'].first
336+
mspki_flag = obj['mspki-certificate-name-flag']&.first
337337
if mspki_flag.present?
338338
mspki_flag = [obj['mspki-certificate-name-flag'].first.to_i].pack('l').unpack1('L')
339339
print_status(" msPKI-Certificate-Name-Flag: 0x#{mspki_flag.to_s(16).rjust(8, '0')}")
@@ -358,7 +358,7 @@ def action_read
358358
end
359359
end
360360

361-
mspki_flag = obj['mspki-enrollment-flag'].first
361+
mspki_flag = obj['mspki-enrollment-flag']&.first
362362
if mspki_flag.present?
363363
mspki_flag = [obj['mspki-enrollment-flag'].first.to_i].pack('l').unpack1('L')
364364
print_status(" msPKI-Enrollment-Flag: 0x#{mspki_flag.to_s(16).rjust(8, '0')}")
@@ -387,7 +387,7 @@ def action_read
387387
end
388388
end
389389

390-
mspki_flag = obj['mspki-private-key-flag'].first
390+
mspki_flag = obj['mspki-private-key-flag']&.first
391391
if mspki_flag.present?
392392
mspki_flag = [obj['mspki-private-key-flag'].first.to_i].pack('l').unpack1('L')
393393
print_status(" msPKI-Private-Key-Flag: 0x#{mspki_flag.to_s(16).rjust(8, '0')}")
@@ -413,7 +413,7 @@ def action_read
413413
end
414414
end
415415

416-
mspki_flag = obj['mspki-ra-signature'].first
416+
mspki_flag = obj['mspki-ra-signature']&.first
417417
if mspki_flag.present?
418418
mspki_flag = [obj['mspki-ra-signature'].first.to_i].pack('l').unpack1('L')
419419
print_status(" msPKI-RA-Signature: 0x#{mspki_flag.to_s(16).rjust(8, '0')}")

0 commit comments

Comments
 (0)