ruby_smb 3.0.6 → 3.1.2
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
- checksums.yaml.gz.sig +0 -0
- data/examples/file_server.rb +8 -1
- data/examples/virtual_file_server.rb +143 -0
- data/lib/ruby_smb/client/encryption.rb +16 -4
- data/lib/ruby_smb/client/negotiation.rb +10 -8
- data/lib/ruby_smb/fscc/file_information/file_access_information.rb +15 -0
- data/lib/ruby_smb/fscc/file_information/file_alignment_information.rb +45 -0
- data/lib/ruby_smb/fscc/file_information/file_all_information.rb +23 -0
- data/lib/ruby_smb/fscc/file_information/file_basic_information.rb +20 -0
- data/lib/ruby_smb/fscc/file_information/file_both_directory_information.rb +3 -3
- data/lib/ruby_smb/fscc/file_information/file_directory_information.rb +3 -3
- data/lib/ruby_smb/fscc/file_information/file_ea_information.rb +1 -0
- data/lib/ruby_smb/fscc/file_information/file_full_directory_information.rb +3 -3
- data/lib/ruby_smb/fscc/file_information/file_id_both_directory_information.rb +3 -3
- data/lib/ruby_smb/fscc/file_information/file_id_full_directory_information.rb +3 -3
- data/lib/ruby_smb/fscc/file_information/file_internal_information.rb +15 -0
- data/lib/ruby_smb/fscc/file_information/file_mode_information.rb +29 -0
- data/lib/ruby_smb/fscc/file_information/file_name_information.rb +16 -0
- data/lib/ruby_smb/fscc/file_information/file_names_information.rb +1 -1
- data/lib/ruby_smb/fscc/file_information/file_normalized_name_information.rb +16 -0
- data/lib/ruby_smb/fscc/file_information/file_position_information.rb +15 -0
- data/lib/ruby_smb/fscc/file_information/file_rename_information.rb +1 -1
- data/lib/ruby_smb/fscc/file_information/file_standard_information.rb +20 -0
- data/lib/ruby_smb/fscc/file_information/file_stream_information.rb +3 -0
- data/lib/ruby_smb/fscc/file_information.rb +43 -6
- data/lib/ruby_smb/fscc/file_system_information/file_fs_attribute_information.rb +1 -0
- data/lib/ruby_smb/fscc/file_system_information/file_fs_volume_information.rb +1 -0
- data/lib/ruby_smb/fscc/file_system_information.rb +4 -0
- data/lib/ruby_smb/gss/provider/ntlm.rb +20 -3
- data/lib/ruby_smb/gss/provider.rb +10 -1
- data/lib/ruby_smb/server/server_client/encryption.rb +66 -0
- data/lib/ruby_smb/server/server_client/negotiation.rb +14 -3
- data/lib/ruby_smb/server/server_client/session_setup.rb +21 -4
- data/lib/ruby_smb/server/server_client/share_io.rb +17 -0
- data/lib/ruby_smb/server/server_client/tree_connect.rb +40 -3
- data/lib/ruby_smb/server/server_client.rb +156 -38
- data/lib/ruby_smb/server/session.rb +5 -1
- data/lib/ruby_smb/server/share/provider/disk/file_system.rb +28 -0
- data/lib/ruby_smb/server/share/provider/disk/processor/close.rb +46 -0
- data/lib/ruby_smb/server/share/provider/disk/processor/create.rb +143 -0
- data/lib/ruby_smb/server/share/provider/disk/processor/query.rb +359 -0
- data/lib/ruby_smb/server/share/provider/disk/processor/read.rb +70 -0
- data/lib/ruby_smb/server/share/provider/disk/processor.rb +223 -0
- data/lib/ruby_smb/server/share/provider/disk.rb +12 -418
- data/lib/ruby_smb/server/share/provider/pipe.rb +2 -2
- data/lib/ruby_smb/server/share/provider/processor.rb +16 -0
- data/lib/ruby_smb/server/share/provider/virtual_disk/virtual_file.rb +85 -0
- data/lib/ruby_smb/server/share/provider/virtual_disk/virtual_pathname.rb +196 -0
- data/lib/ruby_smb/server/share/provider/virtual_disk/virtual_stat.rb +175 -0
- data/lib/ruby_smb/server/share/provider/virtual_disk.rb +116 -0
- data/lib/ruby_smb/server/share/provider.rb +1 -0
- data/lib/ruby_smb/server.rb +13 -3
- data/lib/ruby_smb/signing.rb +18 -4
- data/lib/ruby_smb/smb1/commands.rb +1 -0
- data/lib/ruby_smb/smb1/packet/nt_create_andx_request.rb +11 -1
- data/lib/ruby_smb/smb1/packet/nt_trans/create_request.rb +1 -1
- data/lib/ruby_smb/smb1/packet/read_andx_response.rb +5 -4
- data/lib/ruby_smb/smb1/packet/session_setup_request.rb +12 -4
- data/lib/ruby_smb/smb1/packet/trans2/data_block.rb +9 -1
- data/lib/ruby_smb/smb1/packet/trans2/find_first2_request.rb +52 -51
- data/lib/ruby_smb/smb1/packet/trans2/find_first2_response.rb +37 -37
- data/lib/ruby_smb/smb1/packet/trans2/find_information_level/find_file_both_directory_info.rb +48 -0
- data/lib/ruby_smb/smb1/packet/trans2/find_information_level.rb +28 -15
- data/lib/ruby_smb/smb1/packet/trans2/find_next2_request.rb +51 -51
- data/lib/ruby_smb/smb1/packet/trans2/find_next2_response.rb +36 -36
- data/lib/ruby_smb/smb1/packet/trans2/open2_request.rb +40 -39
- data/lib/ruby_smb/smb1/packet/trans2/open2_response.rb +40 -40
- data/lib/ruby_smb/smb1/packet/trans2/query_file_information_request.rb +60 -0
- data/lib/ruby_smb/smb1/packet/trans2/query_file_information_response.rb +59 -0
- data/lib/ruby_smb/smb1/packet/trans2/query_fs_information_level/query_fs_attribute_info.rb +31 -0
- data/lib/ruby_smb/smb1/packet/trans2/query_fs_information_level.rb +40 -0
- data/lib/ruby_smb/smb1/packet/trans2/query_fs_information_request.rb +46 -0
- data/lib/ruby_smb/smb1/packet/trans2/query_fs_information_response.rb +59 -0
- data/lib/ruby_smb/smb1/packet/trans2/query_information_level/query_file_basic_info.rb +23 -0
- data/lib/ruby_smb/smb1/packet/trans2/query_information_level/query_file_standard_info.rb +22 -0
- data/lib/ruby_smb/smb1/packet/trans2/query_information_level.rb +62 -0
- data/lib/ruby_smb/smb1/packet/trans2/query_path_information_request.rb +65 -0
- data/lib/ruby_smb/smb1/packet/trans2/query_path_information_response.rb +59 -0
- data/lib/ruby_smb/smb1/packet/trans2/request.rb +24 -8
- data/lib/ruby_smb/smb1/packet/trans2/request_secondary.rb +4 -4
- data/lib/ruby_smb/smb1/packet/trans2/response.rb +29 -20
- data/lib/ruby_smb/smb1/packet/trans2/set_file_information_request.rb +42 -42
- data/lib/ruby_smb/smb1/packet/trans2/set_file_information_response.rb +23 -23
- data/lib/ruby_smb/smb1/packet/trans2/subcommands.rb +23 -5
- data/lib/ruby_smb/smb1/packet/trans2.rb +4 -0
- data/lib/ruby_smb/smb1/packet/tree_connect_request.rb +4 -1
- data/lib/ruby_smb/smb2/negotiate_context.rb +10 -1
- data/lib/ruby_smb/smb2/packet/transform_header.rb +7 -7
- data/lib/ruby_smb/smb2/tree.rb +1 -0
- data/lib/ruby_smb/smb2.rb +1 -0
- data/lib/ruby_smb/version.rb +1 -1
- data/spec/lib/ruby_smb/client_spec.rb +31 -8
- data/spec/lib/ruby_smb/fscc/file_information/file_access_information_spec.rb +21 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_alignment_information_spec.rb +21 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_all_information_spec.rb +61 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_basic_information_spec.rb +41 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_both_directory_information_spec.rb +59 -10
- data/spec/lib/ruby_smb/fscc/file_information/file_directory_information_spec.rb +30 -12
- data/spec/lib/ruby_smb/fscc/file_information/file_ea_information_spec.rb +21 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_full_directory_information_spec.rb +30 -12
- data/spec/lib/ruby_smb/fscc/file_information/file_id_both_directory_information_spec.rb +63 -10
- data/spec/lib/ruby_smb/fscc/file_information/file_id_full_directory_information_spec.rb +30 -12
- data/spec/lib/ruby_smb/fscc/file_information/file_internal_information_spec.rb +21 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_mode_information_spec.rb +21 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_name_information_spec.rb +44 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_names_information_spec.rb +30 -12
- data/spec/lib/ruby_smb/fscc/file_information/file_network_open_information_spec.rb +51 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb +44 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_position_information_spec.rb +21 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_rename_information_spec.rb +1 -1
- data/spec/lib/ruby_smb/fscc/file_information/file_standard_information_spec.rb +41 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_stream_information_spec.rb +51 -0
- data/spec/lib/ruby_smb/fscc/file_information_spec.rb +14 -0
- data/spec/lib/ruby_smb/fscc/file_system_information/file_fs_attribute_information_spec.rb +46 -0
- data/spec/lib/ruby_smb/fscc/file_system_information/file_fs_volume_information_spec.rb +51 -0
- data/spec/lib/ruby_smb/fscc/file_system_information_spec.rb +14 -0
- data/spec/lib/ruby_smb/server/server_client_spec.rb +15 -0
- data/spec/lib/ruby_smb/server/share/provider/virtual_disk/virtual_pathname_spec.rb +581 -0
- data/spec/lib/ruby_smb/server/share/provider/virtual_disk/virtual_stat_spec.rb +207 -0
- data/spec/lib/ruby_smb/server/share/provider/virtual_disk_spec.rb +122 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/find_first2_request_spec.rb +2 -2
- data/spec/lib/ruby_smb/smb1/packet/trans2/find_first2_response_spec.rb +36 -2
- data/spec/lib/ruby_smb/smb1/packet/trans2/find_next2_request_spec.rb +2 -2
- data/spec/lib/ruby_smb/smb1/packet/trans2/find_next2_response_spec.rb +35 -1
- data/spec/lib/ruby_smb/smb1/packet/trans2/query_file_information_request_spec.rb +74 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/query_file_information_response_spec.rb +96 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/query_fs_information_request_spec.rb +62 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/query_fs_information_response_spec.rb +88 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/query_path_information_request_spec.rb +79 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/query_path_information_response_spec.rb +96 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/request_spec.rb +2 -2
- data/spec/lib/ruby_smb/smb1/packet/trans2/response_spec.rb +3 -3
- data/spec/lib/ruby_smb/smb1/packet/trans2/set_file_information_request_spec.rb +3 -2
- data/spec/lib/ruby_smb/smb1/packet/trans2/set_file_information_response_spec.rb +7 -2
- data/spec/lib/ruby_smb/smb1/tree_spec.rb +3 -3
- data/spec/lib/ruby_smb/smb2/packet/transform_header_spec.rb +2 -2
- data.tar.gz.sig +0 -0
- metadata +88 -2
- metadata.gz.sig +0 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
include RubySMB::Fscc::FileInformation
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::SMB1::Packet::Trans2::QueryFsInformationRequest do
|
4
|
+
subject(:packet) { described_class.new }
|
5
|
+
|
6
|
+
describe '#smb_header' do
|
7
|
+
subject(:header) { packet.smb_header }
|
8
|
+
|
9
|
+
it 'is a standard SMB Header' do
|
10
|
+
expect(header).to be_a RubySMB::SMB1::SMBHeader
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should have the command set to SMB_COM_TRANSACTION2' do
|
14
|
+
expect(header.command).to eq RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should not have the response flag set' do
|
18
|
+
expect(header.flags.reply).to eq 0
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#parameter_block' do
|
23
|
+
subject(:parameter_block) { packet.parameter_block }
|
24
|
+
|
25
|
+
it 'is a standard ParameterBlock' do
|
26
|
+
expect(parameter_block).to be_a RubySMB::SMB1::Packet::Trans2::Request::ParameterBlock
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should have the setup set to the QUERY_FS_INFORMATION subcommand' do
|
30
|
+
expect(parameter_block.setup).to include RubySMB::SMB1::Packet::Trans2::Subcommands::QUERY_FS_INFORMATION
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#data_block' do
|
35
|
+
subject(:data_block) { packet.data_block }
|
36
|
+
|
37
|
+
it 'is a standard DataBlock' do
|
38
|
+
expect(data_block).to be_a RubySMB::SMB1::DataBlock
|
39
|
+
end
|
40
|
+
|
41
|
+
it { is_expected.to respond_to :name }
|
42
|
+
it { is_expected.to respond_to :trans2_parameters }
|
43
|
+
it { is_expected.to_not respond_to :trans2_data }
|
44
|
+
|
45
|
+
it 'should keep #trans2_parameters 4-byte aligned' do
|
46
|
+
expect(data_block.trans2_parameters.abs_offset % 4).to eq 0
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#trans2_parameters' do
|
50
|
+
subject(:parameters) { data_block.trans2_parameters }
|
51
|
+
|
52
|
+
it { is_expected.to respond_to :information_level }
|
53
|
+
|
54
|
+
describe '#information_level' do
|
55
|
+
it 'is a 16-bit field' do
|
56
|
+
expect(parameters.information_level).to be_a BinData::Uint16le
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
@@ -0,0 +1,88 @@
|
|
1
|
+
RSpec.describe RubySMB::SMB1::Packet::Trans2::QueryFsInformationResponse do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
describe '#smb_header' do
|
5
|
+
subject(:header) { packet.smb_header }
|
6
|
+
|
7
|
+
it 'is a standard SMB Header' do
|
8
|
+
expect(header).to be_a RubySMB::SMB1::SMBHeader
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should have the command set to SMB_COM_TRANSACTION2' do
|
12
|
+
expect(header.command).to eq RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should have the response flag set' do
|
16
|
+
expect(header.flags.reply).to eq 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#parameter_block' do
|
21
|
+
subject(:parameter_block) { packet.parameter_block }
|
22
|
+
|
23
|
+
it 'should have the setup set to the QUERY_FS_INFORMATION subcommand' do
|
24
|
+
expect(parameter_block.setup).to include RubySMB::SMB1::Packet::Trans2::Subcommands::QUERY_FS_INFORMATION
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#data_block' do
|
29
|
+
subject(:data_block) { packet.data_block }
|
30
|
+
|
31
|
+
it 'is a standard DataBlock' do
|
32
|
+
expect(data_block).to be_a RubySMB::SMB1::DataBlock
|
33
|
+
end
|
34
|
+
|
35
|
+
it { is_expected.to respond_to :name }
|
36
|
+
it { is_expected.to respond_to :trans2_parameters }
|
37
|
+
it { is_expected.to respond_to :trans2_data }
|
38
|
+
|
39
|
+
it 'should keep #trans2_parameters 4-byte aligned' do
|
40
|
+
expect(data_block.trans2_parameters.abs_offset % 4).to eq 0
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#trans2_parameters' do
|
44
|
+
subject(:parameters) { data_block.trans2_parameters }
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#trans2_data' do
|
48
|
+
subject(:data) { data_block.trans2_data }
|
49
|
+
|
50
|
+
it { is_expected.to respond_to :buffer }
|
51
|
+
|
52
|
+
describe '#buffer' do
|
53
|
+
it 'is a String field' do
|
54
|
+
expect(data.buffer).to be_a BinData::String
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'when the buffer is empty' do
|
59
|
+
before :each do
|
60
|
+
data.buffer = ''
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should not be padded' do
|
64
|
+
expect(data_block.pad2.num_bytes).to eq 0
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should read its own binary representation' do
|
68
|
+
expect(packet.class.read(packet.to_binary_s).data_block.trans2_data.buffer).to eq ''
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'when the buffer is not empty' do
|
73
|
+
before :each do
|
74
|
+
data.buffer = 'test'
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should be padded to a 4-byte boundary' do
|
78
|
+
expect(data_block.trans2_data.abs_offset % 4).to eq 0
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should read its own binary representation' do
|
82
|
+
expect(packet.class.read(packet.to_binary_s).data_block.trans2_data.buffer).to eq 'test'
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
include RubySMB::Fscc::FileInformation
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::SMB1::Packet::Trans2::QueryPathInformationRequest do
|
4
|
+
subject(:packet) { described_class.new }
|
5
|
+
|
6
|
+
describe '#smb_header' do
|
7
|
+
subject(:header) { packet.smb_header }
|
8
|
+
|
9
|
+
it 'is a standard SMB Header' do
|
10
|
+
expect(header).to be_a RubySMB::SMB1::SMBHeader
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should have the command set to SMB_COM_TRANSACTION2' do
|
14
|
+
expect(header.command).to eq RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should not have the response flag set' do
|
18
|
+
expect(header.flags.reply).to eq 0
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#parameter_block' do
|
23
|
+
subject(:parameter_block) { packet.parameter_block }
|
24
|
+
|
25
|
+
it 'is a standard ParameterBlock' do
|
26
|
+
expect(parameter_block).to be_a RubySMB::SMB1::Packet::Trans2::Request::ParameterBlock
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should have the setup set to the QUERY_PATH_INFORMATION subcommand' do
|
30
|
+
expect(parameter_block.setup).to include RubySMB::SMB1::Packet::Trans2::Subcommands::QUERY_PATH_INFORMATION
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#data_block' do
|
35
|
+
subject(:data_block) { packet.data_block }
|
36
|
+
|
37
|
+
it 'is a standard DataBlock' do
|
38
|
+
expect(data_block).to be_a RubySMB::SMB1::DataBlock
|
39
|
+
end
|
40
|
+
|
41
|
+
it { is_expected.to respond_to :name }
|
42
|
+
it { is_expected.to respond_to :trans2_parameters }
|
43
|
+
it { is_expected.to respond_to :trans2_data }
|
44
|
+
|
45
|
+
it 'should keep #trans2_parameters 4-byte aligned' do
|
46
|
+
expect(data_block.trans2_parameters.abs_offset % 4).to eq 0
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should keep #trans2_data 4-byte aligned' do
|
50
|
+
data_block.trans2_parameters.information_level = FILE_DISPOSITION_INFORMATION + SMB_INFO_PASSTHROUGH
|
51
|
+
expect(data_block.trans2_data.abs_offset % 4).to eq 0 if data_block.trans2_data.num_bytes != 0
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#trans2_parameters' do
|
55
|
+
subject(:parameters) { data_block.trans2_parameters }
|
56
|
+
|
57
|
+
it { is_expected.to respond_to :information_level }
|
58
|
+
it { is_expected.to respond_to :filename }
|
59
|
+
|
60
|
+
describe '#information_level' do
|
61
|
+
it 'is a 16-bit field' do
|
62
|
+
expect(parameters.information_level).to be_a BinData::Uint16le
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#filename' do
|
67
|
+
it 'is a BinData::Choice' do
|
68
|
+
expect(parameters.filename).to be_a BinData::Choice
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'responds to #encode' do
|
72
|
+
expect(parameters.filename).to respond_to :encode
|
73
|
+
expect(parameters.filename.encode).to be_a String
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
@@ -0,0 +1,96 @@
|
|
1
|
+
RSpec.describe RubySMB::SMB1::Packet::Trans2::QueryPathInformationResponse do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
describe '#smb_header' do
|
5
|
+
subject(:header) { packet.smb_header }
|
6
|
+
|
7
|
+
it 'is a standard SMB Header' do
|
8
|
+
expect(header).to be_a RubySMB::SMB1::SMBHeader
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should have the command set to SMB_COM_TRANSACTION2' do
|
12
|
+
expect(header.command).to eq RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should have the response flag set' do
|
16
|
+
expect(header.flags.reply).to eq 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#parameter_block' do
|
21
|
+
subject(:parameter_block) { packet.parameter_block }
|
22
|
+
|
23
|
+
it 'should have the setup set to the QUERY_PATH_INFORMATION subcommand' do
|
24
|
+
expect(parameter_block.setup).to include RubySMB::SMB1::Packet::Trans2::Subcommands::QUERY_PATH_INFORMATION
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#data_block' do
|
29
|
+
subject(:data_block) { packet.data_block }
|
30
|
+
|
31
|
+
it 'is a standard DataBlock' do
|
32
|
+
expect(data_block).to be_a RubySMB::SMB1::DataBlock
|
33
|
+
end
|
34
|
+
|
35
|
+
it { is_expected.to respond_to :name }
|
36
|
+
it { is_expected.to respond_to :trans2_parameters }
|
37
|
+
it { is_expected.to respond_to :trans2_data }
|
38
|
+
|
39
|
+
it 'should keep #trans2_parameters 4-byte aligned' do
|
40
|
+
expect(data_block.trans2_parameters.abs_offset % 4).to eq 0
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#trans2_parameters' do
|
44
|
+
subject(:parameters) { data_block.trans2_parameters }
|
45
|
+
|
46
|
+
it { is_expected.to respond_to :ea_error_offset }
|
47
|
+
|
48
|
+
describe '#ea_error_offset' do
|
49
|
+
it 'is a 16-bit field' do
|
50
|
+
expect(parameters.ea_error_offset).to be_a BinData::Uint16le
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#trans2_data' do
|
56
|
+
subject(:data) { data_block.trans2_data }
|
57
|
+
|
58
|
+
it { is_expected.to respond_to :buffer }
|
59
|
+
|
60
|
+
describe '#buffer' do
|
61
|
+
it 'is a String field' do
|
62
|
+
expect(data.buffer).to be_a BinData::String
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'when the buffer is empty' do
|
67
|
+
before :each do
|
68
|
+
data.buffer = ''
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should not be padded' do
|
72
|
+
expect(data_block.pad2.num_bytes).to eq 0
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should read its own binary representation' do
|
76
|
+
expect(packet.class.read(packet.to_binary_s).data_block.trans2_data.buffer).to eq ''
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'when the buffer is not empty' do
|
81
|
+
before :each do
|
82
|
+
data.buffer = 'test'
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should be padded to a 4-byte boundary' do
|
86
|
+
expect(data_block.trans2_data.abs_offset % 4).to eq 0
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should read its own binary representation' do
|
90
|
+
expect(packet.class.read(packet.to_binary_s).data_block.trans2_data.buffer).to eq 'test'
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
@@ -75,7 +75,7 @@ RSpec.describe RubySMB::SMB1::Packet::Trans2::Request do
|
|
75
75
|
subject(:data_block) { packet.data_block }
|
76
76
|
|
77
77
|
it 'is a standard DataBlock' do
|
78
|
-
expect(data_block).to be_a
|
78
|
+
expect(data_block).to be_a BinData::Choice
|
79
79
|
end
|
80
80
|
|
81
81
|
it { is_expected.to respond_to :name }
|
@@ -88,7 +88,7 @@ RSpec.describe RubySMB::SMB1::Packet::Trans2::Request do
|
|
88
88
|
|
89
89
|
it 'should keep #trans2_data 4-byte aligned' do
|
90
90
|
data_block.trans2_parameters = 'a'
|
91
|
-
expect(data_block.trans2_data.abs_offset % 4).to eq 0
|
91
|
+
expect(data_block.trans2_data.abs_offset % 4).to eq 0 if data_block.trans2_data.num_bytes != 0
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
@@ -44,7 +44,7 @@ RSpec.describe RubySMB::SMB1::Packet::Trans2::Response do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
describe 'parameter_offset' do
|
47
|
-
it '
|
47
|
+
it 'contains the absolute_offset to the data_block trans2_parameters field' do
|
48
48
|
expect(parameter_block.parameter_offset).to eq packet.data_block.trans2_parameters.abs_offset
|
49
49
|
end
|
50
50
|
end
|
@@ -67,7 +67,7 @@ RSpec.describe RubySMB::SMB1::Packet::Trans2::Response do
|
|
67
67
|
subject(:data_block) { packet.data_block }
|
68
68
|
|
69
69
|
it 'is a Trans2 DataBlock' do
|
70
|
-
expect(data_block).to be_a
|
70
|
+
expect(data_block).to be_a BinData::Choice
|
71
71
|
end
|
72
72
|
|
73
73
|
it { is_expected.to respond_to :trans2_parameters }
|
@@ -79,7 +79,7 @@ RSpec.describe RubySMB::SMB1::Packet::Trans2::Response do
|
|
79
79
|
|
80
80
|
it 'should keep #trans2_data 4-byte aligned' do
|
81
81
|
data_block.trans2_parameters = 'a'
|
82
|
-
expect(data_block.trans2_data.abs_offset % 4).to eq 0
|
82
|
+
expect(data_block.trans2_data.abs_offset % 4).to eq 0 if data_block.trans2_data.num_bytes != 0
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
@@ -26,7 +26,7 @@ RSpec.describe RubySMB::SMB1::Packet::Trans2::SetFileInformationRequest do
|
|
26
26
|
expect(parameter_block).to be_a RubySMB::SMB1::Packet::Trans2::Request::ParameterBlock
|
27
27
|
end
|
28
28
|
|
29
|
-
it 'should have the setup set to the
|
29
|
+
it 'should have the setup set to the SET_FILE_INFORMATION subcommand' do
|
30
30
|
expect(parameter_block.setup).to include RubySMB::SMB1::Packet::Trans2::Subcommands::SET_FILE_INFORMATION
|
31
31
|
end
|
32
32
|
end
|
@@ -47,7 +47,8 @@ RSpec.describe RubySMB::SMB1::Packet::Trans2::SetFileInformationRequest do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'should keep #trans2_data 4-byte aligned' do
|
50
|
-
|
50
|
+
data_block.trans2_parameters.information_level = FILE_DISPOSITION_INFORMATION + SMB_INFO_PASSTHROUGH
|
51
|
+
expect(data_block.trans2_data.abs_offset % 4).to eq 0 if data_block.trans2_data.num_bytes != 0
|
51
52
|
end
|
52
53
|
|
53
54
|
describe '#trans2_parameters' do
|
@@ -8,7 +8,7 @@ RSpec.describe RubySMB::SMB1::Packet::Trans2::SetFileInformationResponse do
|
|
8
8
|
expect(header).to be_a RubySMB::SMB1::SMBHeader
|
9
9
|
end
|
10
10
|
|
11
|
-
it 'should have the command set to
|
11
|
+
it 'should have the command set to SMB_COM_TRANSACTION2' do
|
12
12
|
expect(header.command).to eq RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
13
13
|
end
|
14
14
|
|
@@ -20,7 +20,7 @@ RSpec.describe RubySMB::SMB1::Packet::Trans2::SetFileInformationResponse do
|
|
20
20
|
describe '#parameter_block' do
|
21
21
|
subject(:parameter_block) { packet.parameter_block }
|
22
22
|
|
23
|
-
it 'should have the setup set to the
|
23
|
+
it 'should have the setup set to the SET_FILE_INFORMATION subcommand' do
|
24
24
|
expect(parameter_block.setup).to include RubySMB::SMB1::Packet::Trans2::Subcommands::SET_FILE_INFORMATION
|
25
25
|
end
|
26
26
|
end
|
@@ -28,7 +28,12 @@ RSpec.describe RubySMB::SMB1::Packet::Trans2::SetFileInformationResponse do
|
|
28
28
|
describe '#data_block' do
|
29
29
|
subject(:data_block) { packet.data_block }
|
30
30
|
|
31
|
+
it 'is a standard DataBlock' do
|
32
|
+
expect(data_block).to be_a RubySMB::SMB1::DataBlock
|
33
|
+
end
|
34
|
+
|
31
35
|
it { is_expected.to respond_to :trans2_parameters }
|
36
|
+
it { is_expected.to_not respond_to :trans2_data }
|
32
37
|
|
33
38
|
it 'should keep #trans2_parameters 4-byte aligned' do
|
34
39
|
expect(data_block.trans2_parameters.abs_offset % 4).to eq 0
|
@@ -95,7 +95,7 @@ RSpec.describe RubySMB::SMB1::Tree do
|
|
95
95
|
describe 'filename' do
|
96
96
|
it 'takes the filename as an argument' do
|
97
97
|
allow(client).to receive(:send_recv) do |packet|
|
98
|
-
expect(packet.data_block.file_name).to eq(filename)
|
98
|
+
expect(packet.data_block.file_name.to_binary_s).to eq(filename)
|
99
99
|
nt_create_andx_response.to_binary_s
|
100
100
|
end
|
101
101
|
tree.open_file(filename: filename)
|
@@ -103,7 +103,7 @@ RSpec.describe RubySMB::SMB1::Tree do
|
|
103
103
|
|
104
104
|
it 'adds the null termination to the filename if missing' do
|
105
105
|
allow(client).to receive(:send_recv) do |packet|
|
106
|
-
expect(packet.data_block.file_name).to eq(filename)
|
106
|
+
expect(packet.data_block.file_name.to_binary_s).to eq(filename)
|
107
107
|
nt_create_andx_response.to_binary_s
|
108
108
|
end
|
109
109
|
tree.open_file(filename: filename.chop)
|
@@ -113,7 +113,7 @@ RSpec.describe RubySMB::SMB1::Tree do
|
|
113
113
|
unicode_filename = filename.encode('UTF-16LE')
|
114
114
|
nt_create_andx_req.smb_header.flags2.unicode = 1
|
115
115
|
allow(client).to receive(:send_recv) do |packet|
|
116
|
-
expect(packet.data_block.file_name).to eq(unicode_filename.b)
|
116
|
+
expect(packet.data_block.file_name.to_binary_s).to eq(unicode_filename.b)
|
117
117
|
nt_create_andx_response.to_binary_s
|
118
118
|
end
|
119
119
|
tree.open_file(filename: unicode_filename.chop)
|
@@ -69,7 +69,7 @@ RSpec.describe RubySMB::SMB2::Packet::TransformHeader do
|
|
69
69
|
it 'raises the expected exception if the given algorithm is invalid' do
|
70
70
|
expect { packet.decrypt(key, algorithm: 'RC4') }.to raise_error(
|
71
71
|
RubySMB::Error::EncryptionError,
|
72
|
-
'Error while decrypting with \'RC4\' (ArgumentError: Invalid algorithm, must be
|
72
|
+
'Error while decrypting with \'RC4\' (ArgumentError: Invalid algorithm, must be one of AES-128-CCM, AES-128-GCM, AES-256-CCM, or AES-256-GCM)'
|
73
73
|
)
|
74
74
|
end
|
75
75
|
|
@@ -141,7 +141,7 @@ RSpec.describe RubySMB::SMB2::Packet::TransformHeader do
|
|
141
141
|
it 'raises the expected exception if the given algorithm is invalid' do
|
142
142
|
expect { packet.encrypt(struct, key, algorithm: 'RC4') }.to raise_error(
|
143
143
|
RubySMB::Error::EncryptionError,
|
144
|
-
'Error while encrypting with \'RC4\' (ArgumentError: Invalid algorithm, must be
|
144
|
+
'Error while encrypting with \'RC4\' (ArgumentError: Invalid algorithm, must be one of AES-128-CCM, AES-128-GCM, AES-256-CCM, or AES-256-GCM)'
|
145
145
|
)
|
146
146
|
end
|
147
147
|
|
data.tar.gz.sig
CHANGED
Binary file
|