Class: Metasploit::Credential::KrbEncKey

Inherits:
PasswordHash show all
Defined in:
app/models/metasploit/credential/krb_enc_key.rb

Overview

A password hash that cannot be replayed to authenticate to other services. #data is a string in the format ‘’msf_krbenckey:<enctype digits>:<key hexadecimal>:<salt hexadecimal>‘`.

This class contains information relevant to a Kerberos EncryptionKey www.rfc-editor.org/rfc/rfc4120.html#section-5.2.9 which is used to encrypt/decrypt arbitrary Kerberos protocol message data - such as the AS-REP krbtgt ticket and enc-part.

Instance Attribute Summary collapse

Attributes inherited from Private

#cores, #created_at, #id, #type, #updated_at

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataHash{Symbol => String}

Returns:

  • (Hash{Symbol => String})


# File 'app/models/metasploit/credential/krb_enc_key.rb', line 68

Class Method Details

.build_data(enctype:, key:, salt: nil) ⇒ String

Parameters:

  • enctype (Integer)

    The enctype

  • key (String)

    The key bytes

  • salt (String, nil) (defaults to: nil)

    The salt

Returns:

  • (String)

Raises:

  • (ArgumentError)

    if an option is invalid



99
100
101
102
103
104
# File 'app/models/metasploit/credential/krb_enc_key.rb', line 99

def self.build_data(enctype:, key:, salt: nil)
  raise ArgumentError('enctype must be numeric') unless enctype.is_a?(Numeric)
  raise ArgumentError('key must be set') if key.nil?

  "msf_krbenckey:#{enctype}:#{as_hex(key)}:#{as_hex(salt)}"
end

Instance Method Details

#enctypeInteger

Returns:

  • (Integer)


113
114
115
# File 'app/models/metasploit/credential/krb_enc_key.rb', line 113

def enctype
  parsed_data[:enctype]
end

#keyString

The key

Returns:

  • (String)


120
121
122
# File 'app/models/metasploit/credential/krb_enc_key.rb', line 120

def key
  parsed_data[:key]
end

#saltString?

The salt used as part of creating the key. This is normally derived from the Kerberos principal name/Realm. For windows the following convention is used to create the salt: learn.microsoft.com/en-us/openspecs/windows_protocols/ms-kile/7a7b081d-c0c6-46f4-acbf-a439664270b8

This value can be nil if the salt is not known

Returns:

  • (String, nil)

    The key salt if available



130
131
132
# File 'app/models/metasploit/credential/krb_enc_key.rb', line 130

def salt
  parsed_data[:salt]
end

#to_sString

A string suitable for displaying to the user

Returns:

  • (String)


137
138
139
# File 'app/models/metasploit/credential/krb_enc_key.rb', line 137

def to_s
  "#{ENCTYPE_NAMES[enctype]}:#{self.class.as_hex(key)}#{salt ? ":#{self.class.as_hex(salt)}" : ''}"
end