ruby_smb 0.0.12 → 0.0.13
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 +1 -2
- data/lib/ruby_smb/client/authentication.rb +1 -1
- data/lib/ruby_smb/client/echo.rb +36 -0
- data/lib/ruby_smb/client/tree_connect.rb +1 -1
- data/lib/ruby_smb/client.rb +17 -0
- data/lib/ruby_smb/dispatcher/socket.rb +21 -14
- data/lib/ruby_smb/error.rb +3 -0
- data/lib/ruby_smb/field/ea_info_array.rb +58 -0
- data/lib/ruby_smb/field/extended_attribute_flag.rb +10 -0
- data/lib/ruby_smb/field/file_full_ea_info.rb +15 -0
- data/lib/ruby_smb/field/security_descriptor.rb +42 -0
- data/lib/ruby_smb/field/smb_fea.rb +14 -0
- data/lib/ruby_smb/field/smb_fea_list.rb +13 -0
- data/lib/ruby_smb/field/utime.rb +54 -0
- data/lib/ruby_smb/field.rb +7 -0
- data/lib/ruby_smb/generic_packet.rb +8 -4
- data/lib/ruby_smb/impersonation_levels.rb +22 -0
- data/lib/ruby_smb/smb1/bit_field/create_options.rb +38 -0
- data/lib/ruby_smb/smb1/bit_field/file_access_mask.rb +1 -1
- data/lib/ruby_smb/smb1/bit_field/open2_access_mode.rb +42 -0
- data/lib/ruby_smb/smb1/bit_field/open2_flags.rb +18 -0
- data/lib/ruby_smb/smb1/bit_field/open2_open_mode.rb +17 -0
- data/lib/ruby_smb/smb1/bit_field/share_access.rb +20 -0
- data/lib/ruby_smb/smb1/bit_field/smb_ext_file_attributes.rb +35 -0
- data/lib/ruby_smb/smb1/bit_field/smb_file_attributes.rb +26 -0
- data/lib/ruby_smb/smb1/bit_field/smb_nmpipe_status.rb +19 -0
- data/lib/ruby_smb/smb1/bit_field/trans2_flags.rb +15 -0
- data/lib/ruby_smb/smb1/bit_field.rb +9 -0
- data/lib/ruby_smb/smb1/commands.rb +10 -6
- data/lib/ruby_smb/smb1/create_actions.rb +22 -0
- data/lib/ruby_smb/smb1/dispositions.rb +36 -0
- data/lib/ruby_smb/smb1/oplock_levels.rb +19 -0
- data/lib/ruby_smb/smb1/packet/echo_request.rb +30 -0
- data/lib/ruby_smb/smb1/packet/echo_response.rb +31 -0
- data/lib/ruby_smb/smb1/packet/empty_packet.rb +14 -0
- data/lib/ruby_smb/smb1/packet/nt_trans/create_request.rb +85 -0
- data/lib/ruby_smb/smb1/packet/nt_trans/create_response.rb +61 -0
- data/lib/ruby_smb/smb1/packet/nt_trans/request.rb +47 -0
- data/lib/ruby_smb/smb1/packet/nt_trans/response.rb +44 -0
- data/lib/ruby_smb/smb1/packet/nt_trans/subcommands.rb +11 -0
- data/lib/ruby_smb/smb1/packet/nt_trans.rb +16 -0
- data/lib/ruby_smb/smb1/packet/trans2/data_block.rb +32 -0
- data/lib/ruby_smb/smb1/packet/trans2/open2_request.rb +60 -0
- data/lib/ruby_smb/smb1/packet/trans2/open2_response.rb +65 -0
- data/lib/ruby_smb/smb1/packet/trans2/request.rb +52 -0
- data/lib/ruby_smb/smb1/packet/trans2/request_secondary.rb +39 -0
- data/lib/ruby_smb/smb1/packet/trans2/response.rb +48 -0
- data/lib/ruby_smb/smb1/packet/trans2/subcommands.rb +12 -0
- data/lib/ruby_smb/smb1/packet/trans2.rb +18 -0
- data/lib/ruby_smb/smb1/packet.rb +5 -1
- data/lib/ruby_smb/smb1.rb +3 -0
- data/lib/ruby_smb/smb2/bit_field/{share_capabailities.rb → share_capabilities.rb} +0 -0
- data/lib/ruby_smb/smb2/bit_field/{smb2_capabailities.rb → smb2_capabilities.rb} +0 -0
- data/lib/ruby_smb/smb2/bit_field.rb +2 -2
- data/lib/ruby_smb/smb2/packet/echo_request.rb +21 -0
- data/lib/ruby_smb/smb2/packet/echo_response.rb +22 -0
- data/lib/ruby_smb/smb2/packet.rb +2 -0
- data/lib/ruby_smb/version.rb +1 -1
- data/ruby_smb.gemspec +2 -0
- data/spec/lib/ruby_smb/client_spec.rb +46 -0
- data/spec/lib/ruby_smb/field/ea_info_array_spec.rb +51 -0
- data/spec/lib/ruby_smb/field/extended_attribute_flag_spec.rb +16 -0
- data/spec/lib/ruby_smb/field/file_full_ea_info_spec.rb +35 -0
- data/spec/lib/ruby_smb/field/security_descriptor.rb +194 -0
- data/spec/lib/ruby_smb/field/smb_fea_list_spec.rb +38 -0
- data/spec/lib/ruby_smb/field/smb_fea_spec.rb +27 -0
- data/spec/lib/ruby_smb/field/utime_spec.rb +59 -0
- data/spec/lib/ruby_smb/smb1/bit_field/create_options_spec.rb +181 -0
- data/spec/lib/ruby_smb/smb1/bit_field/open2_access_mode_spec.rb +81 -0
- data/spec/lib/ruby_smb/smb1/bit_field/open2_flags_spec.rb +62 -0
- data/spec/lib/ruby_smb/smb1/bit_field/open2_open_mode_spec.rb +27 -0
- data/spec/lib/ruby_smb/smb1/bit_field/share_access_spec.rb +38 -0
- data/spec/lib/ruby_smb/smb1/bit_field/smb_ext_file_attributes_spec.rb +144 -0
- data/spec/lib/ruby_smb/smb1/bit_field/smb_file_attributes_spec.rb +113 -0
- data/spec/lib/ruby_smb/smb1/bit_field/smb_nmpipe_status_spec.rb +53 -0
- data/spec/lib/ruby_smb/smb1/bit_field/trans2_flags_spec.rb +28 -0
- data/spec/lib/ruby_smb/smb1/packet/echo_request_spec.rb +44 -0
- data/spec/lib/ruby_smb/smb1/packet/echo_response_spec.rb +44 -0
- data/spec/lib/ruby_smb/smb1/packet/error_packet_spec.rb +1 -1
- data/spec/lib/ruby_smb/smb1/packet/nt_trans/create_request_spec.rb +194 -0
- data/spec/lib/ruby_smb/smb1/packet/nt_trans/create_response_spec.rb +124 -0
- data/spec/lib/ruby_smb/smb1/packet/nt_trans/request_spec.rb +91 -0
- data/spec/lib/ruby_smb/smb1/packet/nt_trans/response_spec.rb +75 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/open2_request_spec.rb +112 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/open2_response_spec.rb +107 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/request_secondary_spec.rb +77 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/request_spec.rb +98 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/response_spec.rb +88 -0
- data/spec/lib/ruby_smb/smb2/packet/echo_request_spec.rb +30 -0
- data/spec/lib/ruby_smb/smb2/packet/echo_response_spec.rb +30 -0
- data/spec/lib/ruby_smb/smb2/packet/negotiate_request_spec.rb +1 -1
- data/spec/lib/ruby_smb/smb2/packet/negotiate_response_spec.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +104 -7
- metadata.gz.sig +0 -0
- data/lib/ruby_smb/smb1/packet/error_packet.rb +0 -14
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::SMB1::Packet::NtTrans::CreateResponse do
|
4
|
+
|
5
|
+
subject(:packet) { described_class.new }
|
6
|
+
|
7
|
+
describe '#smb_header' do
|
8
|
+
subject(:header) { packet.smb_header }
|
9
|
+
|
10
|
+
it 'is a standard SMB Header' do
|
11
|
+
expect(header).to be_a RubySMB::SMB1::SMBHeader
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should have the command set to SMB_COM_NEGOTIATE' do
|
15
|
+
expect(header.command).to eq RubySMB::SMB1::Commands::SMB_COM_NT_TRANSACT
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should have the response flag set' do
|
19
|
+
expect(header.flags.reply).to eq 1
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#parameter_block' do
|
24
|
+
subject(:parameter_block) { packet.parameter_block }
|
25
|
+
|
26
|
+
it 'is a NTTrans Response ParameterBlock' do
|
27
|
+
expect(parameter_block).to be_a RubySMB::SMB1::Packet::NtTrans::Response::ParameterBlock
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'parameter_count' do
|
31
|
+
it 'is a count of bytes in the data_block trans2_parameters field' do
|
32
|
+
expect(parameter_block.parameter_count).to eq packet.data_block.trans2_parameters.do_num_bytes
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'parameter_offset' do
|
37
|
+
it ' contains the absolute_offset to the data_block trans2_parameters field' do
|
38
|
+
expect(parameter_block.parameter_offset).to eq packet.data_block.trans2_parameters.abs_offset
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe 'data_count' do
|
43
|
+
it 'is a count of bytes in the data_block trans2_data field' do
|
44
|
+
expect(parameter_block.data_count).to eq packet.data_block.trans2_data.do_num_bytes
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'data_offset' do
|
49
|
+
it 'contains the absolute_offset to the data_block trans2_data field' do
|
50
|
+
expect(parameter_block.data_offset).to eq packet.data_block.trans2_data.abs_offset
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#data_block' do
|
56
|
+
subject(:data_block) { packet.data_block }
|
57
|
+
|
58
|
+
it { is_expected.to be_a RubySMB::SMB1::Packet::Trans2::DataBlock }
|
59
|
+
|
60
|
+
describe '#trans2_data' do
|
61
|
+
it 'should be a 0-byte string' do
|
62
|
+
expect(data_block.trans2_data.length).to eq 0
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#trans2_parameters' do
|
67
|
+
subject(:parameters) { data_block.trans2_parameters }
|
68
|
+
|
69
|
+
it { is_expected.to respond_to :oplock_level }
|
70
|
+
it { is_expected.to respond_to :fid }
|
71
|
+
it { is_expected.to respond_to :create_action }
|
72
|
+
it { is_expected.to respond_to :ea_error_offset }
|
73
|
+
it { is_expected.to respond_to :creation_time }
|
74
|
+
it { is_expected.to respond_to :last_access_time }
|
75
|
+
it { is_expected.to respond_to :last_write_time }
|
76
|
+
it { is_expected.to respond_to :last_change_time }
|
77
|
+
it { is_expected.to respond_to :ext_file_attributes }
|
78
|
+
it { is_expected.to respond_to :allocation_size }
|
79
|
+
it { is_expected.to respond_to :end_of_file }
|
80
|
+
it { is_expected.to respond_to :resource_type }
|
81
|
+
it { is_expected.to respond_to :nmpipe_status }
|
82
|
+
it { is_expected.to respond_to :directory }
|
83
|
+
|
84
|
+
describe '#creation_time' do
|
85
|
+
it 'is a FileTime field' do
|
86
|
+
expect(parameters.creation_time).to be_a RubySMB::Field::FileTime
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '#last_access_time' do
|
91
|
+
it 'is a FileTime field' do
|
92
|
+
expect(parameters.last_access_time).to be_a RubySMB::Field::FileTime
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe '#last_write_time' do
|
97
|
+
it 'is a FileTime field' do
|
98
|
+
expect(parameters.last_write_time).to be_a RubySMB::Field::FileTime
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe '#last_change_time' do
|
103
|
+
it 'is a FileTime field' do
|
104
|
+
expect(parameters.last_change_time).to be_a RubySMB::Field::FileTime
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe '#ext_file_attributes' do
|
109
|
+
it 'is a SmbExtFileAttributes field' do
|
110
|
+
expect(parameters.ext_file_attributes).to be_a RubySMB::SMB1::BitField::SmbExtFileAttributes
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe '#nmpipe_status' do
|
115
|
+
it 'is a SmbnmpipeStatus field' do
|
116
|
+
expect(parameters.nmpipe_status).to be_a RubySMB::SMB1::BitField::SmbNmpipeStatus
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::SMB1::Packet::NtTrans::Request do
|
4
|
+
|
5
|
+
subject(:packet) { described_class.new }
|
6
|
+
|
7
|
+
describe '#smb_header' do
|
8
|
+
subject(:header) { packet.smb_header }
|
9
|
+
|
10
|
+
it 'is a standard SMB Header' do
|
11
|
+
expect(header).to be_a RubySMB::SMB1::SMBHeader
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should have the command set to SMB_COM_NEGOTIATE' do
|
15
|
+
expect(header.command).to eq RubySMB::SMB1::Commands::SMB_COM_NT_TRANSACT
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should not have the response flag set' do
|
19
|
+
expect(header.flags.reply).to eq 0
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#parameter_block' do
|
24
|
+
subject(:parameter_block) { packet.parameter_block }
|
25
|
+
|
26
|
+
it 'is a standard ParameterBlock' do
|
27
|
+
expect(parameter_block).to be_a RubySMB::SMB1::ParameterBlock
|
28
|
+
end
|
29
|
+
|
30
|
+
it { is_expected.to respond_to :total_parameter_count }
|
31
|
+
it { is_expected.to respond_to :total_data_count }
|
32
|
+
it { is_expected.to respond_to :max_parameter_count }
|
33
|
+
it { is_expected.to respond_to :max_data_count }
|
34
|
+
it { is_expected.to respond_to :max_setup_count }
|
35
|
+
it { is_expected.to respond_to :function }
|
36
|
+
it { is_expected.to respond_to :parameter_count }
|
37
|
+
it { is_expected.to respond_to :parameter_offset }
|
38
|
+
it { is_expected.to respond_to :data_count }
|
39
|
+
it { is_expected.to respond_to :data_offset }
|
40
|
+
it { is_expected.to respond_to :setup_count }
|
41
|
+
|
42
|
+
|
43
|
+
describe 'parameter_count' do
|
44
|
+
it 'is a count of bytes in the data_block trans2_parameters field' do
|
45
|
+
packet.data_block.trans2_parameters = "\x00\x01\x02\x03"
|
46
|
+
expect(parameter_block.parameter_count).to eq 4
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe 'parameter_offset' do
|
51
|
+
it ' contains the absolute_offset to the data_block trans2_parameters field' do
|
52
|
+
expect(parameter_block.parameter_offset).to eq packet.data_block.trans2_parameters.abs_offset
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe 'data_count' do
|
57
|
+
it 'is a count of bytes in the data_block trans2_data field' do
|
58
|
+
packet.data_block.trans2_data = "\x00\x01\x02\x03"
|
59
|
+
expect(parameter_block.data_count).to eq 4
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe 'data_offset' do
|
64
|
+
it 'contains the absolute_offset to the data_block trans2_data field' do
|
65
|
+
expect(parameter_block.data_offset).to eq packet.data_block.trans2_data.abs_offset
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '#data_block' do
|
71
|
+
subject(:data_block) { packet.data_block }
|
72
|
+
|
73
|
+
it 'is a Trans2 style DataBlock' do
|
74
|
+
expect(data_block).to be_a RubySMB::SMB1::Packet::Trans2::DataBlock
|
75
|
+
end
|
76
|
+
|
77
|
+
it { is_expected.to respond_to :trans2_parameters }
|
78
|
+
it { is_expected.to respond_to :trans2_data }
|
79
|
+
|
80
|
+
it 'should keep #trans2_parameters 4-byte aligned' do
|
81
|
+
expect(data_block.trans2_parameters.abs_offset % 4).to eq 0
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should keep #trans2_data 4-byte aligned' do
|
85
|
+
expect(data_block.trans2_data.abs_offset % 4).to eq 0
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::SMB1::Packet::NtTrans::Response do
|
4
|
+
|
5
|
+
subject(:packet) { described_class.new }
|
6
|
+
|
7
|
+
describe '#smb_header' do
|
8
|
+
subject(:header) { packet.smb_header }
|
9
|
+
|
10
|
+
it 'is a standard SMB Header' do
|
11
|
+
expect(header).to be_a RubySMB::SMB1::SMBHeader
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should have the command set to SMB_COM_NEGOTIATE' do
|
15
|
+
expect(header.command).to eq RubySMB::SMB1::Commands::SMB_COM_NT_TRANSACT
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should have the response flag set' do
|
19
|
+
expect(header.flags.reply).to eq 1
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#parameter_block' do
|
24
|
+
subject(:parameter_block) { packet.parameter_block }
|
25
|
+
|
26
|
+
it 'is a standard ParameterBlock' do
|
27
|
+
expect(parameter_block).to be_a RubySMB::SMB1::ParameterBlock
|
28
|
+
end
|
29
|
+
|
30
|
+
it { is_expected.to respond_to :total_parameter_count }
|
31
|
+
it { is_expected.to respond_to :total_data_count }
|
32
|
+
it { is_expected.to respond_to :parameter_count }
|
33
|
+
it { is_expected.to respond_to :parameter_offset }
|
34
|
+
it { is_expected.to respond_to :data_count }
|
35
|
+
it { is_expected.to respond_to :data_offset }
|
36
|
+
it { is_expected.to respond_to :setup_count }
|
37
|
+
|
38
|
+
|
39
|
+
describe 'parameter_count' do
|
40
|
+
it 'is a count of bytes in the data_block trans2_parameters field' do
|
41
|
+
packet.data_block.trans2_parameters = "\x00\x01\x02\x03"
|
42
|
+
expect(parameter_block.parameter_count).to eq 4
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe 'parameter_offset' do
|
47
|
+
it ' contains the absolute_offset to the data_block trans2_parameters field' do
|
48
|
+
expect(parameter_block.parameter_offset).to eq packet.data_block.trans2_parameters.abs_offset
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'data_count' do
|
53
|
+
it 'is a count of bytes in the data_block trans2_data field' do
|
54
|
+
packet.data_block.trans2_data = "\x00\x01\x02\x03"
|
55
|
+
expect(parameter_block.data_count).to eq 4
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe 'data_offset' do
|
60
|
+
it 'contains the absolute_offset to the data_block trans2_data field' do
|
61
|
+
expect(parameter_block.data_offset).to eq packet.data_block.trans2_data.abs_offset
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#data_block' do
|
67
|
+
subject(:data_block) { packet.data_block }
|
68
|
+
|
69
|
+
it 'is the same as a NtTrans Request DataBlocjk' do
|
70
|
+
expect(data_block).to be_a RubySMB::SMB1::Packet::NtTrans::Request::DataBlock
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::SMB1::Packet::Trans2::Open2Request do
|
4
|
+
|
5
|
+
subject(:packet) { described_class.new }
|
6
|
+
|
7
|
+
describe '#smb_header' do
|
8
|
+
subject(:header) { packet.smb_header }
|
9
|
+
|
10
|
+
it 'is a standard SMB Header' do
|
11
|
+
expect(header).to be_a RubySMB::SMB1::SMBHeader
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should have the command set to SMB_COM_NEGOTIATE' do
|
15
|
+
expect(header.command).to eq RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should not have the response flag set' do
|
19
|
+
expect(header.flags.reply).to eq 0
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#parameter_block' do
|
24
|
+
subject(:parameter_block) { packet.parameter_block }
|
25
|
+
|
26
|
+
it 'is a standard ParameterBlock' do
|
27
|
+
expect(parameter_block).to be_a RubySMB::SMB1::Packet::Trans2::Request::ParameterBlock
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should have the setup set to the OPEN2 subcommand' do
|
31
|
+
expect(parameter_block.setup).to include RubySMB::SMB1::Packet::Trans2::Subcommands::OPEN2
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#data_block' do
|
37
|
+
subject(:data_block) { packet.data_block }
|
38
|
+
|
39
|
+
it 'is a standard DataBlock' do
|
40
|
+
expect(data_block).to be_a RubySMB::SMB1::DataBlock
|
41
|
+
end
|
42
|
+
|
43
|
+
it { is_expected.to respond_to :name }
|
44
|
+
it { is_expected.to respond_to :trans2_parameters }
|
45
|
+
it { is_expected.to respond_to :trans2_data }
|
46
|
+
|
47
|
+
it 'should keep #trans2_parameters 4-byte aligned' do
|
48
|
+
expect(data_block.trans2_parameters.abs_offset % 4).to eq 0
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should keep #trans2_data 4-byte aligned' do
|
52
|
+
expect(data_block.trans2_data.abs_offset % 4).to eq 0
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#trans2_parameters' do
|
56
|
+
subject(:parameters) { data_block.trans2_parameters }
|
57
|
+
|
58
|
+
it { is_expected.to respond_to :flags }
|
59
|
+
it { is_expected.to respond_to :access_mode }
|
60
|
+
it { is_expected.to respond_to :file_attributes }
|
61
|
+
it { is_expected.to respond_to :creation_time }
|
62
|
+
it { is_expected.to respond_to :open_mode }
|
63
|
+
it { is_expected.to respond_to :allocation_size }
|
64
|
+
it { is_expected.to respond_to :filename }
|
65
|
+
|
66
|
+
describe '#flags' do
|
67
|
+
it 'is an open2_flags field' do
|
68
|
+
expect(parameters.flags).to be_a RubySMB::SMB1::BitField::Open2Flags
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#access_mode' do
|
73
|
+
it 'is an open2_access_mode field' do
|
74
|
+
expect(parameters.access_mode).to be_a RubySMB::SMB1::BitField::Open2AccessMode
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#file_attributes' do
|
79
|
+
it 'is a smb_file_attributes field' do
|
80
|
+
expect(parameters.file_attributes).to be_a RubySMB::SMB1::BitField::SmbFileAttributes
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe '#creation_time' do
|
85
|
+
it 'is a utime field' do
|
86
|
+
expect(parameters.creation_time).to be_a RubySMB::Field::Utime
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '#open_mode' do
|
91
|
+
it 'is an open2_open_mode field' do
|
92
|
+
expect(parameters.open_mode).to be_a RubySMB::SMB1::BitField::Open2OpenMode
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe '#trans2_data' do
|
98
|
+
subject(:data) { data_block.trans2_data }
|
99
|
+
|
100
|
+
it { is_expected.to respond_to :extended_attribute_list }
|
101
|
+
|
102
|
+
describe '#extended_attribute_list' do
|
103
|
+
it 'is an smb_fea_list' do
|
104
|
+
expect(data.extended_attribute_list).to be_a RubySMB::Field::SmbFeaList
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::SMB1::Packet::Trans2::Open2Response do
|
4
|
+
|
5
|
+
subject(:packet) { described_class.new }
|
6
|
+
|
7
|
+
describe '#smb_header' do
|
8
|
+
subject(:header) { packet.smb_header }
|
9
|
+
|
10
|
+
it 'is a standard SMB Header' do
|
11
|
+
expect(header).to be_a RubySMB::SMB1::SMBHeader
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should have the command set to SMB_COM_NEGOTIATE' do
|
15
|
+
expect(header.command).to eq RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should have the response flag set' do
|
19
|
+
expect(header.flags.reply).to eq 1
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#parameter_block' do
|
24
|
+
subject(:parameter_block) { packet.parameter_block }
|
25
|
+
|
26
|
+
it 'is a standard Trans2 ParameterBlock' do
|
27
|
+
expect(parameter_block).to be_a RubySMB::SMB1::Packet::Trans2::Response::ParameterBlock
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#data_block' do
|
32
|
+
subject(:data_block) { packet.data_block }
|
33
|
+
|
34
|
+
it 'is a Trans2 DataBlock' do
|
35
|
+
expect(data_block).to be_a RubySMB::SMB1::Packet::Trans2::DataBlock
|
36
|
+
end
|
37
|
+
|
38
|
+
it { is_expected.to respond_to :trans2_parameters }
|
39
|
+
it { is_expected.to respond_to :trans2_data }
|
40
|
+
|
41
|
+
it 'should keep #trans2_parameters 4-byte aligned' do
|
42
|
+
expect(data_block.trans2_parameters.abs_offset % 4).to eq 0
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should keep #trans2_data 4-byte aligned' do
|
46
|
+
expect(data_block.trans2_data.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 be_a RubySMB::SMB1::Packet::Trans2::Open2Response::Trans2Parameters }
|
53
|
+
|
54
|
+
it { is_expected.to respond_to :fid }
|
55
|
+
it { is_expected.to respond_to :file_attributes }
|
56
|
+
it { is_expected.to respond_to :creation_time }
|
57
|
+
it { is_expected.to respond_to :access_mode }
|
58
|
+
it { is_expected.to respond_to :resource_type }
|
59
|
+
it { is_expected.to respond_to :nmpipe_status }
|
60
|
+
it { is_expected.to respond_to :action_taken }
|
61
|
+
it { is_expected.to respond_to :extended_attribute_offset }
|
62
|
+
it { is_expected.to respond_to :extended_attribute_length }
|
63
|
+
|
64
|
+
describe '#access_mode' do
|
65
|
+
it 'is an open2_access_mode field' do
|
66
|
+
expect(parameters.access_mode).to be_a RubySMB::SMB1::BitField::Open2AccessMode
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '#file_attributes' do
|
71
|
+
it 'is a smb_file_attributes field' do
|
72
|
+
expect(parameters.file_attributes).to be_a RubySMB::SMB1::BitField::SmbFileAttributes
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#creation_time' do
|
77
|
+
it 'is a utime field' do
|
78
|
+
expect(parameters.creation_time).to be_a RubySMB::Field::Utime
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe '#smb_nmpipe_status' do
|
83
|
+
it 'is a Named Pipe Status field' do
|
84
|
+
expect(parameters.nmpipe_status).to be_a RubySMB::SMB1::BitField::SmbNmpipeStatus
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe '#action_taken' do
|
89
|
+
subject(:action) { parameters.action_taken}
|
90
|
+
|
91
|
+
it 'is 2-bytes' do
|
92
|
+
expect(action.do_num_bytes).to eq 2
|
93
|
+
end
|
94
|
+
|
95
|
+
describe '#open_result' do
|
96
|
+
it_behaves_like 'bit field with one flag set', :open_result, 'v', 0x0001
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#lock_status' do
|
100
|
+
it_behaves_like 'bit field with one flag set', :lock_status, 'v', 0x8000
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::SMB1::Packet::Trans2::RequestSecondary do
|
4
|
+
|
5
|
+
subject(:packet) { described_class.new }
|
6
|
+
|
7
|
+
describe '#smb_header' do
|
8
|
+
subject(:header) { packet.smb_header }
|
9
|
+
|
10
|
+
it 'is a standard SMB Header' do
|
11
|
+
expect(header).to be_a RubySMB::SMB1::SMBHeader
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should have the command set to SMB_COM_NEGOTIATE' do
|
15
|
+
expect(header.command).to eq RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2_SECONDARY
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should not have the response flag set' do
|
19
|
+
expect(header.flags.reply).to eq 0
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#parameter_block' do
|
24
|
+
subject(:parameter_block) { packet.parameter_block }
|
25
|
+
|
26
|
+
it 'is a standard ParameterBlock' do
|
27
|
+
expect(parameter_block).to be_a RubySMB::SMB1::ParameterBlock
|
28
|
+
end
|
29
|
+
|
30
|
+
it { is_expected.to respond_to :total_parameter_count }
|
31
|
+
it { is_expected.to respond_to :total_data_count }
|
32
|
+
it { is_expected.to respond_to :parameter_count }
|
33
|
+
it { is_expected.to respond_to :parameter_offset }
|
34
|
+
it { is_expected.to respond_to :parameter_displacement }
|
35
|
+
it { is_expected.to respond_to :data_count }
|
36
|
+
it { is_expected.to respond_to :data_offset }
|
37
|
+
it { is_expected.to respond_to :data_displacement }
|
38
|
+
it { is_expected.to respond_to :fid }
|
39
|
+
|
40
|
+
describe 'parameter_count' do
|
41
|
+
it 'is a count of bytes in the data_block trans2_parameters field' do
|
42
|
+
packet.data_block.trans2_parameters = "\x00\x01\x02\x03"
|
43
|
+
expect(parameter_block.parameter_count).to eq 4
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'parameter_offset' do
|
48
|
+
it ' contains the absolute_offset to the data_block trans2_parameters field' do
|
49
|
+
expect(parameter_block.parameter_offset).to eq packet.data_block.trans2_parameters.abs_offset
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'data_count' do
|
54
|
+
it 'is a count of bytes in the data_block trans2_data field' do
|
55
|
+
packet.data_block.trans2_data = "\x00\x01\x02\x03"
|
56
|
+
expect(parameter_block.data_count).to eq 4
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe 'data_offset' do
|
61
|
+
it 'contains the absolute_offset to the data_block trans2_data field' do
|
62
|
+
expect(parameter_block.data_offset).to eq packet.data_block.trans2_data.abs_offset
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#data_block' do
|
68
|
+
subject(:data_block) { packet.data_block }
|
69
|
+
|
70
|
+
it 'is a standard DataBlock' do
|
71
|
+
expect(data_block).to be_a RubySMB::SMB1::Packet::Trans2::Request::DataBlock
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::SMB1::Packet::Trans2::Request do
|
4
|
+
|
5
|
+
subject(:packet) { described_class.new }
|
6
|
+
|
7
|
+
describe '#smb_header' do
|
8
|
+
subject(:header) { packet.smb_header }
|
9
|
+
|
10
|
+
it 'is a standard SMB Header' do
|
11
|
+
expect(header).to be_a RubySMB::SMB1::SMBHeader
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should have the command set to SMB_COM_NEGOTIATE' do
|
15
|
+
expect(header.command).to eq RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should not have the response flag set' do
|
19
|
+
expect(header.flags.reply).to eq 0
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#parameter_block' do
|
24
|
+
subject(:parameter_block) { packet.parameter_block }
|
25
|
+
|
26
|
+
it 'is a standard ParameterBlock' do
|
27
|
+
expect(parameter_block).to be_a RubySMB::SMB1::ParameterBlock
|
28
|
+
end
|
29
|
+
|
30
|
+
it { is_expected.to respond_to :total_parameter_count }
|
31
|
+
it { is_expected.to respond_to :total_data_count }
|
32
|
+
it { is_expected.to respond_to :max_parameter_count }
|
33
|
+
it { is_expected.to respond_to :max_data_count }
|
34
|
+
it { is_expected.to respond_to :max_setup_count }
|
35
|
+
it { is_expected.to respond_to :timeout }
|
36
|
+
it { is_expected.to respond_to :parameter_count }
|
37
|
+
it { is_expected.to respond_to :parameter_offset }
|
38
|
+
it { is_expected.to respond_to :data_count }
|
39
|
+
it { is_expected.to respond_to :data_offset }
|
40
|
+
it { is_expected.to respond_to :setup_count }
|
41
|
+
|
42
|
+
describe 'flags' do
|
43
|
+
it 'is a trans2_flags BitField' do
|
44
|
+
expect(parameter_block.flags).to be_a RubySMB::SMB1::BitField::Trans2Flags
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'parameter_count' do
|
49
|
+
it 'is a count of bytes in the data_block trans2_parameters field' do
|
50
|
+
packet.data_block.trans2_parameters = "\x00\x01\x02\x03"
|
51
|
+
expect(parameter_block.parameter_count).to eq 4
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe 'parameter_offset' do
|
56
|
+
it ' contains the absolute_offset to the data_block trans2_parameters field' do
|
57
|
+
expect(parameter_block.parameter_offset).to eq packet.data_block.trans2_parameters.abs_offset
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'data_count' do
|
62
|
+
it 'is a count of bytes in the data_block trans2_data field' do
|
63
|
+
packet.data_block.trans2_data = "\x00\x01\x02\x03"
|
64
|
+
expect(parameter_block.data_count).to eq 4
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe 'data_offset' do
|
69
|
+
it 'contains the absolute_offset to the data_block trans2_data field' do
|
70
|
+
expect(parameter_block.data_offset).to eq packet.data_block.trans2_data.abs_offset
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#data_block' do
|
76
|
+
subject(:data_block) { packet.data_block }
|
77
|
+
|
78
|
+
it 'is a standard DataBlock' do
|
79
|
+
expect(data_block).to be_a RubySMB::SMB1::DataBlock
|
80
|
+
end
|
81
|
+
|
82
|
+
it { is_expected.to respond_to :name }
|
83
|
+
it { is_expected.to respond_to :trans2_parameters }
|
84
|
+
it { is_expected.to respond_to :trans2_data }
|
85
|
+
|
86
|
+
it 'should keep #trans2_parameters 4-byte aligned' do
|
87
|
+
expect(data_block.trans2_parameters.abs_offset % 4).to eq 0
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should keep #trans2_data 4-byte aligned' do
|
91
|
+
data_block.trans2_parameters = 'a'
|
92
|
+
expect(data_block.trans2_data.abs_offset % 4).to eq 0
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
end
|