2008-06-06 04:29:41 +00:00
|
|
|
##
|
2010-04-30 08:40:19 +00:00
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2008-06-06 04:29:41 +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/
|
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
|
2010-02-05 21:13:07 +00:00
|
|
|
include Msf::Auxiliary::Report
|
2008-10-02 05:23:59 +00:00
|
|
|
include Msf::Auxiliary::Scanner
|
2010-04-30 08:40:19 +00:00
|
|
|
|
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
|
|
|
|
2010-04-30 08:40:19 +00:00
|
|
|
# RFB Protocol Version 3.3 (1998-01)
|
|
|
|
# RFB Protocol Version 3.7 (2003-08)
|
|
|
|
# RFB Protocol Version 3.8 (2007-06)
|
2009-10-18 20:59:35 +00:00
|
|
|
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}")
|
2010-02-05 21:13:07 +00:00
|
|
|
report_service(
|
|
|
|
:host => rhost,
|
|
|
|
:port => rport,
|
|
|
|
:proto => 'tcp',
|
|
|
|
:name => 'vnc',
|
|
|
|
:info => "VNC 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
|
2010-04-30 08:40:19 +00:00
|
|
|
print_status("#{target_host}:#{rport}, VNC server warning messages : \"#{msg}\"")
|
|
|
|
else
|
2009-10-18 20:59:35 +00:00
|
|
|
# send VNC client protocol version
|
|
|
|
cver = ver + "\x0a"
|
|
|
|
sock.put(cver)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-10-18 20:59:35 +00:00
|
|
|
# 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
|
2009-12-17 16:14:27 +00:00
|
|
|
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
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-10-18 20:59:35 +00:00
|
|
|
sec_type = []
|
|
|
|
if types
|
|
|
|
sec_type << "None" if (types.include? 1)
|
|
|
|
sec_type << "VNC" if (types.include? 2)
|
2010-04-30 08:40:19 +00:00
|
|
|
sec_type << "Tight" if (types.include? 16)
|
2009-10-18 20:59:35 +00:00
|
|
|
sec_type << "Ultra" if (types.include? 17)
|
2010-04-30 08:40:19 +00:00
|
|
|
sec_type << "TLS" if (types.include? 18)
|
2009-10-18 20:59:35 +00:00
|
|
|
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!")
|
2010-02-05 21:13:07 +00:00
|
|
|
report_vuln({
|
|
|
|
:host => rhost,
|
|
|
|
:port => rport,
|
|
|
|
:proto => 'tcp',
|
|
|
|
:name => 'VNC-NONE-AUTH-ALLOWED',
|
|
|
|
:data => sec_type.join(",")
|
|
|
|
})
|
2009-10-18 20:59:35 +00:00
|
|
|
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
|
2010-04-15 02:09:08 +00:00
|
|
|
print_error("#{target_host}:#{rport}, failed to retrieve 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
|
2010-02-05 21:13:07 +00:00
|
|
|
|