2014-12-18 23:40:06 +00:00
|
|
|
# -*- coding: binary -*-
|
|
|
|
|
2014-12-18 05:16:58 +00:00
|
|
|
module Rex
|
|
|
|
module Proto
|
|
|
|
module Kerberos
|
|
|
|
module CredentialCache
|
2014-12-18 23:12:58 +00:00
|
|
|
|
|
|
|
# This class provides a representation of a credential keys stored in the Kerberos Credential Cache.
|
2014-12-18 06:30:47 +00:00
|
|
|
class KeyBlock < Element
|
2014-12-18 23:12:58 +00:00
|
|
|
# @!attribute key_type
|
|
|
|
# @return [Fixnum]
|
2014-12-18 06:30:47 +00:00
|
|
|
attr_accessor :key_type
|
2014-12-18 23:12:58 +00:00
|
|
|
# @!attribute e_type
|
|
|
|
# @return [Fixnum]
|
2014-12-18 06:30:47 +00:00
|
|
|
attr_accessor :e_type
|
2014-12-18 23:12:58 +00:00
|
|
|
# @!attribute key_value
|
|
|
|
# @return [String]
|
2014-12-18 06:30:47 +00:00
|
|
|
attr_accessor :key_value
|
|
|
|
|
2014-12-18 23:12:58 +00:00
|
|
|
# Encodes the Rex::Proto::Kerberos::CredentialCache::KeyBlock into an String
|
|
|
|
#
|
|
|
|
# @return [String] encoded key
|
2014-12-18 06:30:47 +00:00
|
|
|
def encode
|
|
|
|
encoded = ''
|
|
|
|
encoded << encode_key_type
|
|
|
|
encoded << encode_e_type
|
|
|
|
encoded << encode_key_value
|
|
|
|
|
|
|
|
encoded
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2014-12-18 23:12:58 +00:00
|
|
|
# Encodes the key_type field
|
|
|
|
#
|
|
|
|
# @return [String]
|
2014-12-18 06:30:47 +00:00
|
|
|
def encode_key_type
|
|
|
|
[key_type].pack('n')
|
|
|
|
end
|
|
|
|
|
2014-12-18 23:12:58 +00:00
|
|
|
# Encodes the e_type field
|
|
|
|
#
|
|
|
|
# @return [String]
|
2014-12-18 06:30:47 +00:00
|
|
|
def encode_e_type
|
|
|
|
[e_type].pack('n')
|
|
|
|
end
|
|
|
|
|
2014-12-18 23:12:58 +00:00
|
|
|
# Encodes the key_value field
|
|
|
|
#
|
|
|
|
# @return [String]
|
2014-12-18 06:30:47 +00:00
|
|
|
def encode_key_value
|
|
|
|
encoded = ''
|
|
|
|
encoded << [key_value.length].pack('n')
|
|
|
|
encoded << key_value
|
|
|
|
|
|
|
|
encoded
|
|
|
|
end
|
2014-12-18 05:16:58 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|