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.
|
|
|
|
# http://metasploit.com/projects/Framework/
|
|
|
|
##
|
|
|
|
|
|
|
|
|
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
|
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
|
|
|
|
2008-11-03 09:17:08 +00:00
|
|
|
# Overload the RPORT setting
|
|
|
|
def rport
|
|
|
|
@target_port
|
|
|
|
end
|
|
|
|
|
2006-08-13 00:08:40 +00:00
|
|
|
# Fingerprint a single host
|
2008-11-11 06:08:04 +00:00
|
|
|
def run_host(ip)
|
2006-08-13 00:08:40 +00:00
|
|
|
[[139, false], [445, true]].each do |info|
|
|
|
|
|
2008-11-03 09:17:08 +00:00
|
|
|
@target_port = info[0]
|
|
|
|
self.smb_direct = info[1]
|
2008-11-11 06:10:45 +00:00
|
|
|
self.simple = nil
|
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']})")
|
|
|
|
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
|
2008-11-03 09:17:08 +00:00
|
|
|
rescue ::Rex::Proto::SMB::Exceptions::ErrorCode
|
|
|
|
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
|