class Rex::Proto::Kerberos::Model::EncKdcResponse

Attributes

auth_time[RW]

@!attribute auth_time

@return [Time] the time of initial authentication for the named principal
end_time[RW]

@!attribute end_time

@return [Time] This field contains the time after which the ticket will
not be honored (its expiration time)
flags[RW]

@!attribute flags

@return [Fixnum] This field indicates which of various options were used or
requested when the ticket was issued
key[RW]

@!attribute key

@return [Rex::Proto::Kerberos::Model::EncryptionKey] The session key
key_expiration[RW]

@!attribute key_expiration

@return [Time] The key-expiration field is part of the response from the
KDC and specifies the time that the client's secret key is due to expire
last_req[RW]

@!attribute last_req

@return [Array<Rex::Proto::Kerberos::Model::LastRequest>] This field is returned by the KDC and specifies the time(s)
of the last request by a principal
nonce[RW]

@!attribute nonce

@return [Fixnum] random number
renew_till[RW]

@!attribute renew_till

@return [Time] This field is only present in tickets that have the
RENEWABLE flag set in the flags field.  It indicates the maximum
endtime that may be included in a renewal
sname[RW]

@!attribute sname

@return [Rex::Proto::Kerberos::Model::PrincipalName] The name part of the server's identity
srealm[RW]

@!attribute srealm

@return [String] The realm part of the server's principal identifier
start_time[RW]

@!attribute start_time

@return [Time] Specifies the time after which the ticket is valid

Public Instance Methods

decode(input) click to toggle source

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

@param input [String, OpenSSL::ASN1::ASN1Data] the input to decode from @return [self] if decoding succeeds @raise [RuntimeError] if decoding doesn't succeed

# File lib/rex/proto/kerberos/model/enc_kdc_response.rb, line 52
def decode(input)
  case input
  when String
    decode_string(input)
  when OpenSSL::ASN1::ASN1Data
    decode_asn1(input)
  else
    raise ::RuntimeError, 'Failed to decode EncKdcResponse, invalid input'
  end

  self
end
encode() click to toggle source

Rex::Proto::Kerberos::Model::EncKdcResponse encoding isn't supported

@raise [NotImplementedError]

# File lib/rex/proto/kerberos/model/enc_kdc_response.rb, line 68
def encode
  raise ::NotImplementedError, 'EncKdcResponse encoding not supported'
end

Private Instance Methods

decode_asn1(input) click to toggle source

Decodes a Rex::Proto::Kerberos::Model::EncKdcResponse

@param input [OpenSSL::ASN1::ASN1Data] the input to decode from @raise [RuntimeError] if decoding doesn't succeed

# File lib/rex/proto/kerberos/model/enc_kdc_response.rb, line 87
def decode_asn1(input)
  input.value[0].value.each do |val|
    case val.tag
    when 0
      self.key = decode_key(val)
    when 1
      self.last_req = decode_last_req(val)
    when 2
      self.nonce = decode_nonce(val)
    when 3
      self.key_expiration = decode_key_expiration(val)
    when 4
      self.flags = decode_flags(val)
    when 5
      self.auth_time = decode_auth_time(val)
    when 6
      self.start_time = decode_start_time(val)
    when 7
      self.end_time = decode_end_time(val)
    when 8
      self.renew_till = decode_renew_till(val)
    when 9
      self.srealm = decode_srealm(val)
    when 10
      self.sname = decode_sname(val)
    else
      raise ::RuntimeError, 'Failed to decode ENC-KDC-RESPONSE SEQUENCE'
    end
  end
end
decode_auth_time(input) click to toggle source

Decodes the auth_time field

@param input [OpenSSL::ASN1::ASN1Data] the input to decode from @return [Time]

# File lib/rex/proto/kerberos/model/enc_kdc_response.rb, line 167
def decode_auth_time(input)
  input.value[0].value
end
decode_end_time(input) click to toggle source

Decodes the end_time field

@param input [OpenSSL::ASN1::ASN1Data] the input to decode from @return [Time]

# File lib/rex/proto/kerberos/model/enc_kdc_response.rb, line 183
def decode_end_time(input)
  input.value[0].value
end
decode_flags(input) click to toggle source

Decodes the flags field

@param input [OpenSSL::ASN1::ASN1Data] the input to decode from @return [Fixnum]

# File lib/rex/proto/kerberos/model/enc_kdc_response.rb, line 159
def decode_flags(input)
  input.value[0].value.to_i
end
decode_key(input) click to toggle source

Decodes the key from an OpenSSL::ASN1::ASN1Data

@param input [OpenSSL::ASN1::ASN1Data] the input to decode from @return [EncryptionKey]

# File lib/rex/proto/kerberos/model/enc_kdc_response.rb, line 122
def decode_key(input)
  Rex::Proto::Kerberos::Model::EncryptionKey.decode(input.value[0])
end
decode_key_expiration(input) click to toggle source

Decodes the key_expiration field

@param input [OpenSSL::ASN1::ASN1Data] the input to decode from @return [Time]

# File lib/rex/proto/kerberos/model/enc_kdc_response.rb, line 151
def decode_key_expiration(input)
  input.value[0].value
end
decode_last_req(input) click to toggle source

Decodes the last_req from an OpenSSL::ASN1::ASN1Data

@param input [OpenSSL::ASN1::ASN1Data] the input to decode from @return [Array<Rex::Proto::Kerberos::Model::LastRequest>]

# File lib/rex/proto/kerberos/model/enc_kdc_response.rb, line 130
def decode_last_req(input)
  last_requests = []
  input.value[0].value.each do |last_request|
    last_requests << Rex::Proto::Kerberos::Model::LastRequest.decode(last_request)
  end

  last_requests
end
decode_nonce(input) click to toggle source

Decodes the nonce field

@param input [OpenSSL::ASN1::ASN1Data] the input to decode from @return [Fixnum]

# File lib/rex/proto/kerberos/model/enc_kdc_response.rb, line 143
def decode_nonce(input)
  input.value[0].value.to_i
end
decode_renew_till(input) click to toggle source

Decodes the renew_till field

@param input [OpenSSL::ASN1::ASN1Data] the input to decode from @return [Time]

# File lib/rex/proto/kerberos/model/enc_kdc_response.rb, line 191
def decode_renew_till(input)
  input.value[0].value
end
decode_sname(input) click to toggle source

Decodes the sname field

@param input [OpenSSL::ASN1::ASN1Data] the input to decode from @return [Rex::Proto::Kerberos::Type::PrincipalName]

# File lib/rex/proto/kerberos/model/enc_kdc_response.rb, line 207
def decode_sname(input)
  Rex::Proto::Kerberos::Model::PrincipalName.decode(input.value[0])
end
decode_srealm(input) click to toggle source

Decodes the srealm field

@param input [OpenSSL::ASN1::ASN1Data] the input to decode from @return [String]

# File lib/rex/proto/kerberos/model/enc_kdc_response.rb, line 199
def decode_srealm(input)
  input.value[0].value
end
decode_start_time(input) click to toggle source

Decodes the start_time field

@param input [OpenSSL::ASN1::ASN1Data] the input to decode from @return [Time]

# File lib/rex/proto/kerberos/model/enc_kdc_response.rb, line 175
def decode_start_time(input)
  input.value[0].value
end
decode_string(input) click to toggle source

Decodes a Rex::Proto::Kerberos::Model::EncKdcResponse from an String

@param input [String] the input to decode from

# File lib/rex/proto/kerberos/model/enc_kdc_response.rb, line 77
def decode_string(input)
  asn1 = OpenSSL::ASN1.decode(input)

  decode_asn1(asn1)
end