ruby_smb 3.3.9 → 3.3.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 278206369fbc36f22011dbdaa45154a7a937468c2178e05c76b2ccc0b5032345
4
- data.tar.gz: 9fc1a683bc32bd5e35860fba5a74749611d9ae4298c3cd3a93b7b0949adea78d
3
+ metadata.gz: 07f6abd7129c406c8b1c008c686eef226b8fa385fa06be6eec900b95b4f97a32
4
+ data.tar.gz: 4ddc7ee9c516a1649faa15ad4316e36149aa4304c4dc176dfd5234f46f9218be
5
5
  SHA512:
6
- metadata.gz: d7cd41abca3c816ad18fedad7f544a42a46f8d863447678e408661d11688696bab1ef91cf85557c5757b916f5bcaee7b047231a4f35e8d4683f8a9e56a2a559b
7
- data.tar.gz: 408e4e81542732f5f31e16c8bc970629518f7a8a56c62c697cd98e3066e93280fb2270f346a63769e05d2cf9cd7bdd2b5ac9344e058c5190d9d88621d321bf24
6
+ metadata.gz: e948d03583b517435a912b4ea07086ee0bff1fc07c0f65f0ea89e51ec10ee4ab2074d33a82c4f774656909c938331a7080fb521e5e65989bb301e10cd80d1bf5
7
+ data.tar.gz: 2f964acae7e74b25cb49e3d47ea125d4f4669f3f8868b9e895bb2f63be9e465e3fc1021e6695a1b837616a0f92419708ff4af6cb894b630d0b6292c95e3b4599
checksums.yaml.gz.sig CHANGED
Binary file
@@ -80,7 +80,8 @@ module RubySMB
80
80
  string :default
81
81
  end
82
82
  choice 'Wkssvc', selection: -> { opnum } do
83
- netr_wksta_get_info_request Wkssvc::NETR_WKSTA_GET_INFO
83
+ netr_wksta_get_info_request Wkssvc::NETR_WKSTA_GET_INFO
84
+ netr_wksta_user_enum_request Wkssvc::NETR_WKSTA_USER_ENUM
84
85
  string :default
85
86
  end
86
87
  choice 'Epm', selection: -> { opnum } do
@@ -2,9 +2,6 @@ module RubySMB
2
2
  module Dcerpc
3
3
  module Wkssvc
4
4
 
5
- # [2.2.2.1 WKSSVC_IDENTIFY_HANDLE](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-wkst/9ef94a11-0e5c-49d7-9ac7-68d6f03565de)
6
- class WkssvcIdentifyHandle < Ndr::NdrWideStringPtr; end
7
-
8
5
  # [3.2.4.1 NetrWkstaGetInfo (Opnum 0)](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-wkst/4af41d6f-b800-4de1-af5b-0b15a85f8e04)
9
6
  class NetrWkstaGetInfoRequest < BinData::Record
10
7
  attr_reader :opnum
@@ -0,0 +1,25 @@
1
+ module RubySMB
2
+ module Dcerpc
3
+ module Wkssvc
4
+
5
+ # [3.2.4.3 NetrWkstaUserEnum (Opnum 2)](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-wkst/4af41d6f-b800-4de1-af5b-0b15a85f8e04)
6
+ class NetrWkstaUserEnumRequest < BinData::Record
7
+ attr_reader :opnum
8
+
9
+ endian :little
10
+
11
+ wkssvc_identify_handle :server_name
12
+ wksta_user_enum_structure :user_info
13
+ ndr_uint32 :preferred_max_length, initial_value: 0xFFFFFFFF
14
+ ndr_uint32_ptr :result_handle, initial_value: 0
15
+
16
+ def initialize_instance
17
+ super
18
+ @opnum = NETR_WKSTA_USER_ENUM
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+
@@ -0,0 +1,25 @@
1
+ module RubySMB
2
+ module Dcerpc
3
+ module Wkssvc
4
+
5
+ # [3.2.4.3 NetrWkstaUserEnum (Opnum 2)](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-wkst/4af41d6f-b800-4de1-af5b-0b15a85f8e04)
6
+ class NetrWkstaUserEnumResponse < BinData::Record
7
+ attr_reader :opnum
8
+
9
+ endian :little
10
+
11
+ wksta_user_enum_structure :user_info
12
+ ndr_uint32_ptr :total_entries
13
+ ndr_uint32_ptr :result_handle
14
+ ndr_uint32 :error_status
15
+
16
+ def initialize_instance
17
+ super
18
+ @opnum = NETR_WKSTA_USER_ENUM
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+
@@ -7,7 +7,8 @@ module RubySMB
7
7
  VER_MINOR = 0
