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
|
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
|
|
|
desc = "#{rhost} is running #{res['os']} #{res['sp']} (language: #{res['lang']})"
|
2009-12-29 14:00:49 +00:00
|
|
|
if(simple.client.default_name)
|
2010-01-05 18:47:04 +00:00
|
|
|
desc << " (name:#{simple.client.default_name})"
|
2009-12-29 14:00:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if(simple.client.default_domain)
|
2010-01-05 18:47:04 +00:00
|
|
|
desc << " (domain:#{simple.client.default_domain})"
|
2009-12-29 14:00:49 +00:00
|
|
|
end
|
|
|
|
|
2010-01-05 18:47:04 +00:00
|
|
|
print_status(desc)
|
|
|
|
|
|
|
|
report_service(
|
|
|
|
:host => ip,
|
|
|
|
:port => info[0],
|
|
|
|
:proto => 'tcp',
|
|
|
|
:name => 'smb',
|
|
|
|
:info => "#{res['os']} #{res['sp']} (language: #{res['lang']})"
|
|
|
|
)
|
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
|
|
|
|
when /ubuntu/
|
|
|
|
os = 'Ubuntu'
|
|
|
|
res['os'] = OperatingSystems::LINUX
|
|
|
|
when /debian/
|
|
|
|
os = 'Ubuntu'
|
|
|
|
res['os'] = OperatingSystems::LINUX
|
|
|
|
else
|
|
|
|
os = OperatingSystems::UNKNOWN
|
|
|
|
end
|
2009-04-21 05:59:46 +00:00
|
|
|
end
|
2010-02-11 22:37:00 +00:00
|
|
|
|
2009-04-21 05:59:46 +00:00
|
|
|
report_host({
|
2009-12-27 07:30:50 +00:00
|
|
|
:host => ip,
|
|
|
|
:os_flavor => res['os'],
|
2009-04-21 05:59:46 +00:00
|
|
|
:os_lang => res['lang'],
|
2009-12-27 07:30:50 +00:00
|
|
|
:os_name => os,
|
2010-01-05 18:47:04 +00:00
|
|
|
:os_sp => res['sp']
|
2009-04-21 05:59:46 +00:00
|
|
|
})
|
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
|
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
|
2009-12-27 07:30:50 +00:00
|
|
|
|
2008-11-03 09:17:08 +00:00
|
|
|
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
|
2009-12-27 07:30:50 +00:00
|
|
|
|