|
6 | 6 | class MetasploitModule < Msf::Auxiliary |
7 | 7 |
|
8 | 8 | include Msf::Exploit::Remote::LDAP |
| 9 | + include Msf::Exploit::Remote::LDAP::ActiveDirectory |
9 | 10 | include Msf::Exploit::Remote::LDAP::Queries |
10 | 11 | include Msf::OptionalSession::LDAP |
11 | 12 | require 'json' |
@@ -66,6 +67,10 @@ def initialize(info = {}) |
66 | 67 | OptString.new('QUERY_FILTER', [false, 'Filter to send to the target LDAP server to perform the query'], conditions: %w[ACTION == RUN_SINGLE_QUERY]), |
67 | 68 | OptString.new('QUERY_ATTRIBUTES', [false, 'Comma separated list of attributes to retrieve from the server'], conditions: %w[ACTION == RUN_SINGLE_QUERY]) |
68 | 69 | ]) |
| 70 | + |
| 71 | + register_advanced_options([ |
| 72 | + OptBool.new('LDAP::QuerySacl', [true, 'Query the SACL field from security descriptors (requires privileges)', true]) |
| 73 | + ]) |
69 | 74 | end |
70 | 75 |
|
71 | 76 | def initialize_actions |
@@ -185,7 +190,13 @@ def run |
185 | 190 | fail_with(Failure::BadConfig, "Could not compile the filter #{filter_string}. Error was #{e}") |
186 | 191 | end |
187 | 192 |
|
188 | | - result_count = perform_ldap_query_streaming(ldap, filter, attributes, query_base, schema_dn) do |result, attribute_properties| |
| 193 | + controls = [] |
| 194 | + unless datastore['LDAP::QuerySacl'] |
| 195 | + # omit the control entirely if querying the SACL because that's the default behavior |
| 196 | + controls = [adds_build_ldap_sd_control(sacl: false)] |
| 197 | + end |
| 198 | + |
| 199 | + result_count = perform_ldap_query_streaming(ldap, filter, attributes, query_base, schema_dn, controls: controls) do |result, attribute_properties| |
189 | 200 | show_output(normalize_entry(result, attribute_properties), datastore['OUTPUT_FORMAT']) |
190 | 201 | end |
191 | 202 |
|
|
0 commit comments