Skip to content

Commit d4378d6

Browse files
committed
change output format to old style
1 parent a93e008 commit d4378d6

File tree

1 file changed

+34
-27
lines changed

1 file changed

+34
-27
lines changed

modules/auxiliary/scanner/smb/smb_enumusers_domain.rb

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -91,28 +91,6 @@ def run_service(port, direct)
9191
disconnect_wkssvc
9292
end
9393

94-
def format_results(results)
95-
users_table = Rex::Text::Table.new(
96-
'Indent' => 4,
97-
'Header' => "Logged-on Users",
98-
'Columns' =>
99-
[
100-
'Name',
101-
'Domain',
102-
'Other Domains',
103-
'Logon Server'
104-
],
105-
'SortIndex' => 0,
106-
)
107-
108-
results.compact.each do |result_set|
109-
result_set.each { |result| users_table << [result.wkui1_username, result.wkui1_logon_domain, result.wkui1_oth_domains, result.wkui1_logon_server] }
110-
end
111-
112-
users_table
113-
114-
end
115-
11694
def run_host(_ip)
11795
if session
11896
self.simple = session.simple_client
@@ -122,11 +100,40 @@ def run_host(_ip)
122100
end
123101

124102
unless results.to_s.empty?
125-
results_table = format_results(results)
126-
results_table.rows = results_table.rows.uniq # Remove potentially duplicate entries from port 139 & 445
127-
128-
print_line
129-
print_line results_table.to_s
103+
104+
accounts = [ Hash.new() ]
105+
results.compact.each do |result_set|
106+
result_set.each { |result| accounts << {
107+
:account_name => result.wkui1_username.encode('UTF-8'),
108+
:logon_domain => result.wkui1_logon_domain.encode('UTF-8'),
109+
:other_domains => result.wkui1_oth_domains.encode('UTF-8'),
110+
:logon_server => result.wkui1_logon_server.encode('UTF-8')} }
111+
end
112+
accounts.shift
113+
114+
if datastore['VERBOSE']
115+
accounts.each do |x|
116+
print_status x[:logon_domain] + "\\" + x[:account_name] +
117+
"\t(logon_server: #{x[:logon_server]}, other_domains: #{x[:other_domains]})"
118+
end
119+
else
120+
print_status "#{accounts.collect{|x| x[:logon_domain] + "\\" + x[:account_name]}.join(", ")}"
121+
end
122+
123+
found_accounts = []
124+
accounts.each do |x|
125+
comp_user = x[:logon_domain] + "\\" + x[:account_name]
126+
found_accounts.push(comp_user.scan(/[[:print:]]/).join) unless found_accounts.include?(comp_user.scan(/[[:print:]]/).join)
127+
end
128+
129+
found_accounts.each do |comp_user|
130+
if comp_user.to_s =~ /\$$/
131+
next
132+
end
133+
134+
print_good("Found user: #{comp_user}")
135+
end
136+
130137
end
131138

132139
end

0 commit comments

Comments
 (0)