Class: Rex::Proto::Kerberos::Model::KrbCred
- Defined in:
- lib/rex/proto/kerberos/model/krb_cred.rb
Overview
This class provides a representation of a Kerberos KRB-CRED message definition.
Constant Summary
Constants included from Rex::Proto::Kerberos::Model
AP_REP, AP_REQ, AS_REP, AS_REQ, AUTHENTICATOR, ENC_AP_REP_PART, ENC_KRB_CRED_PART, KRB_CRED, KRB_ERROR, TGS_REP, TGS_REQ, TICKET, VERSION
Instance Attribute Summary collapse
-
#enc_part ⇒ Rex::Proto::Kerberos::Model::EncryptedData
Encrypted KRB-CRED blob.
-
#msg_type ⇒ Integer
The type of a protocol message.
-
#pvno ⇒ Integer
The protocol version number.
-
#tickets ⇒ Array<Rex::Proto::Kerberos::Model::Ticket>
Tickets encapsulated in this message.
Class Method Summary collapse
-
.load_credential_from_file(file_path) ⇒ Rex::Proto::Kerberos::Model::KrbCred
Loads a KrbCred from a kirbi file.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#decode(input) ⇒ self
Decodes the Rex::Proto::Kerberos::Model::KrbCred from an input.
-
#encode ⇒ Object
Rex::Proto::Kerberos::Model::KrbCred encoding isn’t supported.
-
#save_credential_to_file(file_path) ⇒ Integer
Saves a KrbCred to a kirbi file.
Methods inherited from Element
attr_accessor, attributes, #attributes, decode, #initialize
Constructor Details
This class inherits a constructor from Rex::Proto::Kerberos::Model::Element
Instance Attribute Details
#enc_part ⇒ Rex::Proto::Kerberos::Model::EncryptedData
Returns Encrypted KRB-CRED blob.
21 22 23 |
# File 'lib/rex/proto/kerberos/model/krb_cred.rb', line 21 def enc_part @enc_part end |
#msg_type ⇒ Integer
Returns The type of a protocol message.
15 16 17 |
# File 'lib/rex/proto/kerberos/model/krb_cred.rb', line 15 def msg_type @msg_type end |
#pvno ⇒ Integer
Returns The protocol version number.
12 13 14 |
# File 'lib/rex/proto/kerberos/model/krb_cred.rb', line 12 def pvno @pvno end |
#tickets ⇒ Array<Rex::Proto::Kerberos::Model::Ticket>
Returns Tickets encapsulated in this message.
18 19 20 |
# File 'lib/rex/proto/kerberos/model/krb_cred.rb', line 18 def tickets @tickets end |
Class Method Details
.load_credential_from_file(file_path) ⇒ Rex::Proto::Kerberos::Model::KrbCred
Loads a KrbCred from a kirbi file
67 68 69 70 71 72 73 |
# File 'lib/rex/proto/kerberos/model/krb_cred.rb', line 67 def self.load_credential_from_file(file_path) unless File.readable?(file_path.to_s) raise ::ArgumentError, "Failed to load kirbi file '#{file_path}'" end decode(File.binread(file_path)) end |
Instance Method Details
#==(other) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/rex/proto/kerberos/model/krb_cred.rb', line 23 def ==(other) pvno == other.pvno && msg_type == other.msg_type && tickets == other.tickets && enc_part == other.enc_part end |
#decode(input) ⇒ self
Decodes the Rex::Proto::Kerberos::Model::KrbCred from an input
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rex/proto/kerberos/model/krb_cred.rb', line 35 def decode(input) case input when String decode_string(input) when OpenSSL::ASN1::Sequence decode_asn1(input) else raise ::Rex::Proto::Kerberos::Model::Error::KerberosDecodingError, 'Failed to decode KrbCred, invalid input' end self end |
#encode ⇒ Object
Rex::Proto::Kerberos::Model::KrbCred encoding isn’t supported
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rex/proto/kerberos/model/krb_cred.rb', line 51 def encode elems = [] elems << OpenSSL::ASN1::ASN1Data.new([encode_pvno], 0, :CONTEXT_SPECIFIC) elems << OpenSSL::ASN1::ASN1Data.new([encode_msg_type], 1, :CONTEXT_SPECIFIC) elems << OpenSSL::ASN1::ASN1Data.new([encode_tickets], 2, :CONTEXT_SPECIFIC) elems << OpenSSL::ASN1::ASN1Data.new([encode_enc_part], 3, :CONTEXT_SPECIFIC) seq = OpenSSL::ASN1::Sequence.new(elems) seq_asn1 = OpenSSL::ASN1::ASN1Data.new([seq], KRB_CRED, :APPLICATION) seq_asn1.to_der end |
#save_credential_to_file(file_path) ⇒ Integer
Saves a KrbCred to a kirbi file
78 79 80 |
# File 'lib/rex/proto/kerberos/model/krb_cred.rb', line 78 def save_credential_to_file(file_path) File.binwrite(file_path, encode) end |