rex 2.0.5 → 2.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rex/exploitation/egghunter.rb +4 -6
- data/lib/rex/exploitation/powershell/psh_methods.rb +9 -0
- data/lib/rex/java/serialization.rb +2 -1
- data/lib/rex/java/serialization/builder.rb +94 -0
- data/lib/rex/java/serialization/model.rb +29 -18
- data/lib/rex/java/serialization/model/annotation.rb +2 -2
- data/lib/rex/java/serialization/model/field.rb +2 -2
- data/lib/rex/java/serialization/model/new_array.rb +8 -3
- data/lib/rex/java/serialization/model/new_class_desc.rb +3 -3
- data/lib/rex/java/serialization/model/new_enum.rb +4 -4
- data/lib/rex/java/serialization/model/new_object.rb +17 -10
- data/lib/rex/ole/direntry.rb +1 -1
- data/lib/rex/ole/samples/create_ole.rb +0 -0
- data/lib/rex/ole/samples/dir.rb +0 -0
- data/lib/rex/ole/samples/dump_stream.rb +0 -0
- data/lib/rex/ole/samples/ole_info.rb +0 -0
- data/lib/rex/parser/foundstone_nokogiri.rb +1 -1
- data/lib/rex/parser/fs/ntfs.rb +252 -0
- data/lib/rex/parser/openvas_nokogiri.rb +2 -0
- data/lib/rex/payloads/win32/kernel.rb +3 -3
- data/lib/rex/post/meterpreter/client_core.rb +172 -64
- data/lib/rex/post/meterpreter/extensions/priv/priv.rb +3 -2
- data/lib/rex/post/meterpreter/extensions/stdapi/fs/file.rb +12 -10
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/api_constants.rb +64 -37
- data/lib/rex/post/meterpreter/extensions/stdapi/railgun/dll.rb +8 -2
- data/lib/rex/post/meterpreter/extensions/stdapi/ui.rb +15 -3
- data/lib/rex/post/meterpreter/packet.rb +41 -38
- data/lib/rex/post/meterpreter/packet_dispatcher.rb +7 -1
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb +17 -4
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb +11 -4
- data/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb +1 -1
- data/lib/rex/proto.rb +2 -0
- data/lib/rex/proto/acpp.rb +17 -0
- data/lib/rex/proto/acpp/client.rb +29 -0
- data/lib/rex/proto/acpp/message.rb +183 -0
- data/lib/rex/proto/http/client.rb +1 -2
- data/lib/rex/proto/iax2/call.rb +22 -3
- data/lib/rex/proto/iax2/client.rb +1 -0
- data/lib/rex/proto/kerberos.rb +13 -0
- data/lib/rex/proto/kerberos/client.rb +213 -0
- data/lib/rex/proto/kerberos/credential_cache.rb +19 -0
- data/lib/rex/proto/kerberos/credential_cache/cache.rb +81 -0
- data/lib/rex/proto/kerberos/credential_cache/credential.rb +151 -0
- data/lib/rex/proto/kerberos/credential_cache/element.rb +49 -0
- data/lib/rex/proto/kerberos/credential_cache/key_block.rb +62 -0
- data/lib/rex/proto/kerberos/credential_cache/principal.rb +70 -0
- data/lib/rex/proto/kerberos/credential_cache/time.rb +69 -0
- data/lib/rex/proto/kerberos/crypto.rb +21 -0
- data/lib/rex/proto/kerberos/crypto/rc4_hmac.rb +65 -0
- data/lib/rex/proto/kerberos/crypto/rsa_md5.rb +15 -0
- data/lib/rex/proto/kerberos/model.rb +133 -0
- data/lib/rex/proto/kerberos/model/ap_req.rb +98 -0
- data/lib/rex/proto/kerberos/model/authenticator.rb +143 -0
- data/lib/rex/proto/kerberos/model/authorization_data.rb +85 -0
- data/lib/rex/proto/kerberos/model/checksum.rb +59 -0
- data/lib/rex/proto/kerberos/model/element.rb +67 -0
- data/lib/rex/proto/kerberos/model/enc_kdc_response.rb +215 -0
- data/lib/rex/proto/kerberos/model/encrypted_data.rb +171 -0
- data/lib/rex/proto/kerberos/model/encryption_key.rb +106 -0
- data/lib/rex/proto/kerberos/model/kdc_request.rb +166 -0
- data/lib/rex/proto/kerberos/model/kdc_request_body.rb +315 -0
- data/lib/rex/proto/kerberos/model/kdc_response.rb +141 -0
- data/lib/rex/proto/kerberos/model/krb_error.rb +219 -0
- data/lib/rex/proto/kerberos/model/last_request.rb +82 -0
- data/lib/rex/proto/kerberos/model/pre_auth_data.rb +104 -0
- data/lib/rex/proto/kerberos/model/pre_auth_enc_time_stamp.rb +126 -0
- data/lib/rex/proto/kerberos/model/pre_auth_pac_request.rb +81 -0
- data/lib/rex/proto/kerberos/model/principal_name.rb +116 -0
- data/lib/rex/proto/kerberos/model/ticket.rb +151 -0
- data/lib/rex/proto/kerberos/pac.rb +36 -0
- data/lib/rex/proto/kerberos/pac/client_info.rb +53 -0
- data/lib/rex/proto/kerberos/pac/element.rb +52 -0
- data/lib/rex/proto/kerberos/pac/logon_info.rb +566 -0
- data/lib/rex/proto/kerberos/pac/priv_svr_checksum.rb +29 -0
- data/lib/rex/proto/kerberos/pac/server_checksum.rb +30 -0
- data/lib/rex/proto/kerberos/pac/type.rb +121 -0
- data/lib/rex/proto/rmi.rb +7 -0
- data/lib/rex/proto/rmi/model.rb +31 -0
- data/lib/rex/proto/rmi/model/call.rb +60 -0
- data/lib/rex/proto/rmi/model/continuation.rb +76 -0
- data/lib/rex/proto/rmi/model/dgc_ack.rb +62 -0
- data/lib/rex/proto/rmi/model/element.rb +143 -0
- data/lib/rex/proto/rmi/model/output_header.rb +86 -0
- data/lib/rex/proto/rmi/model/ping.rb +41 -0
- data/lib/rex/proto/rmi/model/ping_ack.rb +41 -0
- data/lib/rex/proto/rmi/model/protocol_ack.rb +100 -0
- data/lib/rex/proto/rmi/model/return_data.rb +60 -0
- data/lib/rex/socket.rb +9 -1
- data/lib/rex/socket/tcp_server.rb +3 -0
- data/lib/rex/ui/text/dispatcher_shell.rb +4 -4
- data/lib/rex/ui/text/output/tee.rb +2 -0
- data/lib/rex/zip/samples/comment.rb +0 -0
- data/lib/rex/zip/samples/mkwar.rb +0 -0
- data/lib/rex/zip/samples/mkzip.rb +0 -0
- data/lib/rex/zip/samples/recursive.rb +0 -0
- data/rex.gemspec +1 -1
- metadata +56 -2
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# -*- coding: binary -*-
|
|
2
|
+
|
|
3
|
+
module Rex
|
|
4
|
+
module Proto
|
|
5
|
+
module Kerberos
|
|
6
|
+
module Pac
|
|
7
|
+
VERSION = 0
|
|
8
|
+
NETLOGON_FLAG = 0x20000
|
|
9
|
+
SE_GROUP_MANDATORY = 1
|
|
10
|
+
SE_GROUP_ENABLED_BY_DEFAULT = 2
|
|
11
|
+
SE_GROUP_ENABLED = 4
|
|
12
|
+
SE_GROUP_ALL = SE_GROUP_MANDATORY | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_ENABLED
|
|
13
|
+
USER_NORMAL_ACCOUNT = 0x00000010
|
|
14
|
+
USER_DONT_EXPIRE_PASSWORD = 0x00000200
|
|
15
|
+
PAC_LOGON_INFO = 1
|
|
16
|
+
PAC_SERVER_CHECKSUM = 6
|
|
17
|
+
PAC_PRIVSVR_CHECKSUM = 7
|
|
18
|
+
PAC_CLIENT_INFO = 10
|
|
19
|
+
AD_WIN2K_PAC = 128
|
|
20
|
+
SEC_TO_UNIX_EPOCH = 11644473600
|
|
21
|
+
WINDOWS_TICK = 10000000
|
|
22
|
+
NEVER_EXPIRE = 0x7fffffffffffffff
|
|
23
|
+
DOMAIN_USERS = 513
|
|
24
|
+
DEFAULT_USER_SID = 1000
|
|
25
|
+
NT_AUTHORITY_SID = 'S-1-5'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
require 'rex/proto/kerberos/pac/element'
|
|
32
|
+
require 'rex/proto/kerberos/pac/priv_svr_checksum'
|
|
33
|
+
require 'rex/proto/kerberos/pac/server_checksum'
|
|
34
|
+
require 'rex/proto/kerberos/pac/client_info'
|
|
35
|
+
require 'rex/proto/kerberos/pac/logon_info'
|
|
36
|
+
require 'rex/proto/kerberos/pac/type'
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# -*- coding: binary -*-
|
|
2
|
+
|
|
3
|
+
module Rex
|
|
4
|
+
module Proto
|
|
5
|
+
module Kerberos
|
|
6
|
+
module Pac
|
|
7
|
+
# This class provides a representation of a PAC-CLIENT-INFO structure, containing the client's name
|
|
8
|
+
# and authentication time. It's used to verify which the ticket's client is the PAC's owner.
|
|
9
|
+
class ClientInfo < Element
|
|
10
|
+
|
|
11
|
+
# @!attribute client_id
|
|
12
|
+
# @return [Time] The auth_time field of the Kerberos KDC-AS response.
|
|
13
|
+
attr_accessor :client_id
|
|
14
|
+
# @!attribute name
|
|
15
|
+
# @return [String] The client name from the ticket
|
|
16
|
+
attr_accessor :name
|
|
17
|
+
|
|
18
|
+
# Encodes the Rex::Proto::Kerberos::Pac::ClientInfo
|
|
19
|
+
#
|
|
20
|
+
# @return [String]
|
|
21
|
+
def encode
|
|
22
|
+
encoded = ''
|
|
23
|
+
encoded << encode_client_id
|
|
24
|
+
encoded << [name.length * 2].pack('v')
|
|
25
|
+
encoded << encode_name
|
|
26
|
+
|
|
27
|
+
encoded
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
# Encodes the client_id attribute
|
|
33
|
+
#
|
|
34
|
+
# @return [String]
|
|
35
|
+
def encode_client_id
|
|
36
|
+
file_time = (client_id.to_i + 11644473600) * 10000000
|
|
37
|
+
encoded = ''
|
|
38
|
+
encoded << [file_time].pack('Q<')
|
|
39
|
+
|
|
40
|
+
encoded
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Encodes the name attribute
|
|
44
|
+
#
|
|
45
|
+
# @return [String]
|
|
46
|
+
def encode_name
|
|
47
|
+
Rex::Text.to_unicode(name)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# -*- coding: binary -*-
|
|
2
|
+
|
|
3
|
+
module Rex
|
|
4
|
+
module Proto
|
|
5
|
+
module Kerberos
|
|
6
|
+
module Pac
|
|
7
|
+
class Element
|
|
8
|
+
|
|
9
|
+
include Rex::Proto::Kerberos::Crypto
|
|
10
|
+
include Rex::Proto::Kerberos::Pac
|
|
11
|
+
|
|
12
|
+
def self.attr_accessor(*vars)
|
|
13
|
+
@attributes ||= []
|
|
14
|
+
@attributes.concat vars
|
|
15
|
+
super(*vars)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Retrieves the element class fields
|
|
19
|
+
#
|
|
20
|
+
# @return [Array]
|
|
21
|
+
def self.attributes
|
|
22
|
+
@attributes
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def initialize(options = {})
|
|
26
|
+
self.class.attributes.each do |attr|
|
|
27
|
+
if options.has_key?(attr)
|
|
28
|
+
m = (attr.to_s + '=').to_sym
|
|
29
|
+
self.send(m, options[attr])
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Retrieves the element instance fields
|
|
35
|
+
#
|
|
36
|
+
# @return [Array]
|
|
37
|
+
def attributes
|
|
38
|
+
self.class.attributes
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Encodes the Rex::Proto::Kerberos::Pac::Element into an String. This
|
|
42
|
+
# method has been designed to be overridden by subclasses.
|
|
43
|
+
#
|
|
44
|
+
# @raise [NoMethodError]
|
|
45
|
+
def encode
|
|
46
|
+
raise ::NoMethodError, 'Method designed to be overridden'
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
# -*- coding: binary -*-
|
|
2
|
+
|
|
3
|
+
module Rex
|
|
4
|
+
module Proto
|
|
5
|
+
module Kerberos
|
|
6
|
+
module Pac
|
|
7
|
+
# @todo Make more fields user controllable, instead of constants.
|
|
8
|
+
# This class provides a representation of a PAC_LOGON_INFO structure, which contains the
|
|
9
|
+
# credential information for the client of the Kerberos ticket.
|
|
10
|
+
class LogonInfo < Element
|
|
11
|
+
|
|
12
|
+
# @!attribute logon_time
|
|
13
|
+
# @return [Time] The time the client last logged on
|
|
14
|
+
attr_accessor :logon_time
|
|
15
|
+
# @!attribute effective_name
|
|
16
|
+
# @return [String] The client's Windows 2000 user name
|
|
17
|
+
attr_accessor :effective_name
|
|
18
|
+
# @!attribute user_id
|
|
19
|
+
# @return [Fixnum] The relative ID for the client
|
|
20
|
+
attr_accessor :user_id
|
|
21
|
+
# @!attribute primary_group_id
|
|
22
|
+
# @return [Fixnum] The relative ID for the client's primary group
|
|
23
|
+
attr_accessor :primary_group_id
|
|
24
|
+
# @!attribute group_ids
|
|
25
|
+
# @return [Array<Fixnum>] Array of relative Ids of the groups which the client is a member
|
|
26
|
+
attr_accessor :group_ids
|
|
27
|
+
# @!attribute logon_domain_name
|
|
28
|
+
# @return [String] The netbios name of the client's domain
|
|
29
|
+
attr_accessor :logon_domain_name
|
|
30
|
+
# @!attribute logon_domain_sid
|
|
31
|
+
# @return [String] The SID of the client's domain
|
|
32
|
+
attr_accessor :logon_domain_id
|
|
33
|
+
|
|
34
|
+
# Encodes the Rex::Proto::Kerberos::Pac::LogonInfo
|
|
35
|
+
#
|
|
36
|
+
# @return [String]
|
|
37
|
+
def encode
|
|
38
|
+
elements = []
|
|
39
|
+
elements[0] = ''
|
|
40
|
+
elements[0] << encode_element_id
|
|
41
|
+
elements[0] << encode_logon_time
|
|
42
|
+
elements[0] << encode_logoff_time
|
|
43
|
+
elements[0] << encode_kickoff_time
|
|
44
|
+
elements[0] << encode_password_last_set
|
|
45
|
+
elements[0] << encode_password_can_change
|
|
46
|
+
elements[0] << encode_password_must_change
|
|
47
|
+
elements[0] << encode_effective_name
|
|
48
|
+
elements << encode_effective_name_info
|
|
49
|
+
elements[0] << encode_full_name
|
|
50
|
+
elements << encode_full_name_info
|
|
51
|
+
elements[0] << encode_logon_script
|
|
52
|
+
elements << encode_logon_script_info
|
|
53
|
+
elements[0] << encode_profile_path
|
|
54
|
+
elements << encode_profile_path_info
|
|
55
|
+
elements[0] << encode_home_directory
|
|
56
|
+
elements << encode_home_directory_info
|
|
57
|
+
elements[0] << encode_home_directory_drive
|
|
58
|
+
elements << encode_home_directory_drive_info
|
|
59
|
+
elements[0] << encode_logon_count
|
|
60
|
+
elements[0] << encode_bad_password_count
|
|
61
|
+
elements[0] << encode_user_id
|
|
62
|
+
elements[0] << encode_primary_group_id
|
|
63
|
+
elements[0] << encode_group_count
|
|
64
|
+
elements[0] << encode_group_ids
|
|
65
|
+
elements << encode_group_ids_info
|
|
66
|
+
elements[0] << encode_user_flags
|
|
67
|
+
elements[0] << encode_user_session_key
|
|
68
|
+
elements[0] << encode_logon_server
|
|
69
|
+
elements << encode_logon_server_info
|
|
70
|
+
elements[0] << encode_logon_domain_name
|
|
71
|
+
elements << encode_logon_domain_name_info
|
|
72
|
+
elements[0] << encode_logon_domain_id
|
|
73
|
+
elements << encode_logon_domain_id_info
|
|
74
|
+
elements[0] << encode_reserved_one
|
|
75
|
+
elements[0] << encode_user_account_control
|
|
76
|
+
elements[0] << encode_reserved_three
|
|
77
|
+
elements[0] << encode_sid_count
|
|
78
|
+
elements[0] << encode_extra_sids
|
|
79
|
+
elements[0] << encode_resource_group_domain_sid
|
|
80
|
+
elements[0] << encode_resource_group_count
|
|
81
|
+
elements[0] << encode_resource_group_ids
|
|
82
|
+
|
|
83
|
+
decoded = ''
|
|
84
|
+
elements.each do |elem|
|
|
85
|
+
decoded << elem
|
|
86
|
+
decoded << "\x00" * ((elem.length + 3) / 4 * 4 - elem.length)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
header = "\x01\x10\x08\x00\xcc\xcc\xcc\xcc"
|
|
90
|
+
header << [decoded.length, 0].pack('VV')
|
|
91
|
+
|
|
92
|
+
header + decoded
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
private
|
|
96
|
+
|
|
97
|
+
# Encodes the netlogon type
|
|
98
|
+
#
|
|
99
|
+
# @return [String]
|
|
100
|
+
def encode_element_id
|
|
101
|
+
[NETLOGON_FLAG].pack('V')
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Encodes the logon_time attribute
|
|
105
|
+
#
|
|
106
|
+
# @return [String]
|
|
107
|
+
def encode_logon_time
|
|
108
|
+
file_time = (logon_time.to_i + SEC_TO_UNIX_EPOCH) * WINDOWS_TICK
|
|
109
|
+
encoded = ''
|
|
110
|
+
encoded << [file_time].pack('Q<')
|
|
111
|
+
|
|
112
|
+
encoded
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Encodes the logoff time (constant)
|
|
116
|
+
#
|
|
117
|
+
# @return [String]
|
|
118
|
+
def encode_logoff_time
|
|
119
|
+
[NEVER_EXPIRE].pack('Q<')
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Encodes the kickoff time (constant)
|
|
123
|
+
#
|
|
124
|
+
# @return [String]
|
|
125
|
+
def encode_kickoff_time
|
|
126
|
+
[NEVER_EXPIRE].pack('Q<')
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Encodes the password_last_set (constant)
|
|
130
|
+
#
|
|
131
|
+
# @return [String]
|
|
132
|
+
def encode_password_last_set
|
|
133
|
+
[0].pack('Q<')
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# Encodes the password_can_change (constant)
|
|
137
|
+
#
|
|
138
|
+
# @return [String]
|
|
139
|
+
def encode_password_can_change
|
|
140
|
+
[0].pack('Q<')
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Encodes the password_must_change (constant)
|
|
144
|
+
#
|
|
145
|
+
# @return [String]
|
|
146
|
+
def encode_password_must_change
|
|
147
|
+
[NEVER_EXPIRE].pack('Q<')
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# Encodes the effective_name id field
|
|
151
|
+
#
|
|
152
|
+
# @return [String]
|
|
153
|
+
def encode_effective_name
|
|
154
|
+
unicode = Rex::Text.to_unicode(effective_name)
|
|
155
|
+
|
|
156
|
+
encoded = ''
|
|
157
|
+
encoded << [
|
|
158
|
+
unicode.length,
|
|
159
|
+
unicode.length,
|
|
160
|
+
0x20004
|
|
161
|
+
].pack('vvV')
|
|
162
|
+
|
|
163
|
+
encoded
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Encodes the effective_name info field
|
|
167
|
+
#
|
|
168
|
+
# @return [String]
|
|
169
|
+
def encode_effective_name_info
|
|
170
|
+
unicode = Rex::Text.to_unicode(effective_name)
|
|
171
|
+
|
|
172
|
+
encoded = ''
|
|
173
|
+
encoded << [
|
|
174
|
+
effective_name.length,
|
|
175
|
+
effective_name.length
|
|
176
|
+
].pack('Q<V')
|
|
177
|
+
encoded << unicode
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# Encodes the full_name id
|
|
181
|
+
#
|
|
182
|
+
# @return [String]
|
|
183
|
+
def encode_full_name
|
|
184
|
+
unicode = Rex::Text.to_unicode('')
|
|
185
|
+
encoded = ''
|
|
186
|
+
encoded << [
|
|
187
|
+
unicode.length,
|
|
188
|
+
unicode.length,
|
|
189
|
+
0x20008
|
|
190
|
+
].pack('vvV')
|
|
191
|
+
|
|
192
|
+
encoded
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# Encodes the full_name_info (constant)
|
|
196
|
+
#
|
|
197
|
+
# @return [String]
|
|
198
|
+
def encode_full_name_info
|
|
199
|
+
unicode = Rex::Text.to_unicode('')
|
|
200
|
+
encoded = ''
|
|
201
|
+
encoded << [
|
|
202
|
+
''.length,
|
|
203
|
+
''.length
|
|
204
|
+
].pack('Q<V')
|
|
205
|
+
encoded << unicode
|
|
206
|
+
encoded
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# Encodes the logon_script id
|
|
210
|
+
#
|
|
211
|
+
# @return [String]
|
|
212
|
+
def encode_logon_script
|
|
213
|
+
unicode = Rex::Text.to_unicode('')
|
|
214
|
+
|
|
215
|
+
encoded = ''
|
|
216
|
+
encoded << [
|
|
217
|
+
unicode.length,
|
|
218
|
+
unicode.length,
|
|
219
|
+
0x2000c
|
|
220
|
+
].pack('vvV')
|
|
221
|
+
|
|
222
|
+
encoded
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# Encodes the logon_script info (constant)
|
|
226
|
+
#
|
|
227
|
+
# @return [String]
|
|
228
|
+
def encode_logon_script_info
|
|
229
|
+
unicode = Rex::Text.to_unicode('')
|
|
230
|
+
encoded = ''
|
|
231
|
+
encoded << [
|
|
232
|
+
''.length,
|
|
233
|
+
''.length
|
|
234
|
+
].pack('Q<V')
|
|
235
|
+
encoded << unicode
|
|
236
|
+
|
|
237
|
+
encoded
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
# Encodes the profile_path id
|
|
241
|
+
#
|
|
242
|
+
# @return [String]
|
|
243
|
+
def encode_profile_path
|
|
244
|
+
unicode = Rex::Text.to_unicode('')
|
|
245
|
+
|
|
246
|
+
encoded = ''
|
|
247
|
+
encoded << [
|
|
248
|
+
unicode.length,
|
|
249
|
+
unicode.length,
|
|
250
|
+
0x20010
|
|
251
|
+
].pack('vvV')
|
|
252
|
+
|
|
253
|
+
encoded
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
# Encodes the profile_path info (constant)
|
|
257
|
+
#
|
|
258
|
+
# @return [String]
|
|
259
|
+
def encode_profile_path_info
|
|
260
|
+
unicode = Rex::Text.to_unicode('')
|
|
261
|
+
encoded = ''
|
|
262
|
+
encoded << [
|
|
263
|
+
''.length,
|
|
264
|
+
''.length
|
|
265
|
+
].pack('Q<V')
|
|
266
|
+
encoded << unicode
|
|
267
|
+
|
|
268
|
+
encoded
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
# Encodes the home_directory id
|
|
272
|
+
#
|
|
273
|
+
# @return [String]
|
|
274
|
+
def encode_home_directory
|
|
275
|
+
unicode = Rex::Text.to_unicode('')
|
|
276
|
+
|
|
277
|
+
encoded = ''
|
|
278
|
+
encoded << [
|
|
279
|
+
unicode.length,
|
|
280
|
+
unicode.length,
|
|
281
|
+
0x20014
|
|
282
|
+
].pack('vvV')
|
|
283
|
+
|
|
284
|
+
encoded
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
# Encodes the home_directory info (constant)
|
|
288
|
+
#
|
|
289
|
+
# @return [String]
|
|
290
|
+
def encode_home_directory_info
|
|
291
|
+
unicode = Rex::Text.to_unicode('')
|
|
292
|
+
encoded = ''
|
|
293
|
+
encoded << [
|
|
294
|
+
''.length,
|
|
295
|
+
''.length
|
|
296
|
+
].pack('Q<V')
|
|
297
|
+
encoded << unicode
|
|
298
|
+
|
|
299
|
+
encoded
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
# Encodes hte home_directory_drive id
|
|
303
|
+
#
|
|
304
|
+
# @return [String]
|
|
305
|
+
def encode_home_directory_drive
|
|
306
|
+
unicode = Rex::Text.to_unicode('')
|
|
307
|
+
|
|
308
|
+
encoded = ''
|
|
309
|
+
encoded << [
|
|
310
|
+
unicode.length,
|
|
311
|
+
unicode.length,
|
|
312
|
+
0x20018
|
|
313
|
+
].pack('vvV')
|
|
314
|
+
encoded
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
# Encodes the home_directory_drive info (constant)
|
|
318
|
+
#
|
|
319
|
+
# @return [String]
|
|
320
|
+
def encode_home_directory_drive_info
|
|
321
|
+
unicode = Rex::Text.to_unicode('')
|
|
322
|
+
encoded = ''
|
|
323
|
+
encoded << [
|
|
324
|
+
''.length,
|
|
325
|
+
''.length
|
|
326
|
+
].pack('Q<V')
|
|
327
|
+
encoded << unicode
|
|
328
|
+
|
|
329
|
+
encoded
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
# Encodes the logon_count (constant)
|
|
333
|
+
#
|
|
334
|
+
# @return [String]
|
|
335
|
+
def encode_logon_count
|
|
336
|
+
[0].pack('v')
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
# Encodes the bad_password_count (constant)
|
|
340
|
+
#
|
|
341
|
+
# @return [String]
|
|
342
|
+
def encode_bad_password_count
|
|
343
|
+
[0].pack('v')
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
# Encodes the user_id field
|
|
347
|
+
#
|
|
348
|
+
# @return [String]
|
|
349
|
+
def encode_user_id
|
|
350
|
+
[user_id].pack('V')
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
# Encodes the primary_group_id field
|
|
354
|
+
#
|
|
355
|
+
# @return [String]
|
|
356
|
+
def encode_primary_group_id
|
|
357
|
+
[primary_group_id].pack('V')
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
# Encodes the group_count field
|
|
361
|
+
#
|
|
362
|
+
# @return [String]
|
|
363
|
+
def encode_group_count
|
|
364
|
+
[group_ids.length].pack('V')
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
# Encodes the group_ids id
|
|
368
|
+
#
|
|
369
|
+
# @return [String]
|
|
370
|
+
def encode_group_ids
|
|
371
|
+
encoded = ''
|
|
372
|
+
encoded << [0x2001c].pack('V')
|
|
373
|
+
|
|
374
|
+
encoded
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
# Encodes the group_ids info
|
|
378
|
+
#
|
|
379
|
+
# @return [String]
|
|
380
|
+
def encode_group_ids_info
|
|
381
|
+
encoded = ''
|
|
382
|
+
encoded << [group_ids.length].pack('V')
|
|
383
|
+
group_ids.each do |group|
|
|
384
|
+
encoded << [
|
|
385
|
+
group,
|
|
386
|
+
SE_GROUP_ALL
|
|
387
|
+
].pack('VV')
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
encoded
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
# Encodes the user_flags (constant)
|
|
394
|
+
#
|
|
395
|
+
# @return [String]
|
|
396
|
+
def encode_user_flags
|
|
397
|
+
[0].pack('V')
|
|
398
|
+
end
|
|
399
|
+
|
|
400
|
+
# Encodes the user_session_key (constant)
|
|
401
|
+
#
|
|
402
|
+
# @return [String]
|
|
403
|
+
def encode_user_session_key
|
|
404
|
+
[0, 0].pack('Q<Q<')
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
# Encodes the logon_server id
|
|
408
|
+
#
|
|
409
|
+
# @return [String]
|
|
410
|
+
def encode_logon_server
|
|
411
|
+
unicode = Rex::Text.to_unicode('')
|
|
412
|
+
|
|
413
|
+
encoded = ''
|
|
414
|
+
encoded << [
|
|
415
|
+
unicode.length,
|
|
416
|
+
unicode.length,
|
|
417
|
+
0x20020
|
|
418
|
+
].pack('vvV')
|
|
419
|
+
encoded
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
# Encodes the logon_server info (constant)
|
|
423
|
+
#
|
|
424
|
+
# @return [String]
|
|
425
|
+
def encode_logon_server_info
|
|
426
|
+
unicode = Rex::Text.to_unicode('')
|
|
427
|
+
encoded = ''
|
|
428
|
+
encoded << [
|
|
429
|
+
''.length,
|
|
430
|
+
''.length
|
|
431
|
+
].pack('Q<V')
|
|
432
|
+
encoded << unicode
|
|
433
|
+
|
|
434
|
+
encoded
|
|
435
|
+
end
|
|
436
|
+
|
|
437
|
+
# Encodes the logon_domain_name id
|
|
438
|
+
#
|
|
439
|
+
# @return [String]
|
|
440
|
+
def encode_logon_domain_name
|
|
441
|
+
unicode = Rex::Text.to_unicode(logon_domain_name)
|
|
442
|
+
|
|
443
|
+
encoded = ''
|
|
444
|
+
encoded << [
|
|
445
|
+
unicode.length,
|
|
446
|
+
unicode.length,
|
|
447
|
+
0x20024
|
|
448
|
+
].pack('vvV')
|
|
449
|
+
|
|
450
|
+
encoded
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
# Encodes the logon_domain_name info field
|
|
454
|
+
#
|
|
455
|
+
# @return [String]
|
|
456
|
+
def encode_logon_domain_name_info
|
|
457
|
+
unicode = Rex::Text.to_unicode(logon_domain_name)
|
|
458
|
+
encoded = ''
|
|
459
|
+
encoded << [
|
|
460
|
+
logon_domain_name.length,
|
|
461
|
+
logon_domain_name.length
|
|
462
|
+
].pack('Q<V')
|
|
463
|
+
encoded << unicode
|
|
464
|
+
|
|
465
|
+
encoded
|
|
466
|
+
end
|
|
467
|
+
|
|
468
|
+
# Encodes the logon_domain_id id
|
|
469
|
+
#
|
|
470
|
+
# @return [String]
|
|
471
|
+
def encode_logon_domain_id
|
|
472
|
+
encoded = ''
|
|
473
|
+
encoded << [0x20028].pack('V')
|
|
474
|
+
|
|
475
|
+
encoded
|
|
476
|
+
end
|
|
477
|
+
|
|
478
|
+
# Encodes the logon_domain_id info field
|
|
479
|
+
#
|
|
480
|
+
# @return [String]
|
|
481
|
+
def encode_logon_domain_id_info
|
|
482
|
+
components = logon_domain_id.split('-')
|
|
483
|
+
unless components[0] == 'S'
|
|
484
|
+
raise ::RuntimeError, 'PAC-LOGON-INFO encoding failed: incorrect LogonDomainId'
|
|
485
|
+
end
|
|
486
|
+
components.slice!(0) # Delete the 'S' component
|
|
487
|
+
|
|
488
|
+
encoded = ''
|
|
489
|
+
encoded << [
|
|
490
|
+
components.length - 2,
|
|
491
|
+
components[0].to_i,
|
|
492
|
+
components.length - 2
|
|
493
|
+
].pack('VCC')
|
|
494
|
+
|
|
495
|
+
encoded << [
|
|
496
|
+
components[1].to_i >> 16,
|
|
497
|
+
components[1].to_i & 0xffff
|
|
498
|
+
].pack('Nn')
|
|
499
|
+
|
|
500
|
+
components[2, components.length].each do |c|
|
|
501
|
+
encoded << [c.to_i].pack('V')
|
|
502
|
+
end
|
|
503
|
+
|
|
504
|
+
encoded
|
|
505
|
+
end
|
|
506
|
+
|
|
507
|
+
# Encodes the reserved_one (constant)
|
|
508
|
+
#
|
|
509
|
+
# @return [String]
|
|
510
|
+
def encode_reserved_one
|
|
511
|
+
[0, 0].pack('VV')
|
|
512
|
+
end
|
|
513
|
+
|
|
514
|
+
# Encodes the user_account_control (constant)
|
|
515
|
+
#
|
|
516
|
+
# @return [String]
|
|
517
|
+
def encode_user_account_control
|
|
518
|
+
[USER_NORMAL_ACCOUNT | USER_DONT_EXPIRE_PASSWORD].pack('V')
|
|
519
|
+
end
|
|
520
|
+
|
|
521
|
+
# Encodes the reserved_three (constant)
|
|
522
|
+
#
|
|
523
|
+
# @return [String]
|
|
524
|
+
def encode_reserved_three
|
|
525
|
+
[0, 0, 0, 0, 0, 0, 0].pack('V*')
|
|
526
|
+
end
|
|
527
|
+
|
|
528
|
+
# Encodes the sid_count (constant)
|
|
529
|
+
#
|
|
530
|
+
# @return [String]
|
|
531
|
+
def encode_sid_count
|
|
532
|
+
[0].pack('V')
|
|
533
|
+
end
|
|
534
|
+
|
|
535
|
+
# Encodes the extra_sids (constant)
|
|
536
|
+
#
|
|
537
|
+
# @return [String]
|
|
538
|
+
def encode_extra_sids
|
|
539
|
+
[0].pack('V')
|
|
540
|
+
end
|
|
541
|
+
|
|
542
|
+
# Encodes the resource_group_domain_sid (constant)
|
|
543
|
+
#
|
|
544
|
+
# @return [String]
|
|
545
|
+
def encode_resource_group_domain_sid
|
|
546
|
+
[0].pack('V')
|
|
547
|
+
end
|
|
548
|
+
|
|
549
|
+
# Encodes the resource_group_count (constant)
|
|
550
|
+
#
|
|
551
|
+
# @return [String]
|
|
552
|
+
def encode_resource_group_count
|
|
553
|
+
[0].pack('V')
|
|
554
|
+
end
|
|
555
|
+
|
|
556
|
+
# Encodes the resource_group_ids (constant)
|
|
557
|
+
#
|
|
558
|
+
# @return [String]
|
|
559
|
+
def encode_resource_group_ids
|
|
560
|
+
[0].pack('V')
|
|
561
|
+
end
|
|
562
|
+
end
|
|
563
|
+
end
|
|
564
|
+
end
|
|
565
|
+
end
|
|
566
|
+
end
|