2007-02-18 00:10:39 +00:00
|
|
|
##
|
2007-04-24 06:27:39 +00:00
|
|
|
# $Id$
|
2007-02-18 00:10:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
2009-04-13 14:33:26 +00:00
|
|
|
# http://metasploit.com/framework/
|
2007-02-18 00:10:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
2006-08-12 08:52:54 +00:00
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
class Metasploit3 < Msf::Auxiliary
|
2006-08-12 08:52:54 +00:00
|
|
|
|
2007-04-24 06:27:39 +00:00
|
|
|
|
2006-08-13 00:08:40 +00:00
|
|
|
# Exploit mixins should be called first
|
2008-11-03 09:17:08 +00:00
|
|
|
include Msf::Exploit::Remote::DCERPC
|
|
|
|
include Msf::Exploit::Remote::SMB
|
2006-08-12 08:52:54 +00:00
|
|
|
|
2006-08-13 00:08:40 +00:00
|
|
|
# Scanner mixin should be near last
|
2008-10-02 05:23:59 +00:00
|
|
|
include Msf::Auxiliary::Scanner
|
2009-04-21 05:59:46 +00:00
|
|
|
include Msf::Auxiliary::Report
|
2007-04-24 06:27:39 +00:00
|
|
|
|
|
|
|
# Aliases for common classes
|
|
|
|
SIMPLE = Rex::Proto::SMB::SimpleClient
|
|
|
|
XCEPT = Rex::Proto::SMB::Exceptions
|
|
|
|
CONST = Rex::Proto::SMB::Constants
|
|
|
|
|
2006-08-13 00:08:40 +00:00
|
|
|
|
2006-08-12 08:52:54 +00:00
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'SMB Version Detection',
|
2007-02-18 00:10:39 +00:00
|
|
|
'Version' => '$Revision$',
|
2006-08-12 08:52:54 +00:00
|
|
|
'Description' => 'Display version information about each system',
|
|
|
|
'Author' => 'hdm',
|
|
|
|
'License' => MSF_LICENSE
|
|
|
|
)
|
2006-08-13 00:08:40 +00:00
|
|
|
|
|
|
|
deregister_options('RPORT')
|
|
|
|
end
|
2006-08-12 08:52:54 +00:00
|
|
|
|
2006-08-13 00:08:40 +00:00
|
|
|
# Fingerprint a single host
|
2008-11-11 06:08:04 +00:00
|
|
|
def run_host(ip)
|
2009-06-20 02:43:56 +00:00
|
|
|
[[445, true], [139, false]].each do |info|
|
2006-08-13 00:08:40 +00:00
|
|
|
|
2009-03-28 05:49:33 +00:00
|
|
|
datastore['RPORT'] = info[0]
|
|
|
|
datastore['SMBDirect'] = info[1]
|
2008-11-11 06:10:45 +00:00
|
|
|
self.simple = nil
|
2009-03-28 05:49:33 +00:00
|
|
|
|
2006-08-12 08:52:54 +00:00
|
|
|
begin
|
2008-11-03 20:37:51 +00:00
|
|
|
res = smb_fingerprint()
|
2006-08-13 00:08:40 +00:00
|
|
|
|
2008-11-03 20:37:51 +00:00
|
|
|
if(res['os'] and res['os'] != 'Unknown')
|
|
|
|
print_status("#{rhost} is running #{res['os']} #{res['sp']} (language: #{res['lang']})")
|
2009-04-21 05:59:46 +00:00
|
|
|
report_service(:host => ip, :port => info[0])
|
|
|
|
case res['os']
|
|
|
|
when /Windows/
|
|
|
|
os = OperatingSystems::WINDOWS
|
|
|
|
else
|
|
|
|
os = OperatingSystems::UNKNOWN
|
|
|
|
end
|
|
|
|
report_host({
|
|
|
|
:host => ip,
|
|
|
|
:os_flavor => res['os'],
|
|
|
|
:os_lang => res['lang'],
|
|
|
|
:os_name => os,
|
|
|
|
:os_sp => res['sp'],
|
|
|
|
})
|
2008-11-03 20:37:51 +00:00
|
|
|
else
|
|
|
|
print_status("#{rhost} could not be identified")
|
2007-01-31 00:08:52 +00:00
|
|
|
end
|
|
|
|
|
2008-11-03 09:17:08 +00:00
|
|
|
disconnect
|
|
|
|
|
2008-11-03 20:37:51 +00:00
|
|
|
break
|
2009-03-28 05:49:33 +00:00
|
|
|
rescue ::Rex::Proto::SMB::Exceptions::ErrorCode => e
|
2008-11-03 09:17:08 +00:00
|
|
|
rescue ::Rex::Proto::SMB::Exceptions::LoginError => e
|
|
|
|
# Vista has 139 open but doesnt like *SMBSERVER
|
|
|
|
if(e.to_s =~ /server refused our NetBIOS/)
|
|
|
|
next
|
|
|
|
end
|
|
|
|
|
|
|
|
return
|
2008-11-11 05:12:52 +00:00
|
|
|
rescue ::Rex::ConnectionError
|
2007-04-24 06:27:39 +00:00
|
|
|
next
|
2008-11-03 09:17:08 +00:00
|
|
|
rescue ::Exception => e
|
2008-11-03 20:37:51 +00:00
|
|
|
print_error("#{rhost}: #{e.class} #{e} #{e.backtrace}")
|
2007-04-24 06:27:39 +00:00
|
|
|
ensure
|
2008-11-03 09:17:08 +00:00
|
|
|
disconnect
|
2006-08-13 00:08:40 +00:00
|
|
|
end
|
2006-08-12 08:52:54 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2008-11-03 09:17:08 +00:00
|
|
|
end
|