Class: Rex::Proto::Kerberos::Model::PreAuthEncTimeStamp

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

Overview

This class is a representation of a PA-ENC-TIMESTAMP, an encrypted timestamp sent as pre authenticated data

Constant Summary collapse

CRYPTO_MSG_TYPE =
1

Constants included from Rex::Proto::Kerberos::Model

AD_IF_RELEVANT, AP_REQ, AS_REP, AS_REQ, AUTHENTICATOR, ERROR_CODES, KDC_OPTION_ALLOW_POST_DATE, KDC_OPTION_ENC_TKT_IN_SKEY, KDC_OPTION_FORWARDABLE, KDC_OPTION_FORWARDED, KDC_OPTION_POST_DATED, KDC_OPTION_PROXIABLE, KDC_OPTION_PROXY, KDC_OPTION_RENEW, KDC_OPTION_RENEWABLE, KDC_OPTION_RENEWABLE_OK, KDC_OPTION_RESERVED, KDC_OPTION_UNUSED_10, KDC_OPTION_UNUSED_11, KDC_OPTION_UNUSED_7, KDC_OPTION_UNUSED_9, KDC_OPTION_VALIDATE, KRB_ERROR, NT_PRINCIPAL, NT_SRV_HST, NT_SRV_INST, NT_SRV_XHST, NT_UID, NT_UNKNOWN, PA_ENC_TIMESTAMP, PA_PAC_REQUEST, PA_PW_SALT, PA_TGS_REQ, TGS_REP, TGS_REQ, TICKET, VERSION

Constants included from Crypto

Crypto::ENC_AS_RESPONSE, Crypto::ENC_KDC_REQUEST_BODY, Crypto::ENC_TGS_RESPONSE, Crypto::RC4_HMAC, Crypto::RSA_MD5

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Element

attr_accessor, attributes, #attributes, decode, #initialize

Methods included from Crypto::RsaMd5

#checksum_rsa_md5

Methods included from Crypto::Rc4Hmac

#decrypt_rc4_hmac, #encrypt_rc4_hmac

Constructor Details

This class inherits a constructor from Rex::Proto::Kerberos::Model::Element

Instance Attribute Details

#pa_time_stampTime

Returns client’s time.

Returns:

  • (Time)

    client's time



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

def pa_time_stamp
  @pa_time_stamp
end

#pausecFixnum

Returns optional microseconds client’s time.

Returns:

  • (Fixnum)

    optional microseconds client's time



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

def pausec
  @pausec
end

Instance Method Details

#decode(input) ⇒ self

Decodes a Rex::Proto::Kerberos::Model::PreAuthEncTimeStamp

Parameters:

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

    the input to decode from

Returns:

  • (self)

    if decoding succeeds

Raises:



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

def decode(input)
  case input
  when String
    decode_string(input)
  when OpenSSL::ASN1::Sequence
    decode_asn1(input)
  else
    raise ::RuntimeError, 'Failed to decode PreAuthEncTimeStamp, invalid input'
  end

  self
end

#encodeString

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

Returns:

  • (String)


42
43
44
45
46
47
48
# File 'lib/rex/proto/kerberos/model/pre_auth_enc_time_stamp.rb', line 42

def encode
  pa_time_stamp_asn1 = OpenSSL::ASN1::ASN1Data.new([encode_pa_time_stamp], 0, :CONTEXT_SPECIFIC)
  pausec_asn1 = OpenSSL::ASN1::ASN1Data.new([encode_pausec], 1, :CONTEXT_SPECIFIC)
  seq = OpenSSL::ASN1::Sequence.new([pa_time_stamp_asn1, pausec_asn1])

  seq.to_der
end

#encrypt(etype, key) ⇒ String

Encrypts the Rex::Proto::Kerberos::Model::PreAuthEncTimeStamp

Parameters:

  • etype (Fixnum)

    the crypto schema to encrypt

  • key (String)

    the key to encrypt

Returns:

  • (String)

    the encrypted result

Raises:



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/rex/proto/kerberos/model/pre_auth_enc_time_stamp.rb', line 56

def encrypt(etype, key)
  data = self.encode

  res = ''
  case etype
  when RC4_HMAC
    res = encrypt_rc4_hmac(data, key, CRYPTO_MSG_TYPE)
  else
    raise ::NotImplementedError, 'EncryptedData schema is not supported'
  end

  res
end