{"id":59320,"date":"2024-09-01T01:50:25","date_gmt":"2024-08-31T22:50:25","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/180927\/vmware_enum_users.rb.txt"},"modified":"2024-09-01T01:50:25","modified_gmt":"2024-08-31T22:50:25","slug":"vmware-enumerate-user-accounts","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/vmware-enumerate-user-accounts\/","title":{"rendered":"VMWare Enumerate User Accounts"},"content":{"rendered":"<p>##<br \/># This module requires Metasploit: https:\/\/metasploit.com\/download<br \/># Current source: https:\/\/github.com\/rapid7\/metasploit-framework<br \/>##<\/p>\n<p>class MetasploitModule &lt; Msf::Auxiliary<br \/>include Msf::Exploit::Remote::VIMSoap<br \/>include Msf::Exploit::Remote::HttpClient<br \/>include Msf::Auxiliary::Report<br \/>include Msf::Auxiliary::Scanner<\/p>\n<p>def initialize<br \/>super(<br \/>&#8216;Name&#8217; =&gt; &#8216;VMWare Enumerate User Accounts&#8217;,<br \/>&#8216;Description&#8217; =&gt; %Q{<br \/>This module will log into the Web API of VMWare and try to enumerate<br \/>all the user accounts. If the VMware instance is connected to one or<br \/>more domains, it will try to enumerate domain users as well.<br \/>},<br \/>&#8216;Author&#8217; =&gt; [&#8216;theLightCosine&#8217;],<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>&#8216;DefaultOptions&#8217; =&gt; { &#8216;SSL&#8217; =&gt; true }<br \/>)<\/p>\n<p>register_options(<br \/>[<br \/>Opt::RPORT(443),<br \/>OptString.new(&#8216;USERNAME&#8217;, [ true, &#8220;The username to Authenticate with.&#8221;, &#8216;root&#8217; ]),<br \/>OptString.new(&#8216;PASSWORD&#8217;, [ true, &#8220;The password to Authenticate with.&#8221;, &#8216;password&#8217; ])<br \/>])<br \/>end<\/p>\n<p>def run_host(ip)<br \/>if vim_do_login(datastore[&#8216;USERNAME&#8217;], datastore[&#8216;PASSWORD&#8217;]) == :success<br \/># Get local Users and Groups<br \/>user_list = vim_get_user_list(nil)<br \/>tmp_users = Rex::Text::Table.new(<br \/>&#8216;Header&#8217; =&gt; &#8220;Users for server #{ip}&#8221;,<br \/>&#8216;Indent&#8217; =&gt; 1,<br \/>&#8216;Columns&#8217; =&gt; [&#8216;Name&#8217;, &#8216;Description&#8217;])<br \/>tmp_groups = Rex::Text::Table.new(<br \/>&#8216;Header&#8217; =&gt; &#8220;Groups for server #{ip}&#8221;,<br \/>&#8216;Indent&#8217; =&gt; 1,<br \/>&#8216;Columns&#8217; =&gt; [&#8216;Name&#8217;, &#8216;Description&#8217;])<br \/>unless user_list.nil?<br \/>case user_list<br \/>when :noresponse<br \/>print_error &#8220;Received no response from #{ip}&#8221;<br \/>when :expired<br \/>print_error &#8220;The login session appears to have expired on #{ip}&#8221;<br \/>when :error<br \/>print_error &#8220;An error occurred while trying to enumerate the users for #{domain} on #{ip}&#8221;<br \/>else<br \/>user_list.each do |obj|<br \/>if obj[&#8216;group&#8217;] == &#8216;true&#8217;<br \/>tmp_groups &lt;&lt; [obj[&#8216;principal&#8217;], obj[&#8216;fullName&#8217;]]else<br \/>tmp_users &lt;&lt; [obj[&#8216;principal&#8217;], obj[&#8216;fullName&#8217;]]end<br \/>end<br \/>print_good tmp_groups.to_s<br \/>store_loot(&#8216;host.vmware.groups&#8217;, &#8220;text\/plain&#8221;, datastore[&#8216;RHOST&#8217;], tmp_groups.to_csv , &#8220;#{datastore[&#8216;RHOST&#8217;]}_esx_groups.txt&#8221;, &#8220;VMWare ESX User Groups&#8221;)<br \/>print_good tmp_users.to_s<br \/>store_loot(&#8216;host.vmware.users&#8217;, &#8220;text\/plain&#8221;, datastore[&#8216;RHOST&#8217;], tmp_users.to_csv , &#8220;#{datastore[&#8216;RHOST&#8217;]}_esx_users.txt&#8221;, &#8220;VMWare ESX Users&#8221;)<br \/>end<br \/>end<\/p>\n<p># Enumerate Domains the Server is connected to<br \/>esx_domains = vim_get_domains<br \/>case esx_domains<br \/>when :noresponse<br \/>print_error &#8220;Received no response from #{ip}&#8221;<br \/>when :expired<br \/>print_error &#8220;The login session appears to have expired on #{ip}&#8221;<br \/>when :error<br \/>print_error &#8220;An error occurred while trying to enumerate the domains on #{ip}&#8221;<br \/>else<br \/># Enumerate Domain Users and Groups<br \/>esx_domains.each do |domain|<br \/>tmp_dusers = Rex::Text::Table.new(<br \/>&#8216;Header&#8217; =&gt; &#8220;Users for domain #{domain}&#8221;,<br \/>&#8216;Indent&#8217; =&gt; 1,<br \/>&#8216;Columns&#8217; =&gt; [&#8216;Name&#8217;, &#8216;Description&#8217;])<\/p>\n<p>tmp_dgroups = Rex::Text::Table.new(<br \/>&#8216;Header&#8217; =&gt; &#8220;Groups for domain #{domain}&#8221;,<br \/>&#8216;Indent&#8217; =&gt; 1,<br \/>&#8216;Columns&#8217; =&gt; [&#8216;Name&#8217;, &#8216;Description&#8217;])<\/p>\n<p>user_list = vim_get_user_list(domain)<br \/>case user_list<br \/>when nil<br \/>next<br \/>when :noresponse<br \/>print_error &#8220;Received no response from #{ip}&#8221;<br \/>when :expired<br \/>print_error &#8220;The login session appears to have expired on #{ip}&#8221;<br \/>when :error<br \/>print_error &#8220;An error occurred while trying to enumerate the users for #{domain} on #{ip}&#8221;<br \/>else<br \/>user_list.each do |obj|<br \/>if obj[&#8216;group&#8217;] == &#8216;true&#8217;<br \/>tmp_dgroups &lt;&lt; [obj[&#8216;principal&#8217;], obj[&#8216;fullName&#8217;]]else<br \/>tmp_dusers &lt;&lt; [obj[&#8216;principal&#8217;], obj[&#8216;fullName&#8217;]]end<br \/>end<br \/>print_good tmp_dgroups.to_s<\/p>\n<p>f = store_loot(&#8216;domain.groups&#8217;, &#8220;text\/plain&#8221;, datastore[&#8216;RHOST&#8217;], tmp_dgroups.to_csv , &#8220;#{domain}_esx_groups.txt&#8221;, &#8220;VMWare ESX #{domain} Domain User Groups&#8221;)<br \/>vprint_status(&#8220;VMWare domain user groups stored in: #{f}&#8221;)<br \/>print_good tmp_dusers.to_s<br \/>f = store_loot(&#8216;domain.users&#8217;, &#8220;text\/plain&#8221;, datastore[&#8216;RHOST&#8217;], tmp_dgroups.to_csv , &#8220;#{domain}_esx_users.txt&#8221;, &#8220;VMWare ESX #{domain} Domain Users&#8221;)<br \/>vprint_status(&#8220;VMWare users stored in: #{f}&#8221;)<br \/>end<br \/>end<br \/>end<br \/>else<br \/>print_error &#8220;Login failure on #{ip}&#8221;<br \/>return<br \/>end<br \/>end<br \/>end<\/p>\n","protected":false},"excerpt":{"rendered":"<p>### This module requires Metasploit: https:\/\/metasploit.com\/download# Current source: https:\/\/github.com\/rapid7\/metasploit-framework## class MetasploitModule &lt; Msf::Auxiliaryinclude Msf::Exploit::Remote::VIMSoapinclude Msf::Exploit::Remote::HttpClientinclude Msf::Auxiliary::Reportinclude Msf::Auxiliary::Scanner def initializesuper(&#8216;Name&#8217; =&gt; &#8216;VMWare Enumerate User Accounts&#8217;,&#8216;Description&#8217; =&gt; %Q{This module will log into the Web API of VMWare and try to enumerateall the user accounts. If the VMware instance is connected to one ormore domains, it will try &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-59320","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59320","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=59320"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59320\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59320"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}