Class: Rex::Proto::Kerberos::Pac::Type

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

Overview

This class provides a representation of a PAC_TYPE structure, the topmost structure of the PAC.

Constant Summary

Constants included from Rex::Proto::Kerberos::Pac

AD_WIN2K_PAC, DEFAULT_USER_SID, DOMAIN_USERS, NETLOGON_FLAG, NEVER_EXPIRE, NT_AUTHORITY_SID, PAC_CLIENT_INFO, PAC_LOGON_INFO, PAC_PRIVSVR_CHECKSUM, PAC_SERVER_CHECKSUM, SEC_TO_UNIX_EPOCH, SE_GROUP_ALL, SE_GROUP_ENABLED, SE_GROUP_ENABLED_BY_DEFAULT, SE_GROUP_MANDATORY, USER_DONT_EXPIRE_PASSWORD, USER_NORMAL_ACCOUNT, VERSION, WINDOWS_TICK

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, #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::Pac::Element

Instance Attribute Details

#buffersArray<Rex::Proto::Kerberos::Pac::Element>

Returns The array of PAC_INFO_BUFFER structures.

Returns:


13
14
15
# File 'lib/rex/proto/kerberos/pac/type.rb', line 13

def buffers
  @buffers
end

#checksumInteger

Returns The type of checksum to use when encoding PAC-TYPE.

Returns:

  • (Integer)

    The type of checksum to use when encoding PAC-TYPE


16
17
18
# File 'lib/rex/proto/kerberos/pac/type.rb', line 16

def checksum
  @checksum
end

Instance Method Details

#encodeString

Encodes the Rex::Proto::Kerberos::Pac::Type

Returns:

  • (String)

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rex/proto/kerberos/pac/type.rb', line 21

def encode
  offset_one = 0
  offset_two = 0

  draft = ''
  draft << encode_buffers_length
  draft << encode_version
  draft << encode_pac_info_buffers

  # Encode buffers
  buffers.each do |buffer|
    if buffer.class == ServerChecksum
      offset_one = draft.length + 4
    elsif buffer.class == PrivSvrChecksum
      offset_two = draft.length + 4
    end

    buffer_encoded = buffer.encode
    draft << buffer_encoded
    draft << "\x00" * ((buffer_encoded.length + 7) / 8 * 8 - buffer_encoded.length)
  end

  checksum_draft = make_checksum(draft)
  double_checksum = make_checksum(checksum_draft)

  encoded = ''
  encoded << draft[0..(offset_one - 1)]
  encoded << checksum_draft
  encoded << draft[(offset_one + checksum_draft.length)..(offset_two - 1)]
  encoded << double_checksum
  encoded << draft[(offset_two + double_checksum.length)..(draft.length - 1)]

  encoded
end