@@ -12,7 +12,13 @@ class Metasploit3 < Msf::Post
1212 include Msf ::Post ::Windows ::Accounts
1313
1414 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
1622
1723 def initialize ( info = { } )
1824 super ( update_info (
@@ -35,6 +41,7 @@ def initialize(info = {})
3541 OptBool . new ( 'STORE_LOOT' , [ true , 'Store file in loot.' , false ] ) ,
3642 OptBool . new ( 'EXCLUDE_LOCKED' , [ true , 'Exclude in search locked accounts..' , false ] ) ,
3743 OptBool . new ( 'EXCLUDE_DISABLED' , [ true , 'Exclude from search disabled accounts.' , false ] ) ,
44+ OptString . new ( 'ADDITIONAL_FIELDS' , [ false , 'Additional fields to retrieve, comma separated' , nil ] ) ,
3845 OptEnum . new ( 'UAC' , [ true , 'Filter on User Account Control Setting.' , 'ANY' ,
3946 [
4047 'ANY' ,
@@ -48,10 +55,17 @@ def initialize(info = {})
4855 end
4956
5057 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+
5165 max_search = datastore [ 'MAX_SEARCH' ]
5266
5367 begin
54- q = query ( query_filter , max_search , USER_FIELDS )
68+ q = query ( query_filter , max_search , @user_fields )
5569 rescue ::RuntimeError , ::Rex ::Post ::Meterpreter ::RequestError => e
5670 # Can't bind or in a network w/ limited accounts
5771 print_error ( e . message )
@@ -93,7 +107,7 @@ def parse_results(results)
93107 'Header' => "Domain Users" ,
94108 'Indent' => 1 ,
95109 'SortIndex' => -1 ,
96- 'Columns' => USER_FIELDS
110+ 'Columns' => @user_fields
97111 )
98112
99113 results . each do |result |
@@ -107,9 +121,9 @@ def parse_results(results)
107121 end
108122 end
109123
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 ]
113127 store_username ( username , uac , lockout_time , domain , domain_ip )
114128
115129 results_table << row
0 commit comments