ruby_smb 2.0.3 → 2.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -2
- data/.github/workflows/verify.yml +56 -0
- data/README.md +0 -1
- data/examples/delete_file.rb +0 -0
- data/examples/net_share_enum_all.rb +0 -0
- data/examples/pipes.rb +0 -0
- data/examples/rename_file.rb +0 -0
- data/lib/ruby_smb.rb +3 -2
- data/lib/ruby_smb/client.rb +12 -8
- data/lib/ruby_smb/client/authentication.rb +5 -10
- data/lib/ruby_smb/client/echo.rb +2 -4
- data/lib/ruby_smb/client/negotiation.rb +4 -6
- data/lib/ruby_smb/client/tree_connect.rb +2 -4
- data/lib/ruby_smb/client/utils.rb +16 -10
- data/lib/ruby_smb/client/winreg.rb +1 -1
- data/lib/ruby_smb/compression.rb +7 -0
- data/lib/ruby_smb/compression/lznt1.rb +164 -0
- data/lib/ruby_smb/dcerpc.rb +3 -1
- data/lib/ruby_smb/dcerpc/ndr.rb +97 -0
- data/lib/ruby_smb/dcerpc/netlogon.rb +101 -0
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_request.rb +37 -0
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_response.rb +26 -0
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_request.rb +37 -0
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_response.rb +23 -0
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_request.rb +32 -0
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_response.rb +24 -0
- data/lib/ruby_smb/dcerpc/request.rb +6 -0
- data/lib/ruby_smb/dcerpc/winreg.rb +2 -2
- data/lib/ruby_smb/dispatcher/socket.rb +1 -1
- data/lib/ruby_smb/error.rb +21 -5
- data/lib/ruby_smb/generic_packet.rb +11 -1
- data/lib/ruby_smb/smb1/file.rb +8 -15
- data/lib/ruby_smb/smb1/packet/trans2/find_first2_response.rb +0 -1
- data/lib/ruby_smb/smb1/packet/trans2/find_next2_response.rb +0 -1
- data/lib/ruby_smb/smb1/packet/trans2/open2_response.rb +1 -2
- data/lib/ruby_smb/smb1/packet/trans2/set_file_information_response.rb +1 -13
- data/lib/ruby_smb/smb1/pipe.rb +8 -8
- data/lib/ruby_smb/smb1/tree.rb +13 -9
- data/lib/ruby_smb/smb2/file.rb +8 -16
- data/lib/ruby_smb/smb2/packet/compression_transform_header.rb +4 -0
- data/lib/ruby_smb/smb2/pipe.rb +8 -8
- data/lib/ruby_smb/smb2/tree.rb +12 -8
- data/lib/ruby_smb/version.rb +1 -1
- data/spec/lib/ruby_smb/client_spec.rb +17 -12
- data/spec/lib/ruby_smb/compression/lznt1_spec.rb +32 -0
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_request_spec.rb +69 -0
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_response_spec.rb +53 -0
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_request_spec.rb +69 -0
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_response_spec.rb +37 -0
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_request_spec.rb +45 -0
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_response_spec.rb +37 -0
- data/spec/lib/ruby_smb/dcerpc/winreg_spec.rb +12 -0
- data/spec/lib/ruby_smb/error_spec.rb +34 -5
- data/spec/lib/ruby_smb/generic_packet_spec.rb +7 -0
- data/spec/lib/ruby_smb/smb1/file_spec.rb +2 -4
- data/spec/lib/ruby_smb/smb1/packet/trans2/find_first2_response_spec.rb +0 -1
- data/spec/lib/ruby_smb/smb1/packet/trans2/find_next2_response_spec.rb +0 -1
- data/spec/lib/ruby_smb/smb1/packet/trans2/open2_response_spec.rb +0 -5
- data/spec/lib/ruby_smb/smb1/packet/trans2/set_file_information_response_spec.rb +0 -6
- data/spec/lib/ruby_smb/smb1/pipe_spec.rb +23 -5
- data/spec/lib/ruby_smb/smb1/tree_spec.rb +22 -0
- data/spec/lib/ruby_smb/smb2/file_spec.rb +1 -3
- data/spec/lib/ruby_smb/smb2/pipe_spec.rb +2 -5
- data/spec/lib/ruby_smb/smb2/tree_spec.rb +23 -0
- data/spec/spec_helper.rb +1 -1
- metadata +42 -19
- metadata.gz.sig +0 -0
- data/.travis.yml +0 -6
data/lib/ruby_smb/smb2/tree.rb
CHANGED
@@ -50,13 +50,20 @@ module RubySMB
|
|
50
50
|
raise RubySMB::Error::InvalidPacket.new(
|
51
51
|
expected_proto: RubySMB::SMB2::SMB2_PROTOCOL_ID,
|
52
52
|
expected_cmd: RubySMB::SMB2::Packet::TreeDisconnectResponse::COMMAND,
|
53
|
-
|
54
|
-
received_cmd: response.smb2_header.command
|
53
|
+
packet: response
|
55
54
|
)
|
56
55
|
end
|
57
56
|
response.status_code
|
58
57
|
end
|
59
58
|
|
59
|
+
def open_pipe(opts)
|
60
|
+
# Make sure we don't modify the caller's hash options
|
61
|
+
opts = opts.dup
|
62
|
+
opts[:filename] = opts[:filename].dup
|
63
|
+
opts[:filename] = opts[:filename][1..-1] if opts[:filename].start_with? '\\'
|
64
|
+
open_file(opts)
|
65
|
+
end
|
66
|
+
|
60
67
|
def open_file(filename:, attributes: nil, options: nil, disposition: RubySMB::Dispositions::FILE_OPEN,
|
61
68
|
impersonation: RubySMB::ImpersonationLevels::SEC_IMPERSONATE, read: true, write: false, delete: false)
|
62
69
|
|
@@ -108,8 +115,7 @@ module RubySMB
|
|
108
115
|
raise RubySMB::Error::InvalidPacket.new(
|
109
116
|
expected_proto: RubySMB::SMB2::SMB2_PROTOCOL_ID,
|
110
117
|
expected_cmd: RubySMB::SMB2::Packet::CreateResponse::COMMAND,
|
111
|
-
|
112
|
-
received_cmd: response.smb2_header.command
|
118
|
+
packet: response
|
113
119
|
)
|
114
120
|
end
|
115
121
|
unless response.status_code == WindowsError::NTStatus::STATUS_SUCCESS
|
@@ -167,8 +173,7 @@ module RubySMB
|
|
167
173
|
raise RubySMB::Error::InvalidPacket.new(
|
168
174
|
expected_proto: RubySMB::SMB2::SMB2_PROTOCOL_ID,
|
169
175
|
expected_cmd: RubySMB::SMB2::Packet::QueryDirectoryResponse::COMMAND,
|
170
|
-
|
171
|
-
received_cmd: directory_response.smb2_header.command
|
176
|
+
packet: directory_response
|
172
177
|
)
|
173
178
|
end
|
174
179
|
|
@@ -212,8 +217,7 @@ module RubySMB
|
|
212
217
|
raise RubySMB::Error::InvalidPacket.new(
|
213
218
|
expected_proto: RubySMB::SMB2::SMB2_PROTOCOL_ID,
|
214
219
|
expected_cmd: RubySMB::SMB2::Packet::CreateResponse::COMMAND,
|
215
|
-
|
216
|
-
received_cmd: response.smb2_header.command
|
220
|
+
packet: response
|
217
221
|
)
|
218
222
|
end
|
219
223
|
unless response.status_code == WindowsError::NTStatus::STATUS_SUCCESS
|
data/lib/ruby_smb/version.rb
CHANGED
@@ -332,23 +332,28 @@ RSpec.describe RubySMB::Client do
|
|
332
332
|
expect(smb2_client.sequence_counter).to eq(1)
|
333
333
|
end
|
334
334
|
|
335
|
-
it 'updates #
|
335
|
+
it 'updates #smb2_message_id with SMB2 header #credit_charge if the server supports multi credits' do
|
336
336
|
allow(smb2_client).to receive(:is_status_pending?).and_return(false)
|
337
337
|
smb2_client.smb2_message_id = 0
|
338
|
-
smb2_client.
|
338
|
+
smb2_client.server_supports_multi_credit = true
|
339
339
|
smb2_header.credit_charge = 5
|
340
340
|
smb2_client.send_recv(smb2_request)
|
341
341
|
expect(smb2_client.smb2_message_id).to eq(5)
|
342
342
|
end
|
343
343
|
|
344
|
-
it 'does not update #msb2_message_id with SMB2 header #credit_charge if the
|
344
|
+
it 'does not update #msb2_message_id with SMB2 header #credit_charge if the server does not support multi credits' do
|
345
345
|
allow(smb2_client).to receive(:is_status_pending?).and_return(false)
|
346
346
|
smb2_client.smb2_message_id = 0
|
347
|
-
smb2_client.
|
347
|
+
smb2_client.server_supports_multi_credit = false
|
348
348
|
smb2_header.credit_charge = 5
|
349
349
|
smb2_client.send_recv(smb2_request)
|
350
350
|
expect(smb2_client.smb2_message_id).to eq(1)
|
351
351
|
end
|
352
|
+
|
353
|
+
it 'ignores errors thrown when parsing the SMB2 header' do
|
354
|
+
allow(RubySMB::SMB2::SMB2Header).to receive(:read).and_raise(IOError)
|
355
|
+
expect { smb2_client.send_recv(smb2_request) }.to_not raise_error
|
356
|
+
end
|
352
357
|
end
|
353
358
|
|
354
359
|
describe '#is_status_pending?' do
|
@@ -2354,7 +2359,7 @@ RSpec.describe RubySMB::Client do
|
|
2354
2359
|
let(:named_pipe){ double("Named Pipe") }
|
2355
2360
|
|
2356
2361
|
before :example do
|
2357
|
-
allow(tree).to receive(:
|
2362
|
+
allow(tree).to receive(:open_pipe).and_return(named_pipe)
|
2358
2363
|
allow(named_pipe).to receive(:net_share_enum_all)
|
2359
2364
|
end
|
2360
2365
|
|
@@ -2369,8 +2374,8 @@ RSpec.describe RubySMB::Client do
|
|
2369
2374
|
smb1_client.net_share_enum_all(sock.peeraddr)
|
2370
2375
|
end
|
2371
2376
|
|
2372
|
-
it 'it calls the Tree #
|
2373
|
-
expect(tree).to receive(:
|
2377
|
+
it 'it calls the Tree #open_pipe method to open "srvsvc" named pipe' do
|
2378
|
+
expect(tree).to receive(:open_pipe).with(filename: "srvsvc", write: true, read: true).and_return(named_pipe)
|
2374
2379
|
smb1_client.net_share_enum_all(sock.peeraddr)
|
2375
2380
|
end
|
2376
2381
|
|
@@ -2392,8 +2397,8 @@ RSpec.describe RubySMB::Client do
|
|
2392
2397
|
smb2_client.net_share_enum_all(sock.peeraddr)
|
2393
2398
|
end
|
2394
2399
|
|
2395
|
-
it 'it calls the Tree #
|
2396
|
-
expect(tree).to receive(:
|
2400
|
+
it 'it calls the Tree #open_pipe method to open "srvsvc" named pipe' do
|
2401
|
+
expect(tree).to receive(:open_pipe).with(filename: "srvsvc", write: true, read: true).and_return(named_pipe)
|
2397
2402
|
smb2_client.net_share_enum_all(sock.peeraddr)
|
2398
2403
|
end
|
2399
2404
|
|
@@ -2474,7 +2479,7 @@ RSpec.describe RubySMB::Client do
|
|
2474
2479
|
before :example do
|
2475
2480
|
allow(ipc_tree).to receive_messages(
|
2476
2481
|
:share => share,
|
2477
|
-
:
|
2482
|
+
:open_pipe => named_pipe
|
2478
2483
|
)
|
2479
2484
|
allow(client).to receive(:tree_connect).and_return(ipc_tree)
|
2480
2485
|
end
|
@@ -2496,9 +2501,9 @@ RSpec.describe RubySMB::Client do
|
|
2496
2501
|
expect(client).to have_received(:tree_connect).with(share)
|
2497
2502
|
end
|
2498
2503
|
|
2499
|
-
it 'open \'winreg\'
|
2504
|
+
it 'open \'winreg\' pipe on the IPC$ Tree' do
|
2500
2505
|
client.connect_to_winreg(host)
|
2501
|
-
expect(ipc_tree).to have_received(:
|
2506
|
+
expect(ipc_tree).to have_received(:open_pipe).with(filename: "winreg", write: true, read: true)
|
2502
2507
|
end
|
2503
2508
|
|
2504
2509
|
it 'returns the expected opened named pipe' do
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::Compression::LZNT1 do
|
4
|
+
describe '.compress' do
|
5
|
+
it 'generates an empty blob when provided an empty blob' do
|
6
|
+
expected = "".b
|
7
|
+
expect(described_class.compress('')).to eq(expected)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'generates a compressed blob when provided a string with non-reoccurring characters' do
|
11
|
+
expect(described_class.compress('RubySMB')).to eq("\x060RubySMB".b)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'generates a compressed blob when provided a string of reoccurring characters' do
|
15
|
+
expect(described_class.compress("\x01" * 0x200)).to eq("\x03\xB0\x02\x01\xFC\x01".b)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '.decompress' do
|
20
|
+
it 'generates a decompressed blob for a string with non-reoccurring characters' do
|
21
|
+
expect(described_class.decompress("\x060RubySMB".b)).to eq('RubySMB')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'generates a decompressed blob for a string of reoccurring characters' do
|
25
|
+
expect(described_class.decompress("\x03\xB0\x02\x01\xFC\x01".b)).to eq("\x01" * 0x200)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'raises an EncodingError when the length is invalid' do
|
29
|
+
expect { described_class.decompress("\x010".b) }.to raise_error(EncodingError)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Netlogon::NetrServerAuthenticate3Request do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :primary_name }
|
5
|
+
it { is_expected.to respond_to :account_name }
|
6
|
+
it { is_expected.to respond_to :secure_channel_type }
|
7
|
+
it { is_expected.to respond_to :computer_name }
|
8
|
+
it { is_expected.to respond_to :client_credential }
|
9
|
+
it { is_expected.to respond_to :flags }
|
10
|
+
|
11
|
+
it 'is little endian' do
|
12
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#primary_name' do
|
16
|
+
it 'is a LogonsrvHandle structure' do
|
17
|
+
expect(packet.primary_name).to be_a RubySMB::Dcerpc::Netlogon::LogonsrvHandle
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#account_name' do
|
22
|
+
it 'is a NdrString structure' do
|
23
|
+
expect(packet.account_name).to be_a RubySMB::Dcerpc::Ndr::NdrString
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#secure_channel_type' do
|
28
|
+
it 'is a NetlogonSecureChannelType enum' do
|
29
|
+
expect(packet.secure_channel_type).to be_a RubySMB::Dcerpc::Netlogon::NetlogonSecureChannelType
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#computer_name' do
|
34
|
+
it 'is a NdrString structure' do
|
35
|
+
expect(packet.computer_name).to be_a RubySMB::Dcerpc::Ndr::NdrString
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#client_credential' do
|
40
|
+
it 'is a NetlogonCredential structure' do
|
41
|
+
expect(packet.client_credential).to be_a RubySMB::Dcerpc::Netlogon::NetlogonCredential
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#flags' do
|
46
|
+
it 'is a 32-bit unsigned integer' do
|
47
|
+
expect(packet.flags).to be_a BinData::Uint32le
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#initialize_instance' do
|
52
|
+
it 'sets #opnum to NETR_SERVER_AUTHENTICATE3 constant' do
|
53
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Netlogon::NETR_SERVER_AUTHENTICATE3)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'reads its own binary representation and outputs the same packet' do
|
58
|
+
packet = described_class.new(
|
59
|
+
primary_name: 'primary_name',
|
60
|
+
account_name: 'account_name',
|
61
|
+
secure_channel_type: 0,
|
62
|
+
computer_name: 'computer_name',
|
63
|
+
client_credential: "\x00" * 8,
|
64
|
+
flags: rand(0xffffffff)
|
65
|
+
)
|
66
|
+
binary = packet.to_binary_s
|
67
|
+
expect(described_class.read(binary)).to eq(packet)
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Netlogon::NetrServerAuthenticate3Response do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :server_credential }
|
5
|
+
it { is_expected.to respond_to :negotiate_flags }
|
6
|
+
it { is_expected.to respond_to :account_rid }
|
7
|
+
it { is_expected.to respond_to :error_status }
|
8
|
+
|
9
|
+
it 'is little endian' do
|
10
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#server_credential' do
|
14
|
+
it 'is a NetlogonCredential structure' do
|
15
|
+
expect(packet.server_credential).to be_a RubySMB::Dcerpc::Netlogon::NetlogonCredential
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#negotiate_flags' do
|
20
|
+
it 'is a 32-bit unsigned integer' do
|
21
|
+
expect(packet.negotiate_flags).to be_a BinData::Uint32le
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#account_rid' do
|
26
|
+
it 'is a 32-bit unsigned integer' do
|
27
|
+
expect(packet.account_rid).to be_a BinData::Uint32le
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#error_status' do
|
32
|
+
it 'is a 32-bit unsigned integer' do
|
33
|
+
expect(packet.error_status).to be_a BinData::Uint32le
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#initialize_instance' do
|
38
|
+
it 'sets #opnum to NETR_SERVER_AUTHENTICATE3 constant' do
|
39
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Netlogon::NETR_SERVER_AUTHENTICATE3)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'reads its own binary representation and outputs the same packet' do
|
44
|
+
packet = described_class.new(
|
45
|
+
server_credential: "\x00" * 8,
|
46
|
+
negotiate_flags: rand(0xffffffff),
|
47
|
+
account_rid: rand(0xffffffff),
|
48
|
+
error_status: rand(0xffffffff)
|
49
|
+
)
|
50
|
+
binary = packet.to_binary_s
|
51
|
+
expect(described_class.read(binary)).to eq(packet)
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Netlogon::NetrServerPasswordSet2Request do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :primary_name }
|
5
|
+
it { is_expected.to respond_to :account_name }
|
6
|
+
it { is_expected.to respond_to :secure_channel_type }
|
7
|
+
it { is_expected.to respond_to :computer_name }
|
8
|
+
it { is_expected.to respond_to :authenticator }
|
9
|
+
it { is_expected.to respond_to :clear_new_password }
|
10
|
+
|
11
|
+
it 'is little endian' do
|
12
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#primary_name' do
|
16
|
+
it 'is a LogonsrvHandle structure' do
|
17
|
+
expect(packet.primary_name).to be_a RubySMB::Dcerpc::Netlogon::LogonsrvHandle
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#account_name' do
|
22
|
+
it 'is a NdrString structure' do
|
23
|
+
expect(packet.account_name).to be_a RubySMB::Dcerpc::Ndr::NdrString
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#secure_channel_type' do
|
28
|
+
it 'is a NetlogonSecureChannelType enum' do
|
29
|
+
expect(packet.secure_channel_type).to be_a RubySMB::Dcerpc::Netlogon::NetlogonSecureChannelType
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#computer_name' do
|
34
|
+
it 'is a NdrString structure' do
|
35
|
+
expect(packet.computer_name).to be_a RubySMB::Dcerpc::Ndr::NdrString
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#authenticator' do
|
40
|
+
it 'is a NetlogonAuthenticator structure' do
|
41
|
+
expect(packet.authenticator).to be_a RubySMB::Dcerpc::Netlogon::NetlogonAuthenticator
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#clear_new_password' do
|
46
|
+
it 'is a NdrFixedByteArray structure' do
|
47
|
+
expect(packet.clear_new_password).to be_a RubySMB::Dcerpc::Ndr::NdrFixedByteArray
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#initialize_instance' do
|
52
|
+
it 'sets #opnum to NETR_SERVER_PASSWORD_SET2 constant' do
|
53
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Netlogon::NETR_SERVER_PASSWORD_SET2)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'reads its own binary representation and outputs the same packet' do
|
58
|
+
packet = described_class.new(
|
59
|
+
primary_name: 'primary_name',
|
60
|
+
account_name: 'account_name',
|
61
|
+
secure_channel_type: 0,
|
62
|
+
computer_name: 'computer_name',
|
63
|
+
authenticator: RubySMB::Dcerpc::Netlogon::NetlogonAuthenticator.new,
|
64
|
+
clear_new_password: "\x00" * 516
|
65
|
+
)
|
66
|
+
binary = packet.to_binary_s
|
67
|
+
expect(described_class.read(binary)).to eq(packet)
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Netlogon::NetrServerPasswordSet2Response do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :return_authenticator }
|
5
|
+
it { is_expected.to respond_to :error_status }
|
6
|
+
|
7
|
+
it 'is little endian' do
|
8
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#return_authenticator' do
|
12
|
+
it 'is a NetlogonAuthenticator structure' do
|
13
|
+
expect(packet.return_authenticator).to be_a RubySMB::Dcerpc::Netlogon::NetlogonAuthenticator
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#error_status' do
|
18
|
+
it 'is a 32-bit unsigned integer' do
|
19
|
+
expect(packet.error_status).to be_a BinData::Uint32le
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#initialize_instance' do
|
24
|
+
it 'sets #opnum to NETR_SERVER_PASSWORD_SET2 constant' do
|
25
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Netlogon::NETR_SERVER_PASSWORD_SET2)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'reads its own binary representation and outputs the same packet' do
|
30
|
+
packet = described_class.new(
|
31
|
+
return_authenticator: RubySMB::Dcerpc::Netlogon::NetlogonAuthenticator.new,
|
32
|
+
error_status: rand(0xffffffff)
|
33
|
+
)
|
34
|
+
binary = packet.to_binary_s
|
35
|
+
expect(described_class.read(binary)).to eq(packet)
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Netlogon::NetrServerReqChallengeRequest do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :primary_name }
|
5
|
+
it { is_expected.to respond_to :computer_name }
|
6
|
+
it { is_expected.to respond_to :client_challenge }
|
7
|
+
|
8
|
+
it 'is little endian' do
|
9
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#primary_name' do
|
13
|
+
it 'is a LogonsrvHandle structure' do
|
14
|
+
expect(packet.primary_name).to be_a RubySMB::Dcerpc::Netlogon::LogonsrvHandle
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#computer_name' do
|
19
|
+
it 'is a NdrString structure' do
|
20
|
+
expect(packet.computer_name).to be_a RubySMB::Dcerpc::Ndr::NdrString
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#client_challenge' do
|
25
|
+
it 'is a NetlogonCredential structure' do
|
26
|
+
expect(packet.client_challenge).to be_a RubySMB::Dcerpc::Netlogon::NetlogonCredential
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#initialize_instance' do
|
31
|
+
it 'sets #opnum to NETR_SERVER_REQ_CHALLENGE constant' do
|
32
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Netlogon::NETR_SERVER_REQ_CHALLENGE)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'reads its own binary representation and outputs the same packet' do
|
37
|
+
packet = described_class.new(
|
38
|
+
primary_name: 'primary_name',
|
39
|
+
computer_name: 'computer_name',
|
40
|
+
client_challenge: "\x00" * 8,
|
41
|
+
)
|
42
|
+
binary = packet.to_binary_s
|
43
|
+
expect(described_class.read(binary)).to eq(packet)
|
44
|
+
end
|
45
|
+
end
|