2010-12-25 06:08:34 +00:00
|
|
|
##
|
2014-10-30 06:54:32 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2010-12-25 06:08:34 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Exploit::Remote::SNMPClient
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
include Msf::Auxiliary::Scanner
|
2014-10-30 06:54:32 +00:00
|
|
|
include SNMP
|
2010-12-25 06:08:34 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'SNMP Windows Username Enumeration',
|
2014-10-30 06:54:32 +00:00
|
|
|
'Description' => '
|
|
|
|
This module will use LanManager/psProcessUsername OID values to
|
|
|
|
enumerate local user accounts on a Windows/Solaris system via SNMP
|
|
|
|
',
|
2013-08-30 21:28:54 +00:00
|
|
|
'Author' => ['tebo[at]attackresearch.com'],
|
|
|
|
'License' => MSF_LICENSE
|
|
|
|
)
|
|
|
|
end
|
2010-12-25 06:08:34 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def run_host(ip)
|
2014-10-30 06:54:32 +00:00
|
|
|
peer = "#{ip}:#{rport}"
|
2013-08-30 21:28:54 +00:00
|
|
|
begin
|
|
|
|
snmp = connect_snmp
|
2010-12-25 06:08:34 +00:00
|
|
|
|
2014-07-17 19:29:26 +00:00
|
|
|
sys_desc = snmp.get_value('sysDescr.0')
|
2014-10-30 06:54:32 +00:00
|
|
|
if sys_desc.blank? || sys_desc.to_s == 'Null'
|
|
|
|
vprint_error("#{peer} No sysDescr received")
|
|
|
|
return
|
2014-07-17 19:29:26 +00:00
|
|
|
end
|
2014-10-30 06:54:32 +00:00
|
|
|
sys_desc = sys_desc.split(/[\r\n]/).join(' ')
|
|
|
|
|
|
|
|
sys_desc_map = {
|
|
|
|
/Windows/ => '1.3.6.1.4.1.77.1.2.25',
|
|
|
|
/Sun/ => '1.3.6.1.4.1.42.3.12.1.8'
|
|
|
|
}
|
|
|
|
|
|
|
|
matching_oids = sys_desc_map.select { |re, _| sys_desc =~ re }.values
|
|
|
|
if matching_oids.empty?
|
|
|
|
vprint_warning("#{peer} Skipping unsupported sysDescr: '#{sys_desc}'")
|
|
|
|
return
|
2014-07-13 09:27:45 +00:00
|
|
|
end
|
2014-10-30 06:54:32 +00:00
|
|
|
users = []
|
2010-12-25 06:08:34 +00:00
|
|
|
|
2014-10-30 06:54:32 +00:00
|
|
|
matching_oids.each do |oid|
|
|
|
|
snmp.walk(oid) do |row|
|
|
|
|
row.each { |val| users << val.value.to_s }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
unless users.empty?
|
|
|
|
users.sort!
|
|
|
|
users.uniq!
|
|
|
|
print_good("#{peer} Found #{users.size} users: #{users.join(', ')}")
|
|
|
|
end
|
2010-12-25 06:08:34 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
report_note(
|
2014-10-30 06:54:32 +00:00
|
|
|
host: rhost,
|
|
|
|
port: rport,
|
|
|
|
proto: 'udp',
|
|
|
|
sname: 'snmp',
|
|
|
|
update: :unique_data,
|
|
|
|
type: 'snmp.users',
|
|
|
|
data: users
|
2013-08-30 21:28:54 +00:00
|
|
|
)
|
2014-10-30 06:54:32 +00:00
|
|
|
rescue ::SNMP::RequestTimeout, ::SNMP::UnsupportedVersion
|
|
|
|
# too noisy for a scanner
|
|
|
|
ensure
|
|
|
|
disconnect_snmp
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
|
|
|
end
|
2010-12-25 06:08:34 +00:00
|
|
|
end
|