Class: Rex::Proto::Kerberos::Model::TicketEncPart

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

Overview

This class provides a representation of a Kerberos ticket encrypted part that helps a client authenticate to a service.

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

#authorization_dataObject

10

AuthorizationData OPTIONAL



18
19
20
# File 'lib/rex/proto/kerberos/model/ticket_enc_part.rb', line 18

def authorization_data
  @authorization_data
end

#authtimeObject

5

KerberosTime,



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

def authtime
  @authtime
end

#caddrObject

9

HostAddresses OPTIONAL,



17
18
19
# File 'lib/rex/proto/kerberos/model/ticket_enc_part.rb', line 17

def caddr
  @caddr
end

#cnameObject

3

PrincipalName,



11
12
13
# File 'lib/rex/proto/kerberos/model/ticket_enc_part.rb', line 11

def cname
  @cname
end

#crealmObject

2

Realm,



10
11
12
# File 'lib/rex/proto/kerberos/model/ticket_enc_part.rb', line 10

def crealm
  @crealm
end

#endtimeObject

7

KerberosTime,



15
16
17
# File 'lib/rex/proto/kerberos/model/ticket_enc_part.rb', line 15

def endtime
  @endtime
end

#flagsObject

0

TicketFlags,



8
9
10
# File 'lib/rex/proto/kerberos/model/ticket_enc_part.rb', line 8

def flags
  @flags
end

#keyObject

1

EncryptionKey,



9
10
11
# File 'lib/rex/proto/kerberos/model/ticket_enc_part.rb', line 9

def key
  @key
end

#renew_tillObject

8

KerberosTime OPTIONAL,



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

def renew_till
  @renew_till
end

#starttimeObject

6

KerberosTime OPTIONAL,



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

def starttime
  @starttime
end

#transitedObject

4

TransitedEncoding,



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

def transited
  @transited
end

Instance Method Details

#decode(input) ⇒ self

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

Parameters:

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

    the input to decode from

Returns:

  • (self)

    if decoding succeeds

Raises:



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

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

  self
end

#encodeString

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

Returns:

  • (String)


42
43
44
# File 'lib/rex/proto/kerberos/model/ticket_enc_part.rb', line 42

def encode
  to_asn1.to_der
end

#to_asn1OpenSSL::ASN1::ASN1Data

Encodes a Rex::Proto::Kerberos::Model::TicketEncPart into ASN.1

Returns:

  • (OpenSSL::ASN1::ASN1Data)

    The TicketEncPart ASN1Data



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/rex/proto/kerberos/model/ticket_enc_part.rb', line 50

def to_asn1
  elems = []
  elems << OpenSSL::ASN1::ASN1Data.new([encode_flags], 0, :CONTEXT_SPECIFIC)
  elems << OpenSSL::ASN1::ASN1Data.new([encode_key], 1, :CONTEXT_SPECIFIC)
  elems << OpenSSL::ASN1::ASN1Data.new([encode_crealm], 2, :CONTEXT_SPECIFIC)
  elems << OpenSSL::ASN1::ASN1Data.new([encode_cname], 3, :CONTEXT_SPECIFIC)
  elems << OpenSSL::ASN1::ASN1Data.new([encode_transited], 4, :CONTEXT_SPECIFIC)
  elems << OpenSSL::ASN1::ASN1Data.new([encode_authtime], 5, :CONTEXT_SPECIFIC)
  elems << OpenSSL::ASN1::ASN1Data.new([encode_starttime], 6, :CONTEXT_SPECIFIC) if starttime
  elems << OpenSSL::ASN1::ASN1Data.new([encode_endtime], 7, :CONTEXT_SPECIFIC)
  elems << OpenSSL::ASN1::ASN1Data.new([encode_renew_till], 8, :CONTEXT_SPECIFIC) if renew_till
  elems << OpenSSL::ASN1::ASN1Data.new([encode_caddr], 9, :CONTEXT_SPECIFIC) if caddr
  elems << OpenSSL::ASN1::ASN1Data.new([encode_authorization_data], 10, :CONTEXT_SPECIFIC) if authorization_data

  seq = OpenSSL::ASN1::Sequence.new(elems)
  OpenSSL::ASN1::ASN1Data.new([seq], 3, :APPLICATION)
end