Class: Rex::Proto::Kerberos::Model::PreAuthPacOptions

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

Overview

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

#flagsInteger

Returns The PA-PAC-OPTIONS flags.

Returns:

  • (Integer)

    The PA-PAC-OPTIONS flags



14
15
16
# File 'lib/rex/proto/kerberos/model/pre_auth_pac_options.rb', line 14

def flags
  @flags
end

Instance Method Details

#decode(input) ⇒ self

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

Parameters:

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

    the input to decode from

Returns:

  • (self)

    if decoding succeeds

Raises:



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rex/proto/kerberos/model/pre_auth_pac_options.rb', line 21

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 PreAuthPacOptions, invalid input'
  end

  self
end

#decode_asn1(input) ⇒ Object

Decodes a Rex::Proto::Kerberos::Model::PreAuthPacOptions from an OpenSSL::ASN1::Sequence

Parameters:

  • input (OpenSSL::ASN1::Sequence)

    the input to decode from

Raises:



70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/rex/proto/kerberos/model/pre_auth_pac_options.rb', line 70

def decode_asn1(input)
  seq_values = input.value

  seq_values.each do |val|
    case val.tag
    when 0
      self.options = decode_flags(val)
    else
      raise ::Rex::Proto::Kerberos::Model::Error::KerberosDecodingError, 'Failed to decode PreAuthPacOptions SEQUENCE'
    end
  end
end

#decode_flags(input) ⇒ Integer

Decodes the flags field

Parameters:

  • input (OpenSSL::ASN1::ASN1Data)

    the input to decode from

Returns:

  • (Integer)


87
88
89
# File 'lib/rex/proto/kerberos/model/pre_auth_pac_options.rb', line 87

def decode_flags(input)
  input.value[0].value.unpack('N')[0]
end

#decode_string(input) ⇒ Object

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

Parameters:

  • input (String)

    the input to decode from

Raises:



57
58
59
60
61
62
63
# File 'lib/rex/proto/kerberos/model/pre_auth_pac_options.rb', line 57

def decode_string(input)
  asn1 = OpenSSL::ASN1.decode(input)

  decode_asn1(asn1)
rescue OpenSSL::ASN1::ASN1Error
  raise Rex::Proto::Kerberos::Model::Error::KerberosDecodingError
end

#encodeString

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

Returns:

  • (String)


37
38
39
40
41
42
43
44
# File 'lib/rex/proto/kerberos/model/pre_auth_pac_options.rb', line 37

def encode
  elems = []
  elems << OpenSSL::ASN1::ASN1Data.new([encode_flags], 0, :CONTEXT_SPECIFIC)

  seq = OpenSSL::ASN1::Sequence.new(elems)

  seq.to_der
end

#encode_flagsOpenSSL::ASN1::BitString

Encodes the flags

Returns:

  • (OpenSSL::ASN1::BitString)


49
50
51
# File 'lib/rex/proto/kerberos/model/pre_auth_pac_options.rb', line 49

def encode_flags
  OpenSSL::ASN1::BitString.new([flags.to_i].pack('N'))
end