class Rex::Proto::Kerberos::Model::KrbError

This class provides a representation of a Kerberos KRB-ERROR (response error) message definition.

Attributes

cname[RW]

@!attribute cname

@return [Rex::Proto::Kerberos::Model::PrincipalName] The name part of the client's principal identifier
crealm[RW]

@!attribute crealm

@return [String] The realm part of the client's principal identifier
ctime[RW]

@!attribute ctime

@return [Time] The current time of the client's host
cusec[RW]

@!attribute cusec

@return [Fixnum] The microseconds part of the client timestamp
e_data[RW]

@!attribute e_data

@return [String] additional data about the error (ASN.1 encoded data)
error_code[RW]

@!attribute error_code

@return [Fixnum] The error request returned by kerberos or the server when a request fails
msg_type[RW]

@!attribute msg_type

@return [Fixnum] The type of a protocol message
pvno[RW]

@!attribute pvno

@return [Fixnum] The protocol version number
realm[RW]

@!attribute realm

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

@!attribute sname

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

@!attribute stime

@return [Time] The current time of the server
susec[RW]

@!attribute susec

@return [Fixnum] The microseconds part of the server timestamp

Public Instance Methods

decode(input) click to toggle source

Decodes the Rex::Proto::Kerberos::Model::KrbError 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/krb_error.rb, line 51
def decode(input)
  case input
  when String
    decode_string(input)
  when OpenSSL::ASN1::ASN1Data
    decode_asn1(input)
  else
    raise ::RuntimeError, 'Failed to decode KrbError, invalid input'
  end

  self
end
encode() click to toggle source

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

@raise [NotImplementedError]

# File lib/rex/proto/kerberos/model/krb_error.rb, line 67
def encode
  raise ::NotImplementedError, 'KrbError encoding not supported'
end

Private Instance Methods

decode_asn1(input) click to toggle source

Decodes a Rex::Proto::Kerberos::Model::KrbError

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

# File lib/rex/proto/kerberos/model/krb_error.rb, line 86
def decode_asn1(input)
  input.value[0].value.each do |val|
    case val.tag
    when 0
      self.pvno = decode_pvno(val)
    when 1
      self.msg_type = decode_msg_type(val)
    when 2
      self.ctime = decode_ctime(val)
    when 3
      self.cusec = decode_cusec(val)
    when 4
      self.stime = decode_stime(val)
    when 5
      self.susec = decode_susec(val)
    when 6
      self.error_code = decode_error_code(val)
    when 7
      self.crealm = decode_crealm(val)
    when 8
      self.cname = decode_cname(val)
    when 9
      self.realm = decode_realm(val)
    when 10
      self.sname = decode_sname(val)
    when 12
      self.e_data = decode_e_data(val)
    else
      raise ::RuntimeError, 'Failed to decode KRB-ERROR SEQUENCE'
    end
  end
end
decode_cname(input) click to toggle source

Decodes the cname field

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

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

Decodes the crealm field

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

# File lib/rex/proto/kerberos/model/krb_error.rb, line 179
def decode_crealm(input)
  input.value[0].value
end
decode_ctime(input) click to toggle source

Decodes the ctime field

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

# File lib/rex/proto/kerberos/model/krb_error.rb, line 139
def decode_ctime(input)
  input.value[0].value
end
decode_cusec(input) click to toggle source

Decodes the cusec field

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

# File lib/rex/proto/kerberos/model/krb_error.rb, line 147
def decode_cusec(input)
  input.value[0].value
end
decode_e_data(input) click to toggle source

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

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

# File lib/rex/proto/kerberos/model/krb_error.rb, line 211
def decode_e_data(input)
  input.value[0].value
end
decode_error_code(input) click to toggle source

Decodes the error_code field

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

# File lib/rex/proto/kerberos/model/krb_error.rb, line 171
def decode_error_code(input)
  input.value[0].value.to_i
end
decode_msg_type(input) click to toggle source

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

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

# File lib/rex/proto/kerberos/model/krb_error.rb, line 131
def decode_msg_type(input)
  input.value[0].value.to_i
end
decode_pvno(input) click to toggle source

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

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

# File lib/rex/proto/kerberos/model/krb_error.rb, line 123
def decode_pvno(input)
  input.value[0].value.to_i
end
decode_realm(input) click to toggle source

Decodes the realm field

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

# File lib/rex/proto/kerberos/model/krb_error.rb, line 195
def decode_realm(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::Model::PrincipalName]

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

Decodes the stime field

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

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

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

@param input [String] the input to decode from

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

  decode_asn1(asn1)
end
decode_susec(input) click to toggle source

Decodes the susec field

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

# File lib/rex/proto/kerberos/model/krb_error.rb, line 163
def decode_susec(input)
  input.value[0].value.to_i
end