2010-12-25 06:08:34 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +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'
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Auxiliary
|
2010-12-25 06:08:34 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Exploit::Remote::SNMPClient
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
include Msf::Auxiliary::Scanner
|
2010-12-25 06:08:34 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'SNMP Windows SMB Share Enumeration',
|
|
|
|
'Description' => "This module will use LanManager OID values to enumerate SMB shares on a Windows system via SNMP",
|
|
|
|
'Author' => ['tebo[at]attackresearch.com'],
|
|
|
|
'License' => MSF_LICENSE
|
|
|
|
)
|
2010-12-25 06:08:34 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2010-12-25 06:08:34 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def run_host(ip)
|
|
|
|
begin
|
|
|
|
snmp = connect_snmp
|
2010-12-25 06:08:34 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
share_tbl = ["1.3.6.1.4.1.77.1.2.27.1.1",
|
|
|
|
"1.3.6.1.4.1.77.1.2.27.1.2",
|
|
|
|
"1.3.6.1.4.1.77.1.2.27.1.3"]
|
2010-12-25 06:08:34 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
@shares = []
|
|
|
|
if snmp.get_value('sysDescr.0') =~ /Windows/
|
2010-12-25 06:08:34 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
snmp.walk(share_tbl) do |entry|
|
|
|
|
@shares << entry.collect{|x|x.value}
|
|
|
|
end
|
|
|
|
end
|
2010-12-25 06:08:34 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
disconnect_snmp
|
2010-12-25 06:08:34 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
if not @shares.empty?
|
|
|
|
print_good("#{ip} #{@shares.map{|x| "\n\t#{x[0]} - #{x[2]} (#{x[1]})" }.join}") #"
|
|
|
|
report_note(
|
|
|
|
:host => ip,
|
|
|
|
:proto => 'udp',
|
|
|
|
:port => datastore['RPORT'],
|
|
|
|
:sname => 'snmp',
|
|
|
|
:type => 'smb.shares',
|
|
|
|
:data => { :shares => @shares },
|
|
|
|
:update => :unique_data
|
|
|
|
)
|
|
|
|
end
|
2010-12-25 06:08:34 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
rescue ::Rex::ConnectionError, ::SNMP::RequestTimeout, ::SNMP::UnsupportedVersion
|
|
|
|
rescue ::Interrupt
|
|
|
|
raise $!
|
|
|
|
rescue ::Exception => e
|
|
|
|
print_error("#{ip} Unknown error: #{e.class} #{e}")
|
|
|
|
ensure
|
|
|
|
disconnect_snmp
|
|
|
|
end
|
2010-12-25 06:08:34 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2010-12-25 06:08:34 +00:00
|
|
|
|
|
|
|
end
|