Skip to content

Commit 12f2828

Browse files
committed
Allow additional fields
1 parent b77aed1 commit 12f2828

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

modules/post/windows/gather/enum_ad_users.rb

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def initialize(info = {})
4141
OptBool.new('STORE_LOOT', [true, 'Store file in loot.', false]),
4242
OptBool.new('EXCLUDE_LOCKED', [true, 'Exclude in search locked accounts..', false]),
4343
OptBool.new('EXCLUDE_DISABLED', [true, 'Exclude from search disabled accounts.', false]),
44+
OptString.new('ADDITIONAL_FIELDS', [false, 'Additional fields to retrieve, comma sperated', nil]),
4445
OptEnum.new('UAC', [true, 'Filter on User Account Control Setting.', 'ANY',
4546
[
4647
'ANY',
@@ -54,10 +55,17 @@ def initialize(info = {})
5455
end
5556

5657
def run
58+
@user_fields = USER_FIELDS.dup
59+
60+
if datastore['ADDITIONAL_FIELDS']
61+
additional_fields = datastore['ADDITIONAL_FIELDS'].gsub(/\s+/,"").split(',')
62+
@user_fields.push(*additional_fields)
63+
end
64+
5765
max_search = datastore['MAX_SEARCH']
5866

5967
begin
60-
q = query(query_filter, max_search, USER_FIELDS)
68+
q = query(query_filter, max_search, @user_fields)
6169
rescue ::RuntimeError, ::Rex::Post::Meterpreter::RequestError => e
6270
# Can't bind or in a network w/ limited accounts
6371
print_error(e.message)
@@ -99,7 +107,7 @@ def parse_results(results)
99107
'Header' => "Domain Users",
100108
'Indent' => 1,
101109
'SortIndex' => -1,
102-
'Columns' => USER_FIELDS
110+
'Columns' => @user_fields
103111
)
104112

105113
results.each do |result|
@@ -113,9 +121,9 @@ def parse_results(results)
113121
end
114122
end
115123

116-
username = result[USER_FIELDS.index('sAMAccountName')][:value]
117-
uac = result[USER_FIELDS.index('userAccountControl')][:value]
118-
lockout_time = result[USER_FIELDS.index('lockoutTime')][:value]
124+
username = result[@user_fields.index('sAMAccountName')][:value]
125+
uac = result[@user_fields.index('userAccountControl')][:value]
126+
lockout_time = result[@user_fields.index('lockoutTime')][:value]
119127
store_username(username, uac, lockout_time, domain, domain_ip)
120128

121129
results_table << row

0 commit comments

Comments
 (0)