Skip to content

Commit 897f8c8

Browse files
authored
Merge pull request rapid7#19808 from jheysel-r7/fix_ms_icpr_esc15_patch
Fix icpr_cert to print an error when ESC15 is patched
2 parents 1d748d7 + f7554d2 commit 897f8c8

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# -*- coding: binary -*-
77

88
require 'windows_error'
9+
require 'windows_error/h_result'
910
require 'rex/proto/x509/request'
1011

1112
module Msf
@@ -195,6 +196,19 @@ def do_request_cert(icpr, opts)
195196

196197
return unless response[:certificate]
197198

199+
policy_oids = get_cert_policy_oids(response[:certificate])
200+
if application_policies.present? && !(application_policies - policy_oids.map(&:value)).empty?
201+
print_error('Certificate application policy OIDs were submitted, but some are missing in the response. This indicates the target has received the patch for ESC15 (CVE-2024-49019) or the template is not vulnerable.')
202+
return
203+
end
204+
205+
if policy_oids
206+
print_status('Certificate Policies:')
207+
policy_oids.each do |oid|
208+
print_status(" * #{oid.value}" + (oid.label.present? ? " (#{oid.label})" : ''))
209+
end
210+
end
211+
198212
unless (dns = get_cert_san_dns(response[:certificate])).empty?
199213
print_status("Certificate DNS: #{dns.join(', ')}")
200214
end
@@ -211,13 +225,6 @@ def do_request_cert(icpr, opts)
211225
print_status("Certificate UPN: #{upn.join(', ')}")
212226
end
213227

214-
unless (policy_oids = get_cert_policy_oids(response[:certificate])).empty?
215-
print_status("Certificate Policies:")
216-
policy_oids.each do |oid|
217-
print_status(" * #{oid.value}" + (oid.label.present? ? " (#{oid.label})" : ''))
218-
end
219-
end
220-
221228
pkcs12 = OpenSSL::PKCS12.create('', '', private_key, response[:certificate])
222229
# see: https://pki-tutorial.readthedocs.io/en/latest/mime.html#mime-types
223230
info = "#{simple.client.default_domain}\\#{datastore['SMBUser']} Certificate"

0 commit comments

Comments
 (0)