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
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2009-12-27 07:30:50 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2007-02-18 00:10:39 +00:00
|
|
|
# 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
|
|
|
|
2009-12-27 07:30:50 +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
|
2010-08-12 15:00:58 +00:00
|
|
|
include Msf::Exploit::Remote::SMB::Authenticated
|
2009-12-27 07:30:50 +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
|
|
|
|
|
2009-12-27 07:30:50 +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
|
|
|
|
)
|
2009-12-27 07:30:50 +00:00
|
|
|
|
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
|
2009-12-27 07:30:50 +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()
|
2009-12-27 07:30:50 +00:00
|
|
|
|
2008-11-03 20:37:51 +00:00
|
|
|
if(res['os'] and res['os'] != 'Unknown')
|
2010-01-05 18:47:04 +00:00
|
|
|
|
2009-04-21 05:59:46 +00:00
|
|
|
case res['os']
|
|
|
|
when /Windows/
|
|
|
|
os = OperatingSystems::WINDOWS
|
|
|
|
else
|
2010-02-11 22:37:00 +00:00
|
|
|
case res['sp']
|
|
|
|
when /apple/
|
|
|
|
os = OperatingSystems::MAC_OSX
|
2010-05-05 16:08:59 +00:00
|
|
|
res['os'] = 'Mac OS X'
|
2010-02-11 22:37:00 +00:00
|
|
|
when /ubuntu/
|
2010-02-14 17:13:55 +00:00
|
|
|
os = OperatingSystems::LINUX
|
2010-02-15 13:34:07 +00:00
|
|
|
res['os'] = 'Ubuntu'
|
2010-02-11 22:37:00 +00:00
|
|
|
when /debian/
|
2010-02-14 17:13:55 +00:00
|
|
|
os = OperatingSystems::LINUX
|
2010-02-15 13:34:07 +00:00
|
|
|
res['os'] = 'Debian'
|
2010-02-11 22:37:00 +00:00
|
|
|
else
|
|
|
|
os = OperatingSystems::UNKNOWN
|
|
|
|
end
|
2009-04-21 05:59:46 +00:00
|
|
|
end
|
2010-02-11 22:37:00 +00:00
|
|
|
|
2010-03-15 21:35:21 +00:00
|
|
|
desc = "#{res['os']} #{res['sp']} (language: #{res['lang']})"
|
2010-02-13 23:26:07 +00:00
|
|
|
if(simple.client.default_name)
|
|
|
|
desc << " (name:#{simple.client.default_name})"
|
|
|
|
end
|
|
|
|
|
|
|
|
if(simple.client.default_domain)
|
|
|
|
desc << " (domain:#{simple.client.default_domain})"
|
|
|
|
end
|
|
|
|
|
2010-09-24 17:52:25 +00:00
|
|
|
print_status("#{rhost}:#{rport} is running #{desc}")
|
2010-02-13 23:26:07 +00:00
|
|
|
|
|
|
|
report_service(
|
|
|
|
:host => ip,
|
|
|
|
:port => info[0],
|
|
|
|
:proto => 'tcp',
|
|
|
|
:name => 'smb',
|
2010-03-15 21:35:21 +00:00
|
|
|
:info => desc
|
2010-02-13 23:26:07 +00:00
|
|
|
)
|
|
|
|
|
2010-02-14 17:25:05 +00:00
|
|
|
conf = {
|
2009-12-27 07:30:50 +00:00
|
|
|
:os_flavor => res['os'],
|
2010-09-21 03:14:08 +00:00
|
|
|
:os_name => os,
|
2010-02-14 17:25:05 +00:00
|
|
|
}
|
|
|
|
|
2010-03-22 00:09:04 +00:00
|
|
|
conf[:os_sp] = res['sp'] if res['sp']
|
2010-02-14 17:25:05 +00:00
|
|
|
conf[:os_lang] = res['lang'] if res['os'] =~ /Windows/
|
|
|
|
|
2010-03-22 00:09:04 +00:00
|
|
|
report_note(
|
|
|
|
:host => ip,
|
|
|
|
:port => info[0],
|
|
|
|
:proto => 'tcp',
|
|
|
|
:ntype => 'smb.fingerprint',
|
|
|
|
:data => conf
|
|
|
|
)
|
|
|
|
|
2008-11-03 20:37:51 +00:00
|
|
|
else
|
2009-12-27 07:30:50 +00:00
|
|
|
report_service(:host => ip, :port => info[0], :name => 'smb')
|
2008-11-03 20:37:51 +00:00
|
|
|
print_status("#{rhost} could not be identified")
|
2007-01-31 00:08:52 +00:00
|
|
|
end
|
2009-12-27 07:30:50 +00:00
|
|
|
|
2008-11-03 09:17:08 +00:00
|
|
|
disconnect
|
2009-12-27 07:30:50 +00:00
|
|
|
|
2008-11-03 20:37:51 +00:00
|
|
|
break
|
2010-07-14 17:08:08 +00:00
|
|
|
|
|
|
|
rescue ::Rex::Proto::SMB::Exceptions::NoReply => e
|
|
|
|
next
|
2009-03-28 05:49:33 +00:00
|
|
|
rescue ::Rex::Proto::SMB::Exceptions::ErrorCode => e
|
2010-07-14 17:08:08 +00:00
|
|
|
next
|
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
|
2009-12-27 07:30:50 +00:00
|
|
|
|
2008-11-03 09:17:08 +00:00
|
|
|
return
|
2010-04-06 03:57:22 +00:00
|
|
|
rescue ::Timeout::Error
|
2008-11-11 05:12:52 +00:00
|
|
|
rescue ::Rex::ConnectionError
|
2007-04-24 06:27:39 +00:00
|
|
|
next
|
2010-07-14 17:08:08 +00:00
|
|
|
|
2008-11-03 09:17:08 +00:00
|
|
|
rescue ::Exception => e
|
2010-04-06 03:57:22 +00:00
|
|
|
print_error("#{rhost}: #{e.class} #{e}")
|
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
|
2009-12-27 07:30:50 +00:00
|
|
|
|