metasploit-credential 6.0.0 → 6.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +2 -3
- data/app/models/metasploit/credential/krb_enc_key.rb +184 -0
- data/app/models/metasploit/credential/private.rb +1 -0
- data/config/locales/en.yml +5 -0
- data/lib/metasploit/credential/creation.rb +3 -0
- data/lib/metasploit/credential/version.rb +1 -1
- data/lib/metasploit/credential.rb +1 -0
- data/spec/dummy/config/database.yml +2 -2
- data/spec/factories/metasploit/credential/cores.rb +2 -1
- data/spec/factories/metasploit/credential/krb_enc_key.rb +81 -0
- data/spec/lib/metasploit/credential/creation_spec.rb +10 -0
- data/spec/models/metasploit/credential/krb_enc_key_spec.rb +151 -0
- data/spec/models/metasploit/credential/private_spec.rb +1 -0
- data.tar.gz.sig +0 -0
- metadata +7 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 416819532338ddf04c5f8305550aa8c3b728223a6ddfe0e8aff141c4690f84bb
|
4
|
+
data.tar.gz: 1a1f815cde01159da2d994b3bc87a90c98a055957c317841d4c5f64381f5a4cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf49d45cfb1f1e5b80795d117947ae7bfe15c507d62d37e7e70b80e6b47e03bfdee5ed5e21f071f5746cb7d20e7ba878049cb4c4f44106f98c831fcd13624b88
|
7
|
+
data.tar.gz: 056fd6587af57c9078459859e43284fb809fb394132919ed70ed237693e2edc1e3eea66ba70b6a1cad1d532959b1aab8d4515cbfbffd3be923c837cd7034fc9a
|
checksums.yaml.gz.sig
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
����͌g�Hq��(|9���t/gt��88O�����b��t���PGl�
|
1
|
+
e���B�-����pO�i�-ޫL|� �;�L�#� �,l]C419�:�s�Ϻ%��@�(����Ԣ�#8�.Og��u
|
2
|
+
����~�K4�Ǧ� �����V@�c��D����U8*�� F�챞����L���ޙ�rk��:�o���>���Z<�@ENdp��&x]�T��4�������9�E���PP��є{�qg�o5�&�%m�Yc�;�>d,o�,AT;M㰉g#W��-�'m��D(�
|
@@ -0,0 +1,184 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
# A {Metasploit::Credential::PasswordHash password hash} that cannot be replayed to authenticate to other services.
|
4
|
+
# {#data} is a string in the format `'msf_krbenckey:<enctype digits>:<key hexadecimal>:<salt hexadecimal>'`.
|
5
|
+
#
|
6
|
+
# This class contains information relevant to a Kerberos EncryptionKey https://www.rfc-editor.org/rfc/rfc4120.html#section-5.2.9
|
7
|
+
# which is used to encrypt/decrypt arbitrary Kerberos protocol message data - such as the AS-REP krbtgt ticket and enc-part.
|
8
|
+
class Metasploit::Credential::KrbEncKey < Metasploit::Credential::PasswordHash
|
9
|
+
|
10
|
+
#
|
11
|
+
# Constants
|
12
|
+
#
|
13
|
+
|
14
|
+
# Valid format for KrbEncKey enctype portion of {#data}: numeric characters
|
15
|
+
# @see ENCTYPE_NAMES
|
16
|
+
TYPE_REGEXP = /(?<enctype>\d+)/
|
17
|
+
private_constant :TYPE_REGEXP
|
18
|
+
|
19
|
+
# Valid format for KrbEncKey key portion of {#data}: lowercase hexadecimal characters
|
20
|
+
KEY_REGEXP = /(?<key>[0-9a-f]+)/
|
21
|
+
private_constant :KEY_REGEXP
|
22
|
+
|
23
|
+
# Valid format for KrbEncKey enctype portion of {#data}: lowercase hexadecimal characters
|
24
|
+
SALT_REGEXP = /(?<salt>[0-9a-f]*)/
|
25
|
+
private_constant :SALT_REGEXP
|
26
|
+
|
27
|
+
# Valid format for {#data} composed of `'msf_krbenckey:<enctype digits>:<key hexadecimal>:<salt hexadecimal>'`.
|
28
|
+
DATA_REGEXP = /\Amsf_krbenckey:#{TYPE_REGEXP}:#{KEY_REGEXP}:#{SALT_REGEXP}\z/
|
29
|
+
private_constant :DATA_REGEXP
|
30
|
+
|
31
|
+
# https://www.iana.org/assignments/kerberos-parameters/kerberos-parameters.xhtml
|
32
|
+
ENCTYPE_NAMES = (Hash.new { |_hash, enctype| "unassigned-#{enctype}" }).merge({
|
33
|
+
0 => 'reserved-0',
|
34
|
+
1 => 'des-cbc-crc',
|
35
|
+
2 => 'des-cbc-md4',
|
36
|
+
3 => 'des-cbc-md5',
|
37
|
+
4 => 'reserved-4',
|
38
|
+
5 => 'des3-cbc-md5',
|
39
|
+
6 => 'reserved-6',
|
40
|
+
7 => 'des3-cbc-sha1',
|
41
|
+
8 => 'unassigned-8',
|
42
|
+
9 => 'dsaWithSHA1-CmsOID',
|
43
|
+
10 => 'md5WithRSAEncryption-CmsOID',
|
44
|
+
11 => 'sha1WithRSAEncryption-CmsOID',
|
45
|
+
12 => 'rc2CBC-EnvOID',
|
46
|
+
13 => 'rsaEncryption-EnvOID',
|
47
|
+
14 => 'rsaES-OAEP-ENV-OID',
|
48
|
+
15 => 'des-ede3-cbc-Env-OID',
|
49
|
+
16 => 'des3-cbc-sha1-kd',
|
50
|
+
17 => 'aes128-cts-hmac-sha1-96',
|
51
|
+
18 => 'aes256-cts-hmac-sha1-96',
|
52
|
+
19 => 'aes128-cts-hmac-sha256-128',
|
53
|
+
20 => 'aes256-cts-hmac-sha384-192',
|
54
|
+
21 => 'unassigned-21',
|
55
|
+
22 => 'unassigned-22',
|
56
|
+
23 => 'rc4-hmac',
|
57
|
+
24 => 'rc4-hmac-exp',
|
58
|
+
25 => 'camellia128-cts-cmac',
|
59
|
+
26 => 'camellia256-cts-cmac',
|
60
|
+
65 => 'subkey-keymaterial'
|
61
|
+
})
|
62
|
+
private_constant :ENCTYPE_NAMES
|
63
|
+
|
64
|
+
#
|
65
|
+
# Attributes
|
66
|
+
#
|
67
|
+
|
68
|
+
# @!attribute data
|
69
|
+
#
|
70
|
+
# @return [Hash{Symbol => String}]
|
71
|
+
|
72
|
+
#
|
73
|
+
# Callbacks
|
74
|
+
#
|
75
|
+
|
76
|
+
before_validation :normalize_data
|
77
|
+
|
78
|
+
#
|
79
|
+
# Validations
|
80
|
+
#
|
81
|
+
|
82
|
+
validate :data_format
|
83
|
+
|
84
|
+
#
|
85
|
+
# Class methods
|
86
|
+
#
|
87
|
+
|
88
|
+
# @param [Integer] enctype The enctype
|
89
|
+
# @param [String] key The key bytes
|
90
|
+
# @param [String,nil] salt The salt
|
91
|
+
# @return [String]
|
92
|
+
# @raise [ArgumentError] if an option is invalid
|
93
|
+
def self.build_data(enctype:, key:, salt: nil)
|
94
|
+
raise ArgumentError('enctype must be numeric') unless enctype.is_a?(Numeric)
|
95
|
+
raise ArgumentError('key must be set') if key.nil?
|
96
|
+
|
97
|
+
"msf_krbenckey:#{enctype}:#{as_hex(key)}:#{as_hex(salt)}"
|
98
|
+
end
|
99
|
+
|
100
|
+
#
|
101
|
+
# Instance Methods
|
102
|
+
#
|
103
|
+
|
104
|
+
# The enctype as defined by https://www.iana.org/assignments/kerberos-parameters/kerberos-parameters.xhtml
|
105
|
+
#
|
106
|
+
# @return [Integer]
|
107
|
+
def enctype
|
108
|
+
parsed_data[:enctype]
|
109
|
+
end
|
110
|
+
|
111
|
+
# The key
|
112
|
+
#
|
113
|
+
# @return [String]
|
114
|
+
def key
|
115
|
+
parsed_data[:key]
|
116
|
+
end
|
117
|
+
|
118
|
+
# The salt used as part of creating the key. This is normally derived from the Kerberos principal name/Realm.
|
119
|
+
# For windows the following convention is used to create the salt:
|
120
|
+
# https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-kile/7a7b081d-c0c6-46f4-acbf-a439664270b8
|
121
|
+
#
|
122
|
+
# This value can be nil if the salt is not known
|
123
|
+
# @return [String,nil] The key salt if available
|
124
|
+
def salt
|
125
|
+
parsed_data[:salt]
|
126
|
+
end
|
127
|
+
|
128
|
+
# A string suitable for displaying to the user
|
129
|
+
#
|
130
|
+
# @return [String]
|
131
|
+
def to_s
|
132
|
+
"#{ENCTYPE_NAMES[enctype]}:#{self.class.as_hex(key)}#{salt ? ":#{self.class.as_hex(salt)}" : ''}"
|
133
|
+
end
|
134
|
+
|
135
|
+
private
|
136
|
+
|
137
|
+
# Converts a buffer containing bytes to a String containing the hex representation of the bytes
|
138
|
+
#
|
139
|
+
# @param hash [String,nil] a buffer of bytes
|
140
|
+
# @return [String] a string where every 2 hexadecimal characters represents a byte in the original hash buffer
|
141
|
+
def self.as_hex(value)
|
142
|
+
value.to_s.unpack1('H*')
|
143
|
+
end
|
144
|
+
|
145
|
+
# Converts a buffer containing bytes to a String containing the hex representation of the bytes
|
146
|
+
#
|
147
|
+
# @param hash [String,nil] a buffer of bytes
|
148
|
+
# @return [String] a string where every 2 hexadecimal characters represents a byte in the original hash buffer
|
149
|
+
def self.as_bytes(value)
|
150
|
+
[value.to_s].pack('H*')
|
151
|
+
end
|
152
|
+
|
153
|
+
# @return [Hash] The parsed data with enctype, key, salt keys
|
154
|
+
def parsed_data
|
155
|
+
match = data.match(DATA_REGEXP)
|
156
|
+
return {} unless match
|
157
|
+
|
158
|
+
{
|
159
|
+
enctype: match[:enctype].to_i,
|
160
|
+
key: self.class.as_bytes(match[:key]),
|
161
|
+
salt: match[:salt].empty? ? nil : self.class.as_bytes(match[:salt])
|
162
|
+
}
|
163
|
+
end
|
164
|
+
|
165
|
+
# Normalizes {#data} by making it all lowercase so that the unique validation and index on
|
166
|
+
# ({Metasploit::Credential::Private#type}, {#data}) catches collision in a case-insensitive manner without the need
|
167
|
+
# to use case-insensitive comparisons.
|
168
|
+
def normalize_data
|
169
|
+
if data
|
170
|
+
self.data = data.downcase
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
# Validates that {#data} is in the expected data format
|
175
|
+
def data_format
|
176
|
+
unless DATA_REGEXP.match(data)
|
177
|
+
errors.add(:data, :format)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
public
|
182
|
+
|
183
|
+
Metasploit::Concern.run(self)
|
184
|
+
end
|
data/config/locales/en.yml
CHANGED
@@ -56,6 +56,7 @@ en:
|
|
56
56
|
models:
|
57
57
|
metasploit/credential/ntlm_hash: "NTLM hash"
|
58
58
|
metasploit/credential/ssh_key: "SSH key"
|
59
|
+
metasploit/credential/krb_enc_key: 'Krb enc key'
|
59
60
|
errors:
|
60
61
|
models:
|
61
62
|
metasploit/credential/core:
|
@@ -78,6 +79,10 @@ en:
|
|
78
79
|
attributes:
|
79
80
|
data:
|
80
81
|
format: "is not in the NTLMHash data format of <LAN Manager hex digest>:<NT LAN Manager hex digest>, where each hex digest is 32 lowercase hexadecimal characters."
|
82
|
+
metasploit/credential/krb_enc_key:
|
83
|
+
attributes:
|
84
|
+
data:
|
85
|
+
format: "is not in the KrbEncKey data format of 'msf_krbenckey:<ENCTYPE>:<KEY>:<SALT>', where the key and salt are in hexadecimal characters"
|
81
86
|
metasploit/credential/ssh_key:
|
82
87
|
attributes:
|
83
88
|
data:
|
@@ -462,6 +462,7 @@ module Metasploit::Credential::Creation
|
|
462
462
|
# @return [Metasploit::Credential::SSHKey] if the private_type was :ssh_key
|
463
463
|
# @return [Metasploit::Credential::NTLMHash] if the private_type was :ntlm_hash
|
464
464
|
# @return [Metasploit::Credential::NonreplayableHash] if the private_type was :nonreplayable_hash
|
465
|
+
# @return [Metasploit::Credential::KrbEncKey] if the private_type was :krb_enc_key
|
465
466
|
def create_credential_private(opts={})
|
466
467
|
return nil unless active_db?
|
467
468
|
private_data = opts.fetch(:private_data)
|
@@ -478,6 +479,8 @@ module Metasploit::Credential::Creation
|
|
478
479
|
private_object = Metasploit::Credential::Password.where(data: private_data).first_or_create
|
479
480
|
when :ssh_key
|
480
481
|
private_object = Metasploit::Credential::SSHKey.where(data: private_data).first_or_create
|
482
|
+
when :krb_enc_key
|
483
|
+
private_object = Metasploit::Credential::KrbEncKey.where(data: private_data).first_or_create
|
481
484
|
when :ntlm_hash
|
482
485
|
private_object = Metasploit::Credential::NTLMHash.where(data: private_data).first_or_create
|
483
486
|
private_object.jtr_format = 'nt,lm'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
development: &pgsql
|
2
2
|
adapter: postgresql
|
3
|
-
database: metasploit-
|
3
|
+
database: metasploit-credential_development2
|
4
4
|
username: msf
|
5
5
|
password: pass123
|
6
6
|
host: localhost
|
@@ -10,4 +10,4 @@ development: &pgsql
|
|
10
10
|
min_messages: warning
|
11
11
|
test:
|
12
12
|
<<: *pgsql
|
13
|
-
database: metasploit-
|
13
|
+
database: metasploit-credential_test2
|
@@ -62,7 +62,8 @@ FactoryBot.define do
|
|
62
62
|
:metasploit_credential_password,
|
63
63
|
:metasploit_credential_nonreplayable_hash,
|
64
64
|
:metasploit_credential_ntlm_hash,
|
65
|
-
:metasploit_credential_ssh_key
|
65
|
+
:metasploit_credential_ssh_key,
|
66
|
+
:metasploit_credential_krb_enc_key
|
66
67
|
]
|
67
68
|
sequence :metasploit_credential_core_private_factory, metasploit_credential_core_private_factories.cycle
|
68
69
|
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
|
3
|
+
FactoryBot.define do
|
4
|
+
klass = Metasploit::Credential::KrbEncKey
|
5
|
+
|
6
|
+
factory :metasploit_credential_krb_enc_key,
|
7
|
+
class: klass,
|
8
|
+
parent: :metasploit_credential_password_hash do
|
9
|
+
|
10
|
+
# By default - use the with_rc4 trait for performance reasons
|
11
|
+
with_rc4
|
12
|
+
|
13
|
+
trait :with_rc4 do
|
14
|
+
data { generate(:metasploit_credential_krb_enc_key_rc4) }
|
15
|
+
end
|
16
|
+
|
17
|
+
trait :with_aes128 do
|
18
|
+
data { generate(:metasploit_credential_krb_enc_key_aes128) }
|
19
|
+
end
|
20
|
+
|
21
|
+
trait :with_aes256 do
|
22
|
+
data { generate(:metasploit_credential_krb_enc_key_aes256) }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
sequence :metasploit_credential_krb_enc_key_rc4 do |n|
|
27
|
+
salt = nil
|
28
|
+
password = "password#{n}"
|
29
|
+
unicode_password = password.encode('utf-16le')
|
30
|
+
key = OpenSSL::Digest.digest('MD4', unicode_password)
|
31
|
+
enctype = 23
|
32
|
+
|
33
|
+
klass.build_data(enctype: enctype, key: key, salt: salt)
|
34
|
+
end
|
35
|
+
|
36
|
+
sequence :metasploit_credential_krb_enc_key_aes128 do |n|
|
37
|
+
salt = "DOMAIN.LOCALUserAccount#{n}"
|
38
|
+
password = "password#{n}"
|
39
|
+
key = aes_cts_hmac_sha1_96('128-CBC', password, salt)
|
40
|
+
enctype = 17
|
41
|
+
|
42
|
+
klass.build_data(enctype: enctype, key: key, salt: salt)
|
43
|
+
end
|
44
|
+
|
45
|
+
sequence :metasploit_credential_krb_enc_key_aes256 do |n|
|
46
|
+
salt = "DOMAIN.LOCALUserAccount#{n}"
|
47
|
+
password = "password#{n}"
|
48
|
+
enctype = 18
|
49
|
+
key = aes_cts_hmac_sha1_96('256-CBC', password, salt)
|
50
|
+
|
51
|
+
klass.build_data(enctype: enctype, key: key, salt: salt)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Encrypt using MIT Kerberos aesXXX-cts-hmac-sha1-96
|
55
|
+
# http://web.mit.edu/kerberos/krb5-latest/doc/admin/enctypes.html?highlight=des#enctype-compatibility
|
56
|
+
#
|
57
|
+
# @param algorithm [String] The AES algorithm to use (e.g. `128-CBC` or `256-CBC`)
|
58
|
+
# @param raw_secret [String] The data to encrypt
|
59
|
+
# @param salt [String] The salt used by the encryption algorithm
|
60
|
+
# @return [String, nil] The encrypted data
|
61
|
+
def aes_cts_hmac_sha1_96(algorithm, raw_secret, salt)
|
62
|
+
iterations = 4096
|
63
|
+
cipher = OpenSSL::Cipher::AES.new(algorithm)
|
64
|
+
key = OpenSSL::PKCS5.pbkdf2_hmac_sha1(raw_secret, salt, iterations, cipher.key_len)
|
65
|
+
plaintext = "kerberos\x7B\x9B\x5B\x2B\x93\x13\x2B\x93".b
|
66
|
+
result = ''.b
|
67
|
+
loop do
|
68
|
+
cipher.reset
|
69
|
+
cipher.encrypt
|
70
|
+
cipher.iv = "\x00".b * 16
|
71
|
+
cipher.key = key
|
72
|
+
ciphertext = cipher.update(plaintext)
|
73
|
+
result += ciphertext
|
74
|
+
break unless result.size < cipher.key_len
|
75
|
+
|
76
|
+
plaintext = ciphertext
|
77
|
+
end
|
78
|
+
result
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
@@ -811,6 +811,16 @@ RSpec.describe Metasploit::Credential::Creation do
|
|
811
811
|
expect(test_object.create_credential_private(opts)).to be_kind_of Metasploit::Credential::BlankPassword
|
812
812
|
end
|
813
813
|
end
|
814
|
+
|
815
|
+
context 'when :private_type is krb_enc_key' do
|
816
|
+
it 'creates a Metasploit::Credential::KrbEncKey' do
|
817
|
+
opts = {
|
818
|
+
private_data: FactoryBot.generate(:metasploit_credential_krb_enc_key_aes256),
|
819
|
+
private_type: :krb_enc_key
|
820
|
+
}
|
821
|
+
expect{ test_object.create_credential_private(opts) }.to change{ Metasploit::Credential::KrbEncKey.count }.by(1)
|
822
|
+
end
|
823
|
+
end
|
814
824
|
end
|
815
825
|
|
816
826
|
context '#create_credential_core' do
|
@@ -0,0 +1,151 @@
|
|
1
|
+
RSpec.shared_examples_for 'a KrbEncKey' do |expected:|
|
2
|
+
describe '#enctype' do
|
3
|
+
it 'has an enctype' do
|
4
|
+
expect(subject.enctype).to eq(expected[:enctype])
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '#key' do
|
9
|
+
it 'has a key' do
|
10
|
+
expect(subject.key.length).to eq(expected[:key_length])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#salt' do
|
15
|
+
it 'has a salt' do
|
16
|
+
expect(subject.salt).to match(expected[:salt])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#to_s' do
|
21
|
+
it 'has a human readable to_s' do
|
22
|
+
expect(subject.to_s).to match expected[:to_s]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
RSpec.describe Metasploit::Credential::KrbEncKey, type: :model do
|
28
|
+
it_should_behave_like 'Metasploit::Concern.run'
|
29
|
+
|
30
|
+
it { is_expected.to be_a Metasploit::Credential::PasswordHash }
|
31
|
+
|
32
|
+
context 'factories' do
|
33
|
+
context 'metasploit_credential_krb_enc_key' do
|
34
|
+
subject(:metasploit_credential_krb_enc_key) do
|
35
|
+
FactoryBot.build(:metasploit_credential_krb_enc_key)
|
36
|
+
end
|
37
|
+
|
38
|
+
it { is_expected.to be_valid }
|
39
|
+
end
|
40
|
+
|
41
|
+
FactoryBot.factories[:metasploit_credential_krb_enc_key].defined_traits.each do |trait|
|
42
|
+
context "with #{trait}" do
|
43
|
+
subject(:metasploit_credential_krb_enc_key) do
|
44
|
+
FactoryBot.build(:metasploit_credential_krb_enc_key, trait.name)
|
45
|
+
end
|
46
|
+
|
47
|
+
it { is_expected.to be_valid }
|
48
|
+
it { expect(subject.data).to be_a(String) }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'when the krb enc key is rc4' do
|
54
|
+
subject :krb_enc_key_rc4 do
|
55
|
+
FactoryBot.build(:metasploit_credential_krb_enc_key, :with_rc4)
|
56
|
+
end
|
57
|
+
|
58
|
+
it_behaves_like 'a KrbEncKey',
|
59
|
+
expected: {
|
60
|
+
enctype: 23,
|
61
|
+
key_length: 16,
|
62
|
+
salt: nil,
|
63
|
+
to_s: /rc4-hmac:\w{32}/
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'when the krb enc key is aes128' do
|
68
|
+
subject :krb_enc_key_aes256 do
|
69
|
+
FactoryBot.build(:metasploit_credential_krb_enc_key, :with_aes128)
|
70
|
+
end
|
71
|
+
|
72
|
+
it_behaves_like 'a KrbEncKey',
|
73
|
+
expected: {
|
74
|
+
enctype: 17,
|
75
|
+
key_length: 16,
|
76
|
+
salt: /DOMAIN.LOCALUserAccount\d+/,
|
77
|
+
to_s: /aes128-cts-hmac-sha1-96:\w{32}/
|
78
|
+
}
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'when the krb enc key is aes128' do
|
82
|
+
subject :krb_enc_key_aes256 do
|
83
|
+
FactoryBot.build(:metasploit_credential_krb_enc_key, :with_aes256)
|
84
|
+
end
|
85
|
+
|
86
|
+
it_behaves_like 'a KrbEncKey',
|
87
|
+
expected: {
|
88
|
+
enctype: 18,
|
89
|
+
key_length: 32,
|
90
|
+
salt: /DOMAIN.LOCALUserAccount\d+/,
|
91
|
+
to_s: /aes256-cts-hmac-sha1-96:\w{64}/
|
92
|
+
}
|
93
|
+
end
|
94
|
+
|
95
|
+
context 'when the krb enc key is not a known enctype' do
|
96
|
+
subject :krb_enc_key_aes256 do
|
97
|
+
FactoryBot.build(:metasploit_credential_krb_enc_key, data: described_class.build_data(enctype: 1024, key: "abc"))
|
98
|
+
end
|
99
|
+
|
100
|
+
it_behaves_like 'a KrbEncKey',
|
101
|
+
expected: {
|
102
|
+
enctype: 1024,
|
103
|
+
key_length: 3,
|
104
|
+
salt: nil,
|
105
|
+
to_s: 'unassigned-1024:616263'
|
106
|
+
}
|
107
|
+
end
|
108
|
+
|
109
|
+
context 'validations' do
|
110
|
+
context '#data' do
|
111
|
+
subject(:data_errors) do
|
112
|
+
krb_enc_key.errors[:data]
|
113
|
+
end
|
114
|
+
|
115
|
+
#
|
116
|
+
# lets
|
117
|
+
#
|
118
|
+
|
119
|
+
let(:data) do
|
120
|
+
FactoryBot.generate(:metasploit_credential_krb_enc_key_aes256)
|
121
|
+
end
|
122
|
+
|
123
|
+
let(:krb_enc_key) do
|
124
|
+
FactoryBot.build(
|
125
|
+
:metasploit_credential_krb_enc_key,
|
126
|
+
data: data
|
127
|
+
)
|
128
|
+
end
|
129
|
+
|
130
|
+
#
|
131
|
+
# Callbacks
|
132
|
+
#
|
133
|
+
|
134
|
+
before(:example) do
|
135
|
+
krb_enc_key.valid?
|
136
|
+
end
|
137
|
+
|
138
|
+
context 'when the data is valid' do
|
139
|
+
it { is_expected.to be_empty }
|
140
|
+
end
|
141
|
+
|
142
|
+
context "when the data is invalid" do
|
143
|
+
let(:data) do
|
144
|
+
"foo"
|
145
|
+
end
|
146
|
+
|
147
|
+
it { is_expected.to include("is not in the KrbEncKey data format of 'msf_krbenckey:<ENCTYPE>:<KEY>:<SALT>', where the key and salt are in hexadecimal characters") }
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metasploit-credential
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.
|
4
|
+
version: 6.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Metasploit Hackers
|
@@ -93,7 +93,7 @@ cert_chain:
|
|
93
93
|
EknWpNgVhohbot1lfVAMmIhdtOVaRVcQQixWPwprDj/ydB8ryDMDosIMcw+fkoXU
|
94
94
|
9GJsSaSRRYQ9UUkVL27b64okU8D48m8=
|
95
95
|
-----END CERTIFICATE-----
|
96
|
-
date:
|
96
|
+
date: 2023-01-31 00:00:00.000000000 Z
|
97
97
|
dependencies:
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: metasploit-concern
|
@@ -244,6 +244,7 @@ files:
|
|
244
244
|
- app/models/metasploit/credential/blank_password.rb
|
245
245
|
- app/models/metasploit/credential/blank_username.rb
|
246
246
|
- app/models/metasploit/credential/core.rb
|
247
|
+
- app/models/metasploit/credential/krb_enc_key.rb
|
247
248
|
- app/models/metasploit/credential/login.rb
|
248
249
|
- app/models/metasploit/credential/nonreplayable_hash.rb
|
249
250
|
- app/models/metasploit/credential/ntlm_hash.rb
|
@@ -355,6 +356,7 @@ files:
|
|
355
356
|
- spec/factories/metasploit/credential/importer/cores.rb
|
356
357
|
- spec/factories/metasploit/credential/importer/pwdumps.rb
|
357
358
|
- spec/factories/metasploit/credential/importer/zips.rb
|
359
|
+
- spec/factories/metasploit/credential/krb_enc_key.rb
|
358
360
|
- spec/factories/metasploit/credential/logins.rb
|
359
361
|
- spec/factories/metasploit/credential/nonreplayable_hashes.rb
|
360
362
|
- spec/factories/metasploit/credential/ntlm_hashes.rb
|
@@ -387,6 +389,7 @@ files:
|
|
387
389
|
- spec/models/mdm/workspace_spec.rb
|
388
390
|
- spec/models/metasploit/credential/blank_username_spec.rb
|
389
391
|
- spec/models/metasploit/credential/core_spec.rb
|
392
|
+
- spec/models/metasploit/credential/krb_enc_key_spec.rb
|
390
393
|
- spec/models/metasploit/credential/login/status_spec.rb
|
391
394
|
- spec/models/metasploit/credential/login_spec.rb
|
392
395
|
- spec/models/metasploit/credential/nonreplayable_hash_spec.rb
|
@@ -484,6 +487,7 @@ test_files:
|
|
484
487
|
- spec/factories/metasploit/credential/importer/cores.rb
|
485
488
|
- spec/factories/metasploit/credential/importer/pwdumps.rb
|
486
489
|
- spec/factories/metasploit/credential/importer/zips.rb
|
490
|
+
- spec/factories/metasploit/credential/krb_enc_key.rb
|
487
491
|
- spec/factories/metasploit/credential/logins.rb
|
488
492
|
- spec/factories/metasploit/credential/nonreplayable_hashes.rb
|
489
493
|
- spec/factories/metasploit/credential/ntlm_hashes.rb
|
@@ -516,6 +520,7 @@ test_files:
|
|
516
520
|
- spec/models/mdm/workspace_spec.rb
|
517
521
|
- spec/models/metasploit/credential/blank_username_spec.rb
|
518
522
|
- spec/models/metasploit/credential/core_spec.rb
|
523
|
+
- spec/models/metasploit/credential/krb_enc_key_spec.rb
|
519
524
|
- spec/models/metasploit/credential/login/status_spec.rb
|
520
525
|
- spec/models/metasploit/credential/login_spec.rb
|
521
526
|
- spec/models/metasploit/credential/nonreplayable_hash_spec.rb
|
metadata.gz.sig
CHANGED
Binary file
|