2008-06-06 04:29:41 +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/
|
2008-06-06 04:29:41 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
class Metasploit3 < Msf::Auxiliary
|
2008-06-06 04:29:41 +00:00
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
include Msf::Exploit::Remote::Tcp
|
|
|
|
include Msf::Auxiliary::Scanner
|
2008-06-06 04:29:41 +00:00
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'VNC Authentication None Detection',
|
2008-06-06 04:39:44 +00:00
|
|
|
'Version' => '$Revision$',
|
2008-06-06 04:29:41 +00:00
|
|
|
'Description' => 'Detect VNC server with empty password.',
|
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
['URL', 'http://en.wikipedia.org/wiki/RFB'],
|
|
|
|
['URL', 'http://en.wikipedia.org/wiki/Vnc'],
|
|
|
|
],
|
|
|
|
'Author' => 'Matteo Cantoni <goony[at]nothink.org>',
|
|
|
|
'License' => MSF_LICENSE
|
|
|
|
)
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
Opt::RPORT(5900),
|
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
def run_host(target_host)
|
|
|
|
|
|
|
|
connect
|
|
|
|
|
2009-10-18 20:59:35 +00:00
|
|
|
begin
|
|
|
|
banner = sock.get_once(50,1)
|
2008-06-06 04:29:41 +00:00
|
|
|
|
2009-10-18 20:59:35 +00:00
|
|
|
# RFB Protocol Version 3.3 (1998-01)
|
|
|
|
# RFB Protocol Version 3.7 (2003-08)
|
|
|
|
# RFB Protocol Version 3.8 (2007-06)
|
|
|
|
if (banner and banner =~ /RFB 003\.003|RFB 003\.007|RFB 003\.008/)
|
|
|
|
ver,msg = (banner.split(/\n/))
|
2008-06-06 04:29:41 +00:00
|
|
|
|
2009-10-18 20:59:35 +00:00
|
|
|
print_status("#{target_host}:#{rport}, VNC server protocol version : #{ver}")
|
2008-06-06 04:29:41 +00:00
|
|
|
|
2009-10-18 20:59:35 +00:00
|
|
|
if msg
|
|
|
|
if (msg =~ /Too many security failures/)
|
|
|
|
msg = msg + ". " + "Wait for a moment!"
|
2008-06-06 04:29:41 +00:00
|
|
|
end
|
2009-10-18 20:59:35 +00:00
|
|
|
print_status("#{target_host}:#{rport}, VNC server warning messages : \"#{msg}\"")
|
|
|
|
else
|
|
|
|
# send VNC client protocol version
|
|
|
|
cver = ver + "\x0a"
|
|
|
|
sock.put(cver)
|
|
|
|
|
|
|
|
# first byte is number of security types
|
|
|
|
num_types = sock.get_once(1).unpack("C").first
|
|
|
|
if (num_types == 0)
|
|
|
|
msg_len = sock.get_once(4).unpack("N").first
|
|
|
|
raise RunTimeError.new("Server error: #{sock.get_once(msg_len)}")
|
2008-06-06 04:29:41 +00:00
|
|
|
end
|
2009-10-18 20:59:35 +00:00
|
|
|
types = sock.get_once(num_types).unpack("C*")
|
|
|
|
|
|
|
|
# Security types
|
|
|
|
# 1 : No authentication, no encryption
|
|
|
|
# 2 : Standard VNC authentication
|
|
|
|
# 16 : Tight (tightvncserver)
|
|
|
|
# 17 : Ultra
|
|
|
|
# 18 : TLS
|
|
|
|
|
|
|
|
sec_type = []
|
|
|
|
if types
|
|
|
|
sec_type << "None" if (types.include? 1)
|
|
|
|
sec_type << "VNC" if (types.include? 2)
|
|
|
|
sec_type << "Tight" if (types.include? 16)
|
|
|
|
sec_type << "Ultra" if (types.include? 17)
|
|
|
|
sec_type << "TLS" if (types.include? 18)
|
|
|
|
print_status("#{target_host}:#{rport}, VNC server security types supported : #{sec_type.join(",")}")
|
|
|
|
if (types.include? 1)
|
|
|
|
print_status("#{target_host}:#{rport}, VNC server security types includes None, free access!")
|
|
|
|
end
|
2008-06-06 04:29:41 +00:00
|
|
|
else
|
2009-10-18 20:59:35 +00:00
|
|
|
print_error("#{target_host}:#{rport}, failed to parse security types")
|
2008-06-06 04:29:41 +00:00
|
|
|
end
|
|
|
|
end
|
2009-10-18 20:59:35 +00:00
|
|
|
elsif banner
|
|
|
|
print_status("#{target_host}:#{rport}, VNC server protocol version : \"#{banner.chomp}\", not supported!")
|
|
|
|
else
|
|
|
|
print_error("#{target_host}:#{rport}, failed to retreive banner")
|
2008-06-06 04:29:41 +00:00
|
|
|
end
|
|
|
|
|
2009-10-18 20:59:35 +00:00
|
|
|
ensure
|
|
|
|
disconnect
|
|
|
|
end
|
2008-06-06 04:29:41 +00:00
|
|
|
end
|
2009-10-18 20:59:35 +00:00
|
|
|
end
|