Class: Rex::Proto::Kerberos::Model::EncKrbCredPart

Inherits:
Element
  • Object
show all
Defined in:
lib/rex/proto/kerberos/model/enc_krb_cred_part.rb

Overview

This class provides a representation of an EncKrbCredPart, sent as the encrypted part of a KRB-CRED

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

Instance Method Summary collapse

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

#ticket-infoArray<Rex::Proto::Kerberos::Model::KrbCredInfo>

Returns The information corresponding to tickets in a KrbCred object.

Returns:



12
# File 'lib/rex/proto/kerberos/model/enc_krb_cred_part.rb', line 12

attr_accessor :ticket_info

#ticket_infoObject

Returns the value of attribute ticket_info.



12
13
14
# File 'lib/rex/proto/kerberos/model/enc_krb_cred_part.rb', line 12

def ticket_info
  @ticket_info
end

Instance Method Details

#decode(input) ⇒ self

Decodes the Rex::Proto::Kerberos::Model::EncKrbCredPart from an input

Parameters:

  • input (String, OpenSSL::ASN1::ASN1Data)

    the input to decode from

Returns:

  • (self)

    if decoding succeeds

Raises:



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rex/proto/kerberos/model/enc_krb_cred_part.rb', line 19

def decode(input)
  case input
  when String
    decode_string(input)
  when OpenSSL::ASN1::ASN1Data
    decode_asn1(input)
  else
    raise ::Rex::Proto::Kerberos::Model::Error::KerberosDecodingError, 'Failed to decode EncKrbCredPart, invalid input'
  end

  self
end

#encodeString

Encodes the Rex::Proto::Kerberos::Model::EncApRepPart into an ASN.1 String

Returns:

  • (String)


45
46
47
48
49
50
51
52
# File 'lib/rex/proto/kerberos/model/enc_krb_cred_part.rb', line 45

def encode
  elems = []
  elems << OpenSSL::ASN1::ASN1Data.new([encode_ticket_info], 0, :CONTEXT_SPECIFIC)
  seq = OpenSSL::ASN1::Sequence.new(elems)
  seq_asn1 = OpenSSL::ASN1::ASN1Data.new([seq], ENC_KRB_CRED_PART, :APPLICATION)

  seq_asn1.to_der
end

#encrypt(key) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/rex/proto/kerberos/model/enc_krb_cred_part.rb', line 32

def encrypt(key)
  encryptor = Rex::Proto::Kerberos::Crypto::Encryption.from_etype(key.type)
  data = encryptor.encrypt(encode, key.value, Rex::Proto::Kerberos::Crypto::KeyUsage::KRB_CRED_ENCPART)

  result = Rex::Proto::Kerberos::Model::EncryptedData.new(
    etype: key.type,
    cipher: data
  )
end