Class: Rex::Proto::Kerberos::Model::PreAuthDataEntry

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

Overview

This class provides a representation for Kerberos pre authenticated data entry.

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

#typeInteger

Returns The padata type.

Returns:

  • (Integer)

    The padata type



13
14
15
# File 'lib/rex/proto/kerberos/model/pre_auth_data_entry.rb', line 13

def type
  @type
end

#valueString

Returns The padata value, encoded.

Returns:

  • (String)

    The padata value, encoded



16
17
18
# File 'lib/rex/proto/kerberos/model/pre_auth_data_entry.rb', line 16

def value
  @value
end

Instance Method Details

#decode(input) ⇒ self

Decodes a Rex::Proto::Kerberos::Model::PreAuthDataEntry

Parameters:

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

    the input to decode from

Returns:

  • (self)

    if decoding succeeds

Raises:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rex/proto/kerberos/model/pre_auth_data_entry.rb', line 23

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

  self
end

#decoded_valueObject

Gets the value of this PreAuthDataEntry as its instantiated object, based on the type

Returns:

  • (Object)

    e.g. PreAuthEncTimeStamp, PreAuthEtypeInfo2



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/rex/proto/kerberos/model/pre_auth_data_entry.rb', line 53

def decoded_value
  case self.type
  when Rex::Proto::Kerberos::Model::PreAuthType::PA_TGS_REQ
    decoded = OpenSSL::ASN1.decode(self.value)
    ApReq.decode(decoded)
  when Rex::Proto::Kerberos::Model::PreAuthType::PA_ENC_TIMESTAMP
    decoded = OpenSSL::ASN1.decode(self.value)
    PreAuthEncTimeStamp.decode(decoded)
  when Rex::Proto::Kerberos::Model::PreAuthType::PA_PW_SALT
    # This is not DER_encoded - just pass the string directly
    PreAuthPwSalt.decode(self.value)
  when Rex::Proto::Kerberos::Model::PreAuthType::PA_ETYPE_INFO
    # Not yet supported
  when Rex::Proto::Kerberos::Model::PreAuthType::PA_PK_AS_REQ
     PreAuthPkAsReq.decode(self.value)
  when Rex::Proto::Kerberos::Model::PreAuthType::PA_PK_AS_REP
     PreAuthPkAsRep.decode(self.value)
  when Rex::Proto::Kerberos::Model::PreAuthType::PA_ETYPE_INFO2
    decoded = OpenSSL::ASN1.decode(self.value)
    PreAuthEtypeInfo2.decode(decoded)
  when Rex::Proto::Kerberos::Model::PreAuthType::PA_PAC_REQUEST
    decoded = OpenSSL::ASN1.decode(self.value)
    PreAuthPacRequest.decode(decoded)
  when Rex::Proto::Kerberos::Model::PreAuthType::PA_FOR_USER
    decoded = OpenSSL::ASN1.decode(self.value)
    PreAuthForUser.decode(decoded)
  else
    # Unknown type - just ignore for now
  end
end

#encodeString

Encodes a Rex::Proto::Kerberos::Model::PreAuthDataEntry into an ASN.1 String

Returns:

  • (String)


41
42
43
44
45
46
47
# File 'lib/rex/proto/kerberos/model/pre_auth_data_entry.rb', line 41

def encode
  type_asn1 = OpenSSL::ASN1::ASN1Data.new([encode_type], 1, :CONTEXT_SPECIFIC)
  value_asn1 = OpenSSL::ASN1::ASN1Data.new([encode_value], 2, :CONTEXT_SPECIFIC)
  seq = OpenSSL::ASN1::Sequence.new([type_asn1, value_asn1])

  seq.to_der
end