2014-12-18 05:16:58 +00:00
|
|
|
module Rex
|
|
|
|
module Proto
|
|
|
|
module Kerberos
|
|
|
|
module CredentialCache
|
2014-12-18 06:30:47 +00:00
|
|
|
=begin
|
|
|
|
uint32_t name_type; /* not present if version 0x0501 */
|
|
|
|
uint32_t num_components; /* sub 1 if version 0x501 */
|
|
|
|
counted_octet_string realm;
|
|
|
|
counted_octet_string components[num_components];
|
|
|
|
=end
|
|
|
|
class Principal < Element
|
|
|
|
# Fixnum
|
|
|
|
attr_accessor :name_type
|
|
|
|
# String
|
|
|
|
attr_accessor :realm
|
|
|
|
# Array<String>
|
|
|
|
attr_accessor :components
|
|
|
|
|
|
|
|
|
|
|
|
def encode
|
|
|
|
encoded = ''
|
|
|
|
encoded << encode_name_type
|
2014-12-18 22:31:46 +00:00
|
|
|
encoded << [components.length].pack('N')
|
2014-12-18 06:30:47 +00:00
|
|
|
encoded << encode_realm
|
|
|
|
encoded << encode_components
|
|
|
|
|
|
|
|
encoded
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def encode_name_type
|
|
|
|
#NT_PRINCIPAL = 1
|
2014-12-18 22:31:46 +00:00
|
|
|
[name_type].pack('N')
|
2014-12-18 06:30:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def encode_realm
|
2014-12-18 22:31:46 +00:00
|
|
|
encoded = ''
|
|
|
|
encoded << [realm.length].pack('N')
|
2014-12-18 06:30:47 +00:00
|
|
|
encoded << realm
|
2014-12-18 22:31:46 +00:00
|
|
|
|
|
|
|
encoded
|
2014-12-18 06:30:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def encode_components
|
|
|
|
encoded = ''
|
|
|
|
|
|
|
|
components.each do |c|
|
2014-12-18 22:31:46 +00:00
|
|
|
encoded << [c.length].pack('N')
|
2014-12-18 06:30:47 +00:00
|
|
|
encoded << c
|
|
|
|
end
|
|
|
|
|
|
|
|
encoded
|
|
|
|
end
|
|
|
|
|
2014-12-18 05:16:58 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|