Skip to content

Commit 170fbcb

Browse files
committed
Add two more report filters
1 parent 1c41c73 commit 170fbcb

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

documentation/modules/auxiliary/gather/ldap_esc_vulnerable_cert_finder.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ if ($editFlags -band $EDITF_ATTRIBUTESUBJECTALTNAME2) {
244244
What templates to report (applies filtering to results).
245245

246246
* **all** - Report all certificate templates.
247+
* **published** - Report certificate templates that are published by at least one CA server.
248+
* **enrollable** - Same as above, but omits templates that the user does not have permissions to enroll in.
247249
* **vulnerable** - Report certificate templates where at least one misconfiguration is appears to be present.
248250
* **vulnerable-and-published** - Same as above, but omits templates that are not published by at least one CA server.
249251
* **vulnerable-and-enrollable** - Same as above, but omits templates that the user does not have permissions to enroll in.

modules/auxiliary/gather/ldap_esc_vulnerable_cert_finder.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def initialize(info = {})
9595

9696
register_options([
9797
OptString.new('BASE_DN', [false, 'LDAP base DN if you already have it']),
98-
OptEnum.new('REPORT', [true, 'What templates to report (applies filtering to results)', 'vulnerable-and-published', %w[all vulnerable vulnerable-and-published vulnerable-and-enrollable]]),
98+
OptEnum.new('REPORT', [true, 'What templates to report (applies filtering to results)', 'vulnerable-and-published', %w[all published enrollable vulnerable vulnerable-and-published vulnerable-and-enrollable]]),
9999
OptBool.new('RUN_REGISTRY_CHECKS', [true, 'Authenticate to WinRM to query the registry values to enhance reporting for ESC9, ESC10 and ESC16. Must be a privileged user in order to query successfully', false]),
100100
])
101101
end
@@ -727,18 +727,26 @@ def reporting_split_techniques(template)
727727

728728
if datastore['REPORT'] == 'vulnerable-and-enrollable'
729729
vulnerable.keep_if do |technique|
730-
enroll_by_proxy.include?(technique) || (template[:permissions].include?('FULL CONTROL') || template[:permissions].include?('ENROLL')) && template[:ca_servers].values.any? { _1[:permissions].include?('REQUEST CERTIFICATES') }
730+
enroll_by_proxy.include?(technique) || can_enroll?(template)
731731
end
732732
end
733733

734734
[vulnerable, potentially_vulnerable]
735735
end
736736

737+
def can_enroll?(template)
738+
(template[:permissions].include?('FULL CONTROL') || template[:permissions].include?('ENROLL')) && template[:ca_servers].values.any? { _1[:permissions].include?('REQUEST CERTIFICATES') }
739+
end
740+
737741
def print_vulnerable_cert_info
738742
filtered_certificate_details = @certificate_details.sort.to_h.select do |_key, template|
739743
case datastore['REPORT']
740744
when 'all'
741745
true
746+
when 'published'
747+
template[:ca_servers].present?
748+
when 'enrollable'
749+
can_enroll?(template)
742750
when 'vulnerable'
743751
template[:techniques].present?
744752
when 'vulnerable-and-published'

0 commit comments

Comments
 (0)