8
8
 
9
9
  # Operation numbers
10
- NETR_WKSTA_GET_INFO = 0x0000
10
+ NETR_WKSTA_GET_INFO = 0x0000
11
+ NETR_WKSTA_USER_ENUM = 0x0002
11
12
 
12
13
  PLATFORM_ID = {
13
14
  0x0000012C => "DOS",
@@ -23,9 +24,85 @@ module RubySMB
23
24
  WKSTA_INFO_102 = 0x00000066
24
25
  #TODO: WKSTA_INFO_502 = 0x000001F6
25
26
 
27
+ # User Enum Information Level
28
+ WKSTA_USER_INFO_0 = 0x00000000
29
+ WKSTA_USER_INFO_1 = 0x00000001
30
+
31
+ # [2.2.2.1 WKSSVC_IDENTIFY_HANDLE](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-wkst/9ef94a11-0e5c-49d7-9ac7-68d6f03565de)
32
+ class WkssvcIdentifyHandle < Ndr::NdrWideStringzPtr; end
33
+
34
+ # [2.2.5.9 WKSTA_USER_INFO_0](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-wkst/b7c53c6f-8b92-4e5d-9a2e-6462cb4ef1ac)
35
+ class WkstaUserInfo0 < Ndr::NdrStruct
36
+ default_parameter byte_align: 4
37
+ endian :little
38
+
39
+ ndr_wide_stringz_ptr :wkui0_username
40
+ end
41
+
42
+ class WkstaUserInfo0ArrayPtr < Ndr::NdrConfArray
43
+ default_parameter type: :wksta_user_info0
44
+ extend Ndr::PointerClassPlugin
45
+ end
46
+
47
+ # [2.2.5.12 WKSTA_USER_INFO_0_CONTAINER](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-wkst/0b0cff8f-09bc-43a8-b0d3-88f0bf7e3664)
48
+ class WkstaUserInfo0Container < Ndr::NdrStruct
49
+ default_parameter byte_align: 4
50
+ endian :little
51
+
52
+ ndr_uint32 :wkui0_entries_read
53
+ wksta_user_info0_array_ptr :wkui0_buffer
54
+ end
55
+
56
+ class PwkstaUserInfo0Container < WkstaUserInfo0Container
57
+ extend Ndr::PointerClassPlugin
58
+ end
59
+
60
+ # [2.2.5.10 WKSTA_USER_INFO_1](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-wkst/c37b9606-866f-40ac-9490-57b8334968e2)
61
+ class WkstaUserInfo1 < Ndr::NdrStruct
62
+ default_parameter byte_align: 4
63
+ endian :little
64
+
65
+ ndr_wide_stringz_ptr :wkui1_username
66
+ ndr_wide_stringz_ptr :wkui1_logon_domain
67
+ ndr_wide_stringz_ptr :wkui1_oth_domains
68
+ ndr_wide_stringz_ptr :wkui1_logon_server
69
+ end
70
+
71
+ class WkstaUserInfo1ArrayPtr < Ndr::NdrConfArray
72
+ default_parameter type: :wksta_user_info1
73
+ extend Ndr::PointerClassPlugin
74
+ end
75
+
76
+ # [2.2.5.13 WKSTA_USER_INFO_1_CONTAINER](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-wkst/22a813e4-fc7d-4fe3-a6d6-78debfd2c0c9)
77
+ class WkstaUserInfo1Container < Ndr::NdrStruct
78
+ default_parameter byte_align: 4
79
+ endian :little
80
+
81
+ ndr_uint32 :wkui1_entries_read
82
+ wksta_user_info1_array_ptr :wkui1_buffer
83
+ end
84
+
85
+ class PwkstaUserInfo1Container < WkstaUserInfo1Container
86
+ extend Ndr::PointerClassPlugin
87
+ end
88
+
89
+ # [2.2.5.14 WKSTA_USER_ENUM_STRUCT](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-wkst/4041455a-52be-4389-a4fc-82fea3cb3160)
90
+ class WkstaUserEnumStructure < Ndr::NdrStruct
91
+ default_parameter byte_align: 4
92
+ endian :little
93
+
94
+ ndr_uint32 :level
95
+ ndr_uint32 :tag, value: -> { self.level }
96
+ choice :info, selection: :level, byte_align: 4 do
97
+ pwksta_user_info0_container WKSTA_USER_INFO_0
98
+ pwksta_user_info1_container WKSTA_USER_INFO_1
99
+ end
100
+ end
26
101
 
27
102
  require 'ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_request'
28
103
  require 'ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_response'
104
+ require 'ruby_smb/dcerpc/wkssvc/netr_wksta_user_enum_request'
105
+ require 'ruby_smb/dcerpc/wkssvc/netr_wksta_user_enum_response'
29
106
 
30
107
  # Returns details about a computer environment, including
31
108
  # platform-specific information, the names of the domain and local
@@ -33,14 +110,14 @@ module RubySMB
33
110
  #
34
111
  # @param server_name [optional, String] String that identifies the server (optional
35
112
  # since it is ignored by the server)
36
- # @param server_name [optional, Integer] The information level of the data (default: WKSTA_INFO_100)
113
+ # @param level [optional, Integer] The information level of the data (default: WKSTA_INFO_100)
37
114
  # @return [RubySMB::Dcerpc::Wkssvc::WkstaInfo100, RubySMB::Dcerpc::Wkssvc::WkstaInfo101,
38
115
  # RubySMB::Dcerpc::Wkssvc::WkstaInfo102] The structure containing the requested information
39
116
  # @raise [RubySMB::Dcerpc::Error::InvalidPacket] if the response is not a
40
117
  # NetrWkstaGetInfoResponse packet
41
118
  # @raise [RubySMB::Dcerpc::Error::WkssvcError] if the response error status
42
119
  # is not STATUS_SUCCESS
43
- def netr_wksta_get_info(server_name: "\x00", level: WKSTA_INFO_100)
120
+ def netr_wksta_get_info(server_name: '', level: WKSTA_INFO_100)
44
121
  wkst_netr_wksta_get_info_request = NetrWkstaGetInfoRequest.new(
45
122
  server_name: server_name,
46
123
  level: level
@@ -59,6 +136,44 @@ module RubySMB
59
136
  wkst_netr_wksta_get_info_response.wksta_info.info
60
137
  end
61
138
 
139
+ # Returns details about users who are currently active on a remote computer.
140
+ #
141
+ # @param server_name [optional, String] String that identifies the server (optional
142
+ # since it is ignored by the server)
143
+ # @param level [optional, Integer] The information level of the data (default: WKSTA_USER_INFO_0)
144
+ # @return [RubySMB::Dcerpc::Wkssvc::WkstaUserInfo0, RubySMB::Dcerpc::Wkssvc::WkstaUserInfo1]
145
+ # The structure containing the requested information
146
+ # @raise [RubySMB::Dcerpc::Error::InvalidPacket] if the response is not a
147
+ # NetrWkstaGetInfoResponse packet
148
+ # @raise [RubySMB::Dcerpc::Error::WkssvcError] if the response error status
149
+ # is not STATUS_SUCCESS
150
+ def netr_wksta_user_enum(server_name: '', level: WKSTA_USER_INFO_0)
151
+ wkst_netr_wksta_enum_user_request = NetrWkstaUserEnumRequest.new(
152
+ server_name: server_name,
153
+ user_info: {
154
+ level: level,
155
+ tag: level,
156
+ info: {
157
+ wkui0_entries_read: 0,
158
+ },
159
+ },
160
+ preferred_max_length: 0xFFFFFFFF,
161
+ result_handle: 0
162
+ )
163
+ response = dcerpc_request(wkst_netr_wksta_enum_user_request)
164
+ begin
165
+ wkst_netr_wksta_enum_user_response = NetrWkstaUserEnumResponse.read(response)
166
+ rescue IOError
167
+ raise RubySMB::Dcerpc::Error::InvalidPacket, 'Error reading WkstNetrWkstaUserEnumResponse'
168
+ end
169
+ unless wkst_netr_wksta_enum_user_response.error_status == WindowsError::NTStatus::STATUS_SUCCESS
170
+ raise RubySMB::Dcerpc::Error::WkssvcError,
171
+ "Error returned with netr_wksta_enum_user: #{wkst_netr_wksta_enum_user_response.error_status.value} - "\
172
+ "#{WindowsError::NTStatus.find_by_retval(wkst_netr_wksta_enum_user_response.error_status.value).join(',')}"
173
+ end
174
+ wkst_netr_wksta_enum_user_response.user_info.info
175
+ end
176
+
62
177
  end
63
178
  end
64
179
  end
@@ -155,9 +155,9 @@ module RubySMB
155
155
  their_blob = type3_msg.ntlm_response[digest.digest_length..-1]
156
156
 
157
157
  ntlmv2_hash = Net::NTLM.ntlmv2_hash(
158
- RubySMB::Utils.safe_encode(account.username, 'UTF-16LE'),
159
- RubySMB::Utils.safe_encode(account.password, 'UTF-16LE'),
160
- RubySMB::Utils.safe_encode(type3_msg.domain, 'UTF-16LE'), # don't use the account domain because of the special '.' value
158
+ Net::NTLM::EncodeUtil.encode_utf16le(account.username),
159
+ Net::NTLM::EncodeUtil.encode_utf16le(account.password),
160
+ type3_msg.domain.force_encoding('ASCII-8BIT'), # don't use the account domain because of the special '.' value
161
161
  {client_challenge: their_blob[16...24], unicode: true}
162
162
  )
163
163
 
@@ -1,3 +1,3 @@
1
1
  module RubySMB
2
- VERSION = '3.3.9'.freeze
2
+ VERSION = '3.3.10'.freeze
3
3
  end
@@ -1,11 +1,3 @@
1
- RSpec.describe RubySMB::Dcerpc::Wkssvc::WkssvcIdentifyHandle do
2
- subject(:packet) { described_class.new }
3
-
4
- it 'is a Ndr::NdrWideStringPtr' do
5
- expect(packet).to be_a(RubySMB::Dcerpc::Ndr::NdrWideStringPtr)
6
- end
7
- end
8
-
9
1
  RSpec.describe RubySMB::Dcerpc::Wkssvc::NetrWkstaGetInfoRequest do
10
2
  subject(:packet) { described_class.new }
11
3
 
@@ -305,7 +305,7 @@ RSpec.describe RubySMB::Dcerpc::Wkssvc::LpwkstaInfo do
305
305
  it 'is little endian' do
306
306
  expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
307
307
  end
308
- it 'it is a Ndr::NdrStruct' do
308
+ it 'is a Ndr::NdrStruct' do
309
309
  expect(described_class).to be < RubySMB::Dcerpc::Ndr::NdrStruct
310
310
  end
311
311
  describe '#level' do
@@ -0,0 +1,7 @@
1
+ RSpec.describe RubySMB::Dcerpc::Wkssvc::WkssvcIdentifyHandle do
2
+ subject(:packet) { described_class.new }
3
+
4
+ it 'is a Ndr::NdrWideStringPtr' do
5
+ expect(packet).to be_a(RubySMB::Dcerpc::Ndr::NdrWideStringPtr)
6
+ end
7
+ end
@@ -0,0 +1,71 @@
1
+ RSpec.describe RubySMB::Dcerpc::Wkssvc::NetrWkstaUserEnumRequest do
2
+ subject(:packet) { described_class.new }
3
+
4
+ def random_str(nb = 8)
5
+ nb.times.map { rand('a'.ord..'z'.ord).chr }.join
6
+ end
7
+
8
+ it { is_expected.to respond_to :server_name }
9
+ it { is_expected.to respond_to :user_info }
10
+ it { is_expected.to respond_to :preferred_max_length }
11
+ it { is_expected.to respond_to :result_handle }
12
+ it { is_expected.to respond_to :opnum }
13
+
14
+ it 'is little endian' do
15
+ expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
16
+ end
17
+ it 'is a BinData::Record' do
18
+ expect(packet).to be_a(BinData::Record)
19
+ end
20
+ describe '#server_name' do
21
+ it 'is a WkssvcIdentifyHandle structure' do
22
+ expect(packet.server_name).to be_a RubySMB::Dcerpc::Wkssvc::WkssvcIdentifyHandle
23
+ end
24
+ end
25
+ describe '#user_info' do
26
+ it 'is a WkstaUserEnumStructure structure' do
27
+ expect(packet.user_info).to be_a RubySMB::Dcerpc::Wkssvc::WkstaUserEnumStructure
28
+ end
29
+ end
30
+ describe '#preferred_max_length' do
31
+ it 'is a NdrUint32 structure' do
32
+ expect(packet.preferred_max_length).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
33
+ end
34
+
35
+ it 'has a default value of 0xFFFFFFFF' do
36
+ expect(packet.preferred_max_length).to eq(0xFFFFFFFF)
37
+ end
38
+ end
39
+ describe '#result_handle' do
40
+ it 'is a NdrUint32Ptr structure' do
41
+ expect(packet.result_handle).to be_a RubySMB::Dcerpc::Ndr::NdrUint32Ptr
42
+ end
43
+
44
+ it 'has a default value of 0' do
45
+ expect(packet.result_handle).to eq(0)
46
+ end
47
+ end
48
+ describe '#initialize_instance' do
49
+ it 'sets #opnum to NETR_WKSTA_USER_ENUM constant' do
50
+ expect(packet.opnum).to eq(RubySMB::Dcerpc::Wkssvc::NETR_WKSTA_USER_ENUM)
51
+ end
52
+ end
53
+ it 'reads itself' do
54
+ packet = described_class.new(
55
+ server_name: 'TestServer',
56
+ user_info: {
57
+ level: RubySMB::Dcerpc::Wkssvc::WKSTA_USER_INFO_0,
58
+ info: {
59
+ wkui0_entries_read: 1,
60
+ wkui0_buffer: [{
61
+ wkui0_username: random_str
62
+ }],
63
+ },
64
+ },
65
+ preferred_max_length: 0xFFFFFFFF,
66
+ result_handle: 0
67
+ )
68
+ binary = packet.to_binary_s
69
+ expect(described_class.read(binary)).to eq(packet)
70
+ end
71
+ end
@@ -0,0 +1,65 @@
1
+ RSpec.describe RubySMB::Dcerpc::Wkssvc::NetrWkstaUserEnumResponse do
2
+ subject(:packet) { described_class.new }
3
+
4
+ def random_str(nb = 8)
5
+ nb.times.map { rand('a'.ord..'z'.ord).chr }.join
6
+ end
7
+
8
+ it { is_expected.to respond_to :user_info }
9
+ it { is_expected.to respond_to :total_entries }
10
+ it { is_expected.to respond_to :result_handle }
11
+ it { is_expected.to respond_to :error_status }
12
+
13
+ it 'is little endian' do
14
+ expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
15
+ end
16
+ it 'is a BinData::Record' do
17
+ expect(packet).to be_a(BinData::Record)
18
+ end
19
+ describe '#user_info' do
20
+ it 'is a WkstaUserEnumStructure structure' do
21
+ expect(packet.user_info).to be_a RubySMB::Dcerpc::Wkssvc::WkstaUserEnumStructure
22
+ end
23
+ end
24
+ describe '#total_entries' do
25
+ it 'is a NdrUint32Ptr structure' do
26
+ expect(packet.total_entries).to be_a RubySMB::Dcerpc::Ndr::NdrUint32Ptr
27
+ end
28
+ end
29
+ describe '#result_handle' do
30
+ it 'is a NdrUint32Ptr structure' do
31
+ expect(packet.result_handle).to be_a RubySMB::Dcerpc::Ndr::NdrUint32Ptr
32
+ end
33
+ end
34
+ describe '#error_status' do
35
+ it 'is a NdrUint32 structure' do
36
+ expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
37
+ end
38
+ end
39
+ describe '#initialize_instance' do
40
+ it 'sets #opnum to NETR_WKSTA_USER_ENUM constant' do
41
+ expect(packet.opnum).to eq(RubySMB::Dcerpc::Wkssvc::NETR_WKSTA_USER_ENUM)
42
+ end
43
+ end
44
+ it 'reads itself' do
45
+ packet = described_class.new(
46
+ user_info: {
47
+ level: RubySMB::Dcerpc::Wkssvc::WKSTA_USER_INFO_1,
48
+ info: {
49
+ wkui1_entries_read: 1,
50
+ wkui1_buffer: [{
51
+ wkui1_username: random_str,
52
+ wkui1_logon_domain: random_str,
53
+ wkui1_oth_domains: random_str,
54
+ wkui1_logon_server: random_str
55
+ }],
56
+ },
57
+ },
58
+ total_entries: 1,
59
+ result_handle: 0,
60
+ error_status: 0
61
+ )
62
+ binary = packet.to_binary_s
63
+ expect(described_class.read(binary)).to eq(packet)
64
+ end
65
+ end
@@ -1,3 +1,11 @@
1
+ RSpec.describe RubySMB::Dcerpc::Wkssvc::WkssvcIdentifyHandle do
2
+ subject(:packet) { described_class.new }
3
+
4
+ it 'is a Ndr::NdrWideStringzPtr' do
5
+ expect(packet).to be_a(RubySMB::Dcerpc::Ndr::NdrWideStringzPtr)
6
+ end
7
+ end
8
+
1
9
  RSpec.describe RubySMB::Dcerpc::Wkssvc do
2
10
  let(:wkssvc) do
3
11
  RubySMB::SMB1::Pipe.new(
@@ -23,7 +31,7 @@ RSpec.describe RubySMB::Dcerpc::Wkssvc do
23
31
  it 'sets the request with the expected values' do
24
32
  wkssvc.netr_wksta_get_info
25
33
  expect(described_class::NetrWkstaGetInfoRequest).to have_received(:new).with(
26
- server_name: "\x00",
34
+ server_name: '',
27
35
  level: described_class::WKSTA_INFO_100
28
36
  )
29
37
  end
@@ -67,4 +75,53 @@ RSpec.describe RubySMB::Dcerpc::Wkssvc do
67
75
  end
68
76
  end
69
77
  end
78
+
79
+ describe '#netr_wksta_user_enum' do
80
+ let(:wkst_netr_wksta_user_enum_request) { double('NetrWkstaUserEnumRequest') }
81
+ let(:response) { double('Response') }
82
+ let(:wkst_netr_wksta_user_enum_response) { double('NetrWkstaUserEnumResponse') }
83
+ let(:info) { double('info') }
84
+ before :example do
85
+ allow(described_class::NetrWkstaUserEnumRequest).to receive(:new).and_return(wkst_netr_wksta_user_enum_request)
86
+ allow(wkssvc).to receive(:dcerpc_request).and_return(response)
87
+ allow(described_class::NetrWkstaUserEnumResponse).to receive(:read).and_return(wkst_netr_wksta_user_enum_response)
88
+ allow(wkst_netr_wksta_user_enum_response).to receive(:error_status).and_return(WindowsError::Win32::ERROR_SUCCESS)
89
+ allow(wkst_netr_wksta_user_enum_response).to receive_message_chain(:user_info, :info => info)
90
+ end
91
+
92
+ it 'sets the request with the expected values' do
93
+ wkssvc.netr_wksta_user_enum
94
+ expect(described_class::NetrWkstaUserEnumRequest).to have_received(:new).with(
95
+ server_name: '',
96
+ user_info: {
97
+ level: described_class::WKSTA_USER_INFO_0,
98
+ tag: described_class::WKSTA_USER_INFO_0,
99
+ info: {
100
+ wkui0_entries_read: 0,
101
+ },
102
+ },
103
+ preferred_max_length: 0xFFFFFFFF,
104
+ result_handle: 0
105
+ )
106
+ end
107
+ it 'send the expected request structure' do
108
+ wkssvc.netr_wksta_user_enum
109
+ expect(wkssvc).to have_received(:dcerpc_request).with(wkst_netr_wksta_user_enum_request)
110
+ end
111
+ context 'when an IOError occurs while parsing the response' do
112
+ it 'raises a RubySMB::Dcerpc::Error::InvalidPacket' do
113
+ allow(described_class::NetrWkstaUserEnumResponse).to receive(:read).and_raise(IOError)
114
+ expect { wkssvc.netr_wksta_user_enum }.to raise_error(RubySMB::Dcerpc::Error::InvalidPacket)
115
+ end
116
+ end
117
+ context 'when the response error status is not WindowsError::Win32::ERROR_SUCCESS' do
118
+ it 'raises a RubySMB::Dcerpc::Error::WinregError' do
119
+ allow(wkst_netr_wksta_user_enum_response).to receive(:error_status).and_return(WindowsError::Win32::ERROR_INVALID_DATA)
120
+ expect { wkssvc.netr_wksta_user_enum }.to raise_error(RubySMB::Dcerpc::Error::WkssvcError)
121
+ end
122
+ end
123
+ it 'returns the expected handler' do
124
+ expect(wkssvc.netr_wksta_user_enum).to eq(info)
125
+ end
126
+ end
70
127
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_smb
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.9
4
+ version: 3.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Metasploit Hackers
@@ -38,7 +38,7 @@ cert_chain:
38
38
  DgscAao7wB3xW2BWEp1KnaDWkf1x9ttgoBEYyuYwU7uatB67kBQG1PKvLt79wHvz
39
39
  Dxs+KOjGbBRfMnPgVGYkORKVrZIwlaboHbDKxcVW5xv+oZc7KYXWGg==
40
40
  -----END CERTIFICATE-----
41
- date: 2024-06-10 00:00:00.000000000 Z
41
+ date: 2024-09-11 00:00:00.000000000 Z
42
42
  dependencies:
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: redcarpet
@@ -409,6 +409,8 @@ files:
409
409
  - lib/ruby_smb/dcerpc/wkssvc.rb
410
410
  - lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_request.rb
411
411
  - lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_response.rb
412
+ - lib/ruby_smb/dcerpc/wkssvc/netr_wksta_user_enum_request.rb
413
+ - lib/ruby_smb/dcerpc/wkssvc/netr_wksta_user_enum_response.rb
412
414
  - lib/ruby_smb/dialect.rb
413
415
  - lib/ruby_smb/dispatcher.rb
414
416
  - lib/ruby_smb/dispatcher/base.rb
@@ -779,6 +781,9 @@ files:
779
781
  - spec/lib/ruby_smb/dcerpc/winreg_spec.rb
780
782
  - spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_request_spec.rb
781
783
  - spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_response_spec.rb
784
+ - spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_identity_handle.rb
785
+ - spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_user_enum_request_spec.rb
786
+ - spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_user_enum_response_spec.rb
782
787
  - spec/lib/ruby_smb/dcerpc/wkssvc_spec.rb
783
788
  - spec/lib/ruby_smb/dcerpc_spec.rb
784
789
  - spec/lib/ruby_smb/dispatcher/base_spec.rb
@@ -1120,6 +1125,9 @@ test_files:
1120
1125
  - spec/lib/ruby_smb/dcerpc/winreg_spec.rb
1121
1126
  - spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_request_spec.rb
1122
1127
  - spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_response_spec.rb
1128
+ - spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_identity_handle.rb
1129
+ - spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_user_enum_request_spec.rb
1130
+ - spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_user_enum_response_spec.rb
1123
1131
  - spec/lib/ruby_smb/dcerpc/wkssvc_spec.rb
1124
1132
  - spec/lib/ruby_smb/dcerpc_spec.rb
1125
1133
  - spec/lib/ruby_smb/dispatcher/base_spec.rb
metadata.gz.sig CHANGED
Binary file