@@ -12,7 +12,13 @@ class Metasploit3 < Msf::Post
12
12
include Msf ::Post ::Windows ::Accounts
13
13
14
14
UAC_DISABLED = 0x02
15
- USER_FIELDS = [ 'sAMAccountName' , 'userAccountControl' , 'lockoutTime' , 'mail' , 'primarygroupid' , 'description' ] . freeze
15
+ USER_FIELDS = [ 'sAMAccountName' ,
16
+ 'userPrincipalName' ,
17
+ 'userAccountControl' ,
18
+ 'lockoutTime' ,
19
+ 'mail' ,
20
+ 'primarygroupid' ,
21
+ 'description' ] . freeze
16
22
17
23
def initialize ( info = { } )
18
24
super ( update_info (
@@ -35,6 +41,7 @@ def initialize(info = {})
35
41
OptBool . new ( 'STORE_LOOT' , [ true , 'Store file in loot.' , false ] ) ,
36
42
OptBool . new ( 'EXCLUDE_LOCKED' , [ true , 'Exclude in search locked accounts..' , false ] ) ,
37
43
OptBool . new ( 'EXCLUDE_DISABLED' , [ true , 'Exclude from search disabled accounts.' , false ] ) ,
44
+ OptString . new ( 'ADDITIONAL_FIELDS' , [ false , 'Additional fields to retrieve, comma separated' , nil ] ) ,
38
45
OptEnum . new ( 'UAC' , [ true , 'Filter on User Account Control Setting.' , 'ANY' ,
39
46
[
40
47
'ANY' ,
@@ -48,10 +55,17 @@ def initialize(info = {})
48
55
end
49
56
50
57
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
+
51
65
max_search = datastore [ 'MAX_SEARCH' ]
52
66
53
67
begin
54
- q = query ( query_filter , max_search , USER_FIELDS )
68
+ q = query ( query_filter , max_search , @user_fields )
55
69
rescue ::RuntimeError , ::Rex ::Post ::Meterpreter ::RequestError => e
56
70
# Can't bind or in a network w/ limited accounts
57
71
print_error ( e . message )
@@ -93,7 +107,7 @@ def parse_results(results)
93
107
'Header' => "Domain Users" ,
94
108
'Indent' => 1 ,
95
109
'SortIndex' => -1 ,
96
- 'Columns' => USER_FIELDS
110
+ 'Columns' => @user_fields
97
111
)
98
112
99
113
results . each do |result |
@@ -107,9 +121,9 @@ def parse_results(results)
107
121
end
108
122
end
109
123
110
- username = result . first [ :value ]
111
- uac = result [ 1 ] [ :value ]
112
- lockout_time = result [ 2 ] [ :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 ]
113
127
store_username ( username , uac , lockout_time , domain , domain_ip )
114
128
115
129
results_table << row
0 commit comments