2010-05-03 17:13:09 +00:00
|
|
|
##
|
2012-03-01 22:54:04 +00:00
|
|
|
# $Id$
|
2010-05-03 17:13:09 +00:00
|
|
|
##
|
2008-10-22 05:31:55 +00:00
|
|
|
|
|
|
|
##
|
2010-02-20 05:50:05 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2008-10-22 05:31:55 +00:00
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2008-10-22 05:31:55 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
2011-11-26 21:32:43 +00:00
|
|
|
class Metasploit4 < Msf::Auxiliary
|
2010-02-20 05:50:05 +00:00
|
|
|
|
|
|
|
include Msf::Exploit::Remote::Tcp
|
2012-02-03 21:43:21 +00:00
|
|
|
include Msf::Auxiliary::WmapScanSSL
|
2008-10-22 05:31:55 +00:00
|
|
|
include Msf::Auxiliary::Scanner
|
2009-11-26 20:39:15 +00:00
|
|
|
include Msf::Auxiliary::Report
|
2010-02-20 05:50:05 +00:00
|
|
|
|
2008-10-22 05:31:55 +00:00
|
|
|
include Rex::Socket::Comm
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
2010-02-20 05:50:05 +00:00
|
|
|
'Name' => 'HTTP SSL Certificate Information',
|
2012-03-01 22:59:54 +00:00
|
|
|
'Version' => '$Revision$',
|
2010-02-20 05:50:05 +00:00
|
|
|
'Description' => 'Parse the server SSL certificate to obtain the common name and signature algorithm',
|
2011-11-26 21:32:43 +00:00
|
|
|
'Author' =>
|
|
|
|
[
|
|
|
|
'et', #original module
|
|
|
|
'Chris John Riley', #additions
|
|
|
|
],
|
2008-10-22 05:31:55 +00:00
|
|
|
'License' => MSF_LICENSE
|
|
|
|
)
|
2010-02-20 05:50:05 +00:00
|
|
|
register_options([
|
|
|
|
Opt::RPORT(443)
|
|
|
|
], self.class)
|
2008-10-22 05:31:55 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Fingerprint a single host
|
|
|
|
def run_host(ip)
|
|
|
|
|
|
|
|
begin
|
2008-10-23 03:19:24 +00:00
|
|
|
|
2011-11-26 21:32:43 +00:00
|
|
|
connect(true, {"SSL" => true}) #Force SSL
|
2010-02-20 05:50:05 +00:00
|
|
|
|
|
|
|
cert = OpenSSL::X509::Certificate.new(sock.peer_cert)
|
|
|
|
|
|
|
|
disconnect
|
2008-10-23 03:19:24 +00:00
|
|
|
|
2008-10-22 05:31:55 +00:00
|
|
|
if cert
|
2011-11-26 21:32:43 +00:00
|
|
|
print_status("#{ip}:#{rport} Subject: #{cert.subject}")
|
|
|
|
print_status("#{ip}:#{rport} Issuer: #{cert.issuer}")
|
|
|
|
print_status("#{ip}:#{rport} Signature Alg: #{cert.signature_algorithm}")
|
|
|
|
|
|
|
|
# Checks for common properties of self signed certificates
|
|
|
|
caissuer = (/CA Issuers - URI:(.*?),/i).match(cert.extensions.to_s)
|
|
|
|
|
|
|
|
if caissuer.to_s.empty?
|
2012-10-08 20:23:26 +00:00
|
|
|
print_good("#{ip}:#{rport} Certificate contains no CA Issuers extension... possible self signed certificate")
|
2011-11-26 21:32:43 +00:00
|
|
|
else
|
|
|
|
print_status("#{ip}:#{rport} " +caissuer.to_s[0..-2])
|
|
|
|
end
|
|
|
|
|
|
|
|
if cert.issuer.to_s == cert.subject.to_s
|
2012-10-08 20:23:26 +00:00
|
|
|
print_good("#{ip}:#{rport} Certificate Subject and Issuer match... possible self signed certificate")
|
2011-11-26 21:32:43 +00:00
|
|
|
end
|
|
|
|
|
2009-01-03 05:20:20 +00:00
|
|
|
alg = cert.signature_algorithm
|
2010-02-20 05:50:05 +00:00
|
|
|
|
2009-01-03 05:20:20 +00:00
|
|
|
if alg.downcase.include? "md5"
|
2010-02-20 05:50:05 +00:00
|
|
|
print_status("#{ip}:#{rport} WARNING: Signature algorithm using MD5 (#{alg})")
|
2009-01-03 05:20:20 +00:00
|
|
|
end
|
2010-02-20 05:50:05 +00:00
|
|
|
|
|
|
|
vhostn = nil
|
|
|
|
cert.subject.to_a.each do |n|
|
|
|
|
vhostn = n[1] if n[0] == 'CN'
|
2008-10-23 03:19:24 +00:00
|
|
|
end
|
2010-02-20 05:50:05 +00:00
|
|
|
|
2008-10-22 05:31:55 +00:00
|
|
|
if vhostn
|
2010-02-20 05:50:05 +00:00
|
|
|
print_status("#{ip}:#{rport} has common name #{vhostn}")
|
|
|
|
|
|
|
|
# Store the virtual hostname for HTTP
|
2009-11-25 06:08:28 +00:00
|
|
|
report_note(
|
2009-11-26 20:39:15 +00:00
|
|
|
:host => ip,
|
2009-11-25 06:08:28 +00:00
|
|
|
:port => rport,
|
2010-02-20 05:50:05 +00:00
|
|
|
:proto => 'tcp',
|
|
|
|
:type => 'http.vhost',
|
|
|
|
:data => {:name => vhostn}
|
2009-11-25 06:08:28 +00:00
|
|
|
)
|
2010-02-20 05:50:05 +00:00
|
|
|
|
|
|
|
# Store the SSL certificate itself
|
2009-11-25 06:08:28 +00:00
|
|
|
report_note(
|
2009-11-26 20:39:15 +00:00
|
|
|
:host => ip,
|
2010-02-20 05:50:05 +00:00
|
|
|
:proto => 'tcp',
|
2009-11-25 06:08:28 +00:00
|
|
|
:port => rport,
|
2010-02-20 05:50:05 +00:00
|
|
|
:type => 'ssl.certificate',
|
|
|
|
:data => {
|
|
|
|
:cn => vhostn,
|
|
|
|
:subject => cert.subject.to_a,
|
|
|
|
:algorithm => alg
|
|
|
|
|
|
|
|
}
|
2009-03-28 17:45:14 +00:00
|
|
|
)
|
2010-02-20 05:50:05 +00:00
|
|
|
|
|
|
|
# Update the server hostname if necessary
|
|
|
|
if vhostn !~ /localhost|snakeoil/i
|
|
|
|
report_host(
|
|
|
|
:host => ip,
|
|
|
|
:name => vhostn
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2008-10-22 05:31:55 +00:00
|
|
|
end
|
|
|
|
else
|
2010-02-20 05:50:05 +00:00
|
|
|
print_status("#{ip}:#{rport}] No certificate subject or common name found")
|
|
|
|
end
|
2008-10-22 05:31:55 +00:00
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
|
|
|
|
rescue ::Timeout::Error, ::Errno::EPIPE
|
|
|
|
end
|
2010-02-20 05:50:05 +00:00
|
|
|
end
|
2012-03-18 05:07:27 +00:00
|
|
|
end
|