Skip to content

Commit

Permalink
Merge pull request #19808 from jheysel-r7/fix_ms_icpr_esc15_patch
Browse files Browse the repository at this point in the history
Fix icpr_cert to print an error when ESC15 is patched
  • Loading branch information
smcintyre-r7 authored Jan 16, 2025
2 parents 1d748d7 + f7554d2 commit 897f8c8
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions lib/msf/core/exploit/remote/ms_icpr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# -*- coding: binary -*-

require 'windows_error'
require 'windows_error/h_result'
require 'rex/proto/x509/request'

module Msf
Expand Down Expand Up @@ -195,6 +196,19 @@ def do_request_cert(icpr, opts)

return unless response[:certificate]

policy_oids = get_cert_policy_oids(response[:certificate])
if application_policies.present? && !(application_policies - policy_oids.map(&:value)).empty?
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.')
return
end

if policy_oids
print_status('Certificate Policies:')
policy_oids.each do |oid|
print_status(" * #{oid.value}" + (oid.label.present? ? " (#{oid.label})" : ''))
end
end

unless (dns = get_cert_san_dns(response[:certificate])).empty?
print_status("Certificate DNS: #{dns.join(', ')}")
end
Expand All @@ -211,13 +225,6 @@ def do_request_cert(icpr, opts)
print_status("Certificate UPN: #{upn.join(', ')}")
end

unless (policy_oids = get_cert_policy_oids(response[:certificate])).empty?
print_status("Certificate Policies:")
policy_oids.each do |oid|
print_status(" * #{oid.value}" + (oid.label.present? ? " (#{oid.label})" : ''))
end
end

pkcs12 = OpenSSL::PKCS12.create('', '', private_key, response[:certificate])
# see: https://pki-tutorial.readthedocs.io/en/latest/mime.html#mime-types
info = "#{simple.client.default_domain}\\#{datastore['SMBUser']} Certificate"
Expand Down

0 comments on commit 897f8c8

Please sign in to comment.