Class: Rex::Proto::Kerberos::Model::Ticket

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

Overview

This class provides a representation of a Kerberos ticket 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

#enc_partRex::Proto::Kerberos::Model::EncryptedData

Returns The encrypted part of the ticket.

Returns:



21
22
23
# File 'lib/rex/proto/kerberos/model/ticket.rb', line 21

def enc_part
  @enc_part
end

#realmString

Returns The realm that issued the ticket.

Returns:

  • (String)

    The realm that issued the ticket



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

def realm
  @realm
end

#snameRex::Proto::Kerberos::Model::PrincipalName

Returns The name part of the server’s identity.

Returns:



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

def sname
  @sname
end

#tkt_vnoInteger

Returns The ticket version number.

Returns:

  • (Integer)

    The ticket version number



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

def tkt_vno
  @tkt_vno
end

Instance Method Details

#==(other) ⇒ Object



23
24
25
26
27
28
# File 'lib/rex/proto/kerberos/model/ticket.rb', line 23

def ==(other)
  tkt_vno == other.tkt_vno &&
    realm == other.realm &&
    sname == other.sname &&
    enc_part == other.enc_part
end

#decode(input) ⇒ self

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

Parameters:

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

    the input to decode from

Returns:

  • (self)

    if decoding succeeds

Raises:



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rex/proto/kerberos/model/ticket.rb', line 35

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

  self
end

#encodeObject



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/rex/proto/kerberos/model/ticket.rb', line 48

def encode
  elems = []
  elems << OpenSSL::ASN1::ASN1Data.new([encode_tkt_vno], 0, :CONTEXT_SPECIFIC)
  elems << OpenSSL::ASN1::ASN1Data.new([encode_realm], 1, :CONTEXT_SPECIFIC)
  elems << OpenSSL::ASN1::ASN1Data.new([encode_sname], 2, :CONTEXT_SPECIFIC)
  elems << OpenSSL::ASN1::ASN1Data.new([encode_enc_part], 3, :CONTEXT_SPECIFIC)
  seq = OpenSSL::ASN1::Sequence.new(elems)

  seq_asn1 = OpenSSL::ASN1::ASN1Data.new([seq], TICKET, :APPLICATION)

  seq_asn1.to_der
end