2008-10-22 05:31:55 +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/
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
require 'rex/socket/ssl_tcp'
|
|
|
|
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
include Msf::Auxiliary::WMAPScanServer
|
|
|
|
include Msf::Auxiliary::Scanner
|
|
|
|
|
|
|
|
include Rex::Socket::Comm
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
2009-01-03 05:20:20 +00:00
|
|
|
'Name' => 'HTTP SSL Certificate tester',
|
2009-03-28 06:03:35 +00:00
|
|
|
'Version' => '$Revision$',
|
2009-01-03 05:20:20 +00:00
|
|
|
'Description' => 'Display vhost associated to server using SSL certificate and check for signature algorithm',
|
2008-10-22 05:31:55 +00:00
|
|
|
'Author' => 'et',
|
|
|
|
'License' => MSF_LICENSE
|
|
|
|
)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
# Fingerprint a single host
|
|
|
|
def run_host(ip)
|
|
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
ssock = Rex::Socket::SslTcp.create(
|
2008-10-23 03:19:24 +00:00
|
|
|
'PeerHost' => ip,
|
|
|
|
'PeerPort' => datastore['RPORT'])
|
|
|
|
|
|
|
|
cert = OpenSSL::X509::Certificate.new(ssock.peer_cert)
|
|
|
|
|
|
|
|
ssock.close
|
2008-10-22 05:31:55 +00:00
|
|
|
|
|
|
|
if cert
|
2009-01-03 05:20:20 +00:00
|
|
|
print_status("Subject: #{cert.subject} Signature Alg: #{cert.signature_algorithm}")
|
|
|
|
alg = cert.signature_algorithm
|
|
|
|
|
|
|
|
if alg.downcase.include? "md5"
|
|
|
|
print_status("#{ip} WARNING: Signature algorithm using MD5 (#{alg})")
|
|
|
|
end
|
|
|
|
|
2008-10-22 05:31:55 +00:00
|
|
|
sub = cert.subject.to_a
|
2008-10-23 03:19:24 +00:00
|
|
|
|
2009-01-03 05:20:20 +00:00
|
|
|
vhostn = 'EMPTY'
|
2008-10-23 03:19:24 +00:00
|
|
|
sub.each do |n|
|
2009-01-03 05:20:20 +00:00
|
|
|
#print_line "#{n[0]}"
|
2008-10-23 03:19:24 +00:00
|
|
|
if n[0] == 'CN'
|
2009-01-03 05:20:20 +00:00
|
|
|
#print_line "> #{n[1]}"
|
2008-10-23 03:19:24 +00:00
|
|
|
vhostn = n[1]
|
|
|
|
end
|
|
|
|
end
|
2008-10-22 05:31:55 +00:00
|
|
|
|
|
|
|
if vhostn
|
2008-10-23 03:19:24 +00:00
|
|
|
print_status("#{ip} is host #{vhostn}")
|
2008-10-27 02:22:30 +00:00
|
|
|
rep_id = wmap_base_report_id(
|
2008-11-10 04:38:05 +00:00
|
|
|
wmap_target_host,
|
|
|
|
wmap_target_port,
|
|
|
|
wmap_target_ssl
|
2008-10-27 02:22:30 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
wmap_report(rep_id,'VHOST','NAME',"#{vhostn}","Vhost #{vhostn} found.")
|
2008-12-19 07:11:08 +00:00
|
|
|
wmap_report(rep_id,'X509','SUBJECT',"#{cert.subject}",nil)
|
2009-01-03 05:20:20 +00:00
|
|
|
wmap_report(rep_id,'X509','SIGN_ALGORITHM',"#{cert.signature_algorithm}","Signature algorithm")
|
2008-10-22 05:31:55 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
print_status("No certificate subject or CN found")
|
|
|
|
end
|
|
|
|
|
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
|
|
|
|
rescue ::Timeout::Error, ::Errno::EPIPE
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|