ruby_smb 0.0.12 → 0.0.13
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 +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,194 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe RubySMB::Field::SecurityDescriptor do
|
|
4
|
+
subject(:descriptor) {
|
|
5
|
+
struct = described_class.new
|
|
6
|
+
struct.owner_sid = 'ABCD'
|
|
7
|
+
struct.group_sid = 'ABCD'
|
|
8
|
+
struct.sacl = 'ABCD'
|
|
9
|
+
struct.dacl = 'ABCD'
|
|
10
|
+
struct
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
it { is_expected.to respond_to :revision }
|
|
14
|
+
it { is_expected.to respond_to :sbz1 }
|
|
15
|
+
it { is_expected.to respond_to :control }
|
|
16
|
+
it { is_expected.to respond_to :offset_owner }
|
|
17
|
+
it { is_expected.to respond_to :offset_group }
|
|
18
|
+
it { is_expected.to respond_to :offset_sacl }
|
|
19
|
+
it { is_expected.to respond_to :offset_dacl }
|
|
20
|
+
it { is_expected.to respond_to :owner_sid }
|
|
21
|
+
it { is_expected.to respond_to :group_sid }
|
|
22
|
+
it { is_expected.to respond_to :sacl }
|
|
23
|
+
it { is_expected.to respond_to :dacl }
|
|
24
|
+
|
|
25
|
+
it 'is little endian' do
|
|
26
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'tracks the offset to the #owner_sid' do
|
|
30
|
+
expect(descriptor.offset_owner).to eq descriptor.owner_sid.rel_offset
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'tracks the offset to the #group_sid' do
|
|
34
|
+
expect(descriptor.offset_group).to eq descriptor.group_sid.rel_offset
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'tracks the offset to the #sacl' do
|
|
38
|
+
expect(descriptor.offset_sacl).to eq descriptor.sacl.rel_offset
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'tracks the offset to the #dacl' do
|
|
42
|
+
expect(descriptor.offset_dacl).to eq descriptor.dacl.rel_offset
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe '#control' do
|
|
46
|
+
subject(:control) { descriptor.control }
|
|
47
|
+
|
|
48
|
+
it { is_expected.to respond_to :owner_defaulted }
|
|
49
|
+
it { is_expected.to respond_to :group_defaulted }
|
|
50
|
+
it { is_expected.to respond_to :dacl_present }
|
|
51
|
+
it { is_expected.to respond_to :dacl_defaulted }
|
|
52
|
+
it { is_expected.to respond_to :sacl_present }
|
|
53
|
+
it { is_expected.to respond_to :sacl_defaulted }
|
|
54
|
+
it { is_expected.to respond_to :server_security }
|
|
55
|
+
it { is_expected.to respond_to :dacl_trusted }
|
|
56
|
+
it { is_expected.to respond_to :dacl_computed_inheritance }
|
|
57
|
+
it { is_expected.to respond_to :sacl_computed_inheritance }
|
|
58
|
+
it { is_expected.to respond_to :dacl_auto_inherited }
|
|
59
|
+
it { is_expected.to respond_to :sacl_auto_inherited }
|
|
60
|
+
it { is_expected.to respond_to :dacl_protected }
|
|
61
|
+
it { is_expected.to respond_to :sacl_protected }
|
|
62
|
+
it { is_expected.to respond_to :rm_control_valid }
|
|
63
|
+
it { is_expected.to respond_to :self_relative }
|
|
64
|
+
|
|
65
|
+
describe '#self_relative' do
|
|
66
|
+
it 'is a 1-bit flag' do
|
|
67
|
+
expect(control.self_relative).to be_a BinData::Bit1
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it_behaves_like 'bit field with one flag set', :self_relative, 'v', 0x0001
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
describe '#rm_control_valid' do
|
|
74
|
+
it 'is a 1-bit flag' do
|
|
75
|
+
expect(control.rm_control_valid).to be_a BinData::Bit1
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it_behaves_like 'bit field with one flag set', :rm_control_valid, 'v', 0x0002
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
describe '#sacl_protected' do
|
|
82
|
+
it 'is a 1-bit flag' do
|
|
83
|
+
expect(control.sacl_protected).to be_a BinData::Bit1
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it_behaves_like 'bit field with one flag set', :sacl_protected, 'v', 0x0004
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
describe '#dacl_protected' do
|
|
90
|
+
it 'is a 1-bit flag' do
|
|
91
|
+
expect(control.dacl_protected).to be_a BinData::Bit1
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it_behaves_like 'bit field with one flag set', :dacl_protected, 'v', 0x0008
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
describe '#sacl_auto_inherited' do
|
|
98
|
+
it 'is a 1-bit flag' do
|
|
99
|
+
expect(control.sacl_auto_inherited).to be_a BinData::Bit1
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it_behaves_like 'bit field with one flag set', :sacl_auto_inherited, 'v', 0x0010
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
describe '#dacl_auto_inherited' do
|
|
106
|
+
it 'is a 1-bit flag' do
|
|
107
|
+
expect(control.dacl_auto_inherited).to be_a BinData::Bit1
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it_behaves_like 'bit field with one flag set', :dacl_auto_inherited, 'v', 0x0020
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
describe '#sacl_computed_inheritance' do
|
|
114
|
+
it 'is a 1-bit flag' do
|
|
115
|
+
expect(control.sacl_computed_inheritance).to be_a BinData::Bit1
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it_behaves_like 'bit field with one flag set', :sacl_computed_inheritance, 'v', 0x0040
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
describe '#dacl_computed_inheritance' do
|
|
122
|
+
it 'is a 1-bit flag' do
|
|
123
|
+
expect(control.dacl_computed_inheritance).to be_a BinData::Bit1
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
it_behaves_like 'bit field with one flag set', :dacl_computed_inheritance, 'v', 0x0080
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
describe '#dacl_trusted' do
|
|
130
|
+
it 'is a 1-bit flag' do
|
|
131
|
+
expect(control.dacl_trusted).to be_a BinData::Bit1
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it_behaves_like 'bit field with one flag set', :dacl_trusted, 'v', 0x0100
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
describe '#server_security' do
|
|
138
|
+
it 'is a 1-bit flag' do
|
|
139
|
+
expect(control.server_security).to be_a BinData::Bit1
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it_behaves_like 'bit field with one flag set', :server_security, 'v', 0x0200
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
describe '#sacl_defaulted' do
|
|
146
|
+
it 'is a 1-bit flag' do
|
|
147
|
+
expect(control.sacl_defaulted).to be_a BinData::Bit1
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
it_behaves_like 'bit field with one flag set', :sacl_defaulted, 'v', 0x0400
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
describe '#sacl_present' do
|
|
154
|
+
it 'is a 1-bit flag' do
|
|
155
|
+
expect(control.sacl_present).to be_a BinData::Bit1
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
it_behaves_like 'bit field with one flag set', :sacl_present, 'v', 0x0800
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
describe '#dacl_defaulted' do
|
|
162
|
+
it 'is a 1-bit flag' do
|
|
163
|
+
expect(control.dacl_defaulted).to be_a BinData::Bit1
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
it_behaves_like 'bit field with one flag set', :dacl_defaulted, 'v', 0x1000
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
describe '#dacl_present' do
|
|
170
|
+
it 'is a 1-bit flag' do
|
|
171
|
+
expect(control.dacl_present).to be_a BinData::Bit1
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
it_behaves_like 'bit field with one flag set', :dacl_present, 'v', 0x2000
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
describe '#group_defaulted' do
|
|
178
|
+
it 'is a 1-bit flag' do
|
|
179
|
+
expect(control.group_defaulted).to be_a BinData::Bit1
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
it_behaves_like 'bit field with one flag set', :group_defaulted, 'v', 0x4000
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
describe '#owner_defaulted' do
|
|
186
|
+
it 'is a 1-bit flag' do
|
|
187
|
+
expect(control.owner_defaulted).to be_a BinData::Bit1
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
it_behaves_like 'bit field with one flag set', :owner_defaulted, 'v', 0x8000
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
RSpec.describe RubySMB::Field::SmbFeaList do
|
|
2
|
+
subject(:list) { described_class.new }
|
|
3
|
+
let(:fea1) {
|
|
4
|
+
fea = RubySMB::Field::SmbFea.new
|
|
5
|
+
fea.attribute_name = 'foo'
|
|
6
|
+
fea.attribute_value = 'bar'
|
|
7
|
+
fea
|
|
8
|
+
}
|
|
9
|
+
let(:fea2) {
|
|
10
|
+
fea = RubySMB::Field::SmbFea.new
|
|
11
|
+
fea.attribute_name = 'hello world'
|
|
12
|
+
fea.attribute_value = 'this is a test'
|
|
13
|
+
fea
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
it { is_expected.to respond_to :size_of_list }
|
|
18
|
+
it { is_expected.to respond_to :fea_list }
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
it 'is little endian' do
|
|
22
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe '#size_of_list' do
|
|
26
|
+
it 'shows the size, in bytes, of the fea_list' do
|
|
27
|
+
list.fea_list << fea1
|
|
28
|
+
expect(list.size_of_list).to eq fea1.do_num_bytes
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'changes dynamically as new FEAs are added' do
|
|
32
|
+
list.fea_list << fea1
|
|
33
|
+
expect(list.size_of_list).to eq fea1.do_num_bytes
|
|
34
|
+
list.fea_list << fea2
|
|
35
|
+
expect(list.size_of_list).to eq (fea1.do_num_bytes + fea2.do_num_bytes )
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
RSpec.describe RubySMB::Field::SmbFea do
|
|
2
|
+
subject(:fea) { described_class.new }
|
|
3
|
+
|
|
4
|
+
it { is_expected.to respond_to :ea_flag }
|
|
5
|
+
it { is_expected.to respond_to :attribute_name_length }
|
|
6
|
+
it { is_expected.to respond_to :attribute_value_length }
|
|
7
|
+
it { is_expected.to respond_to :attribute_name }
|
|
8
|
+
it { is_expected.to respond_to :attribute_value }
|
|
9
|
+
|
|
10
|
+
it 'is little endian' do
|
|
11
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe '#attribute_name_length' do
|
|
15
|
+
it 'reflects the size of the attribute_name field' do
|
|
16
|
+
fea.attribute_name = 'TEST'
|
|
17
|
+
expect(fea.attribute_name_length).to eq 4
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe '#attribute_value_length' do
|
|
22
|
+
it 'reflects the size of the attribute_value field' do
|
|
23
|
+
fea.attribute_value = 'TEST'
|
|
24
|
+
expect(fea.attribute_value_length).to eq 4
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
RSpec.describe RubySMB::Field::Utime do
|
|
2
|
+
subject(:time) { described_class.read(binary_filetime) }
|
|
3
|
+
|
|
4
|
+
let(:binary_filetime) { "\x94\xD1\xE5U" }
|
|
5
|
+
let(:int_filetime) { time_filetime.to_i }
|
|
6
|
+
let(:str_filetime) { '2015-09-01T11:25:56-05:00' }
|
|
7
|
+
let(:time_filetime) { Time.parse str_filetime }
|
|
8
|
+
let(:datetime_filetime) { time_filetime.to_datetime }
|
|
9
|
+
|
|
10
|
+
it { is_expected.to respond_to :val }
|
|
11
|
+
it { is_expected.to respond_to :get }
|
|
12
|
+
it { is_expected.to respond_to :set }
|
|
13
|
+
it { is_expected.to respond_to :to_time }
|
|
14
|
+
it { is_expected.to respond_to :to_datetime }
|
|
15
|
+
|
|
16
|
+
describe '#val' do
|
|
17
|
+
it 'should b an Unsigned 32-bit Integer' do
|
|
18
|
+
expect(time.val).to be_a BinData::Uint32le
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe '#get' do
|
|
23
|
+
it 'returns the expected integer value' do
|
|
24
|
+
expect(time.val).to eq int_filetime
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe '#to_time' do
|
|
29
|
+
it 'returns a Time object representing the correct time' do
|
|
30
|
+
expect(time.to_time).to eq time_filetime
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe '#to_datetime' do
|
|
35
|
+
it 'returns a DateTime object representing the correct time' do
|
|
36
|
+
expect(time.to_datetime).to eq datetime_filetime
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe '#set' do
|
|
41
|
+
subject(:empty_filetime) { described_class.new }
|
|
42
|
+
it 'will take a Time object correctly but lose Nanoseconds' do
|
|
43
|
+
empty_filetime.set time_filetime
|
|
44
|
+
val = empty_filetime.get
|
|
45
|
+
expect(val / 10_000_000).to eq (int_filetime / 10_000_000)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'will take a DateTime object correctly but lose Nanoseconds' do
|
|
49
|
+
empty_filetime.set datetime_filetime
|
|
50
|
+
val = empty_filetime.get
|
|
51
|
+
expect(val / 10_000_000).to eq (int_filetime / 10_000_000)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'will accept a raw integer value and set it' do
|
|
55
|
+
empty_filetime.set int_filetime
|
|
56
|
+
expect(empty_filetime.get).to eq int_filetime
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe RubySMB::SMB1::BitField::CreateOptions do
|
|
4
|
+
subject(:options) { described_class.new }
|
|
5
|
+
|
|
6
|
+
it { is_expected.to respond_to :create_tree_connection }
|
|
7
|
+
it { is_expected.to respond_to :non_directory_file }
|
|
8
|
+
it { is_expected.to respond_to :synchronous_io_nonalert }
|
|
9
|
+
it { is_expected.to respond_to :synchronous_io_alert }
|
|
10
|
+
it { is_expected.to respond_to :no_intermediate_buffer }
|
|
11
|
+
it { is_expected.to respond_to :sequential_only }
|
|
12
|
+
it { is_expected.to respond_to :write_through }
|
|
13
|
+
it { is_expected.to respond_to :directory_file }
|
|
14
|
+
it { is_expected.to respond_to :no_compression }
|
|
15
|
+
it { is_expected.to respond_to :open_for_backup_intent }
|
|
16
|
+
it { is_expected.to respond_to :open_by_file_id }
|
|
17
|
+
it { is_expected.to respond_to :delete_on_close }
|
|
18
|
+
it { is_expected.to respond_to :random_access }
|
|
19
|
+
it { is_expected.to respond_to :open_for_recovery }
|
|
20
|
+
it { is_expected.to respond_to :no_ea_knowledge }
|
|
21
|
+
it { is_expected.to respond_to :complete_if_oplocked }
|
|
22
|
+
it { is_expected.to respond_to :open_for_free_space_query }
|
|
23
|
+
it { is_expected.to respond_to :open_no_recall }
|
|
24
|
+
it { is_expected.to respond_to :reserve_opfilter }
|
|
25
|
+
|
|
26
|
+
it 'is little endian' do
|
|
27
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe '#create_tree_connection' do
|
|
31
|
+
it 'is a 1-bit flag' do
|
|
32
|
+
expect(options.create_tree_connection).to be_a BinData::Bit1
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it_behaves_like 'bit field with one flag set', :create_tree_connection, 'V', 0x00000080
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe '#non_directory_file' do
|
|
39
|
+
it 'is a 1-bit flag' do
|
|
40
|
+
expect(options.non_directory_file).to be_a BinData::Bit1
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it_behaves_like 'bit field with one flag set', :non_directory_file, 'V', 0x00000040
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe '#synchronous_io_nonalert' do
|
|
47
|
+
it 'is a 1-bit flag' do
|
|
48
|
+
expect(options.synchronous_io_nonalert).to be_a BinData::Bit1
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it_behaves_like 'bit field with one flag set', :synchronous_io_nonalert, 'V', 0x00000020
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
describe '#synchronous_io_alert' do
|
|
55
|
+
it 'is a 1-bit flag' do
|
|
56
|
+
expect(options.synchronous_io_alert).to be_a BinData::Bit1
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it_behaves_like 'bit field with one flag set', :synchronous_io_alert, 'V', 0x00000010
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
describe '#no_intermediate_buffer' do
|
|
63
|
+
it 'is a 1-bit flag' do
|
|
64
|
+
expect(options.no_intermediate_buffer).to be_a BinData::Bit1
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it_behaves_like 'bit field with one flag set', :no_intermediate_buffer, 'V', 0x00000008
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe '#sequential_only' do
|
|
71
|
+
it 'is a 1-bit flag' do
|
|
72
|
+
expect(options.sequential_only).to be_a BinData::Bit1
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it_behaves_like 'bit field with one flag set', :sequential_only, 'V', 0x00000004
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
describe '#write_through' do
|
|
79
|
+
it 'is a 1-bit flag' do
|
|
80
|
+
expect(options.write_through).to be_a BinData::Bit1
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it_behaves_like 'bit field with one flag set', :write_through, 'V', 0x00000002
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
describe '#directory_file' do
|
|
87
|
+
it 'is a 1-bit flag' do
|
|
88
|
+
expect(options.directory_file).to be_a BinData::Bit1
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it_behaves_like 'bit field with one flag set', :directory_file, 'V', 0x00000001
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
describe '#no_compression' do
|
|
95
|
+
it 'is a 1-bit flag' do
|
|
96
|
+
expect(options.no_compression).to be_a BinData::Bit1
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it_behaves_like 'bit field with one flag set', :no_compression, 'V', 0x00008000
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
describe '#open_for_backup_intent' do
|
|
103
|
+
it 'is a 1-bit flag' do
|
|
104
|
+
expect(options.open_for_backup_intent).to be_a BinData::Bit1
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it_behaves_like 'bit field with one flag set', :open_for_backup_intent, 'V', 0x00004000
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
describe '#open_by_file_id' do
|
|
111
|
+
it 'is a 1-bit flag' do
|
|
112
|
+
expect(options.open_by_file_id).to be_a BinData::Bit1
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it_behaves_like 'bit field with one flag set', :open_by_file_id, 'V', 0x00002000
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
describe '#delete_on_close' do
|
|
119
|
+
it 'is a 1-bit flag' do
|
|
120
|
+
expect(options.delete_on_close).to be_a BinData::Bit1
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
it_behaves_like 'bit field with one flag set', :delete_on_close, 'V', 0x00001000
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
describe '#random_access' do
|
|
127
|
+
it 'is a 1-bit flag' do
|
|
128
|
+
expect(options.random_access).to be_a BinData::Bit1
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
it_behaves_like 'bit field with one flag set', :random_access, 'V', 0x00000800
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
describe '#open_for_recovery' do
|
|
135
|
+
it 'is a 1-bit flag' do
|
|
136
|
+
expect(options.open_for_recovery).to be_a BinData::Bit1
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
it_behaves_like 'bit field with one flag set', :open_for_recovery, 'V', 0x00000400
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
describe '#no_ea_knowledge' do
|
|
143
|
+
it 'is a 1-bit flag' do
|
|
144
|
+
expect(options.no_ea_knowledge).to be_a BinData::Bit1
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it_behaves_like 'bit field with one flag set', :no_ea_knowledge, 'V', 0x00000200
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
describe '#complete_if_oplocked' do
|
|
151
|
+
it 'is a 1-bit flag' do
|
|
152
|
+
expect(options.complete_if_oplocked).to be_a BinData::Bit1
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
it_behaves_like 'bit field with one flag set', :complete_if_oplocked, 'V', 0x00000100
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
describe '#open_for_free_space_query' do
|
|
159
|
+
it 'is a 1-bit flag' do
|
|
160
|
+
expect(options.open_for_free_space_query).to be_a BinData::Bit1
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
it_behaves_like 'bit field with one flag set', :open_for_free_space_query, 'V', 0x00800000
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
describe '#open_no_recall' do
|
|
167
|
+
it 'is a 1-bit flag' do
|
|
168
|
+
expect(options.open_no_recall).to be_a BinData::Bit1
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
it_behaves_like 'bit field with one flag set', :open_no_recall, 'V', 0x00400000
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
describe '#reserve_opfilter' do
|
|
175
|
+
it 'is a 1-bit flag' do
|
|
176
|
+
expect(options.reserve_opfilter).to be_a BinData::Bit1
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
it_behaves_like 'bit field with one flag set', :reserve_opfilter, 'V', 0x00100000
|
|
180
|
+
end
|
|
181
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
RSpec.describe RubySMB::SMB1::BitField::Open2AccessMode do
|
|
2
|
+
subject(:flags) { described_class.new }
|
|
3
|
+
|
|
4
|
+
it { is_expected.to respond_to :sharing_mode }
|
|
5
|
+
it { is_expected.to respond_to :access_mode }
|
|
6
|
+
it { is_expected.to respond_to :writethrough }
|
|
7
|
+
it { is_expected.to respond_to :cache_mode }
|
|
8
|
+
it { is_expected.to respond_to :reference_locality }
|
|
9
|
+
|
|
10
|
+
it 'is little endian' do
|
|
11
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe 'access_mode' do
|
|
15
|
+
it 'should be a 3-bit field per the SMB spec' do
|
|
16
|
+
expect(flags.access_mode).to be_a BinData::Bit3
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it_behaves_like 'bit field with one flag set', :access_mode, 'v', 0x0001
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe 'sharing_mode' do
|
|
23
|
+
it 'should be a 3-bit field per the SMB spec' do
|
|
24
|
+
expect(flags.sharing_mode).to be_a BinData::Bit3
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it_behaves_like 'bit field with one flag set', :sharing_mode, 'v', 0x0010
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe 'reference_locality' do
|
|
31
|
+
it 'should be a 3-bit field per the SMB spec' do
|
|
32
|
+
expect(flags.reference_locality).to be_a BinData::Bit3
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it_behaves_like 'bit field with one flag set', :reference_locality, 'v', 0x0100
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe 'cache_mode' do
|
|
39
|
+
it 'should be a 1-bit field per the SMB spec' do
|
|
40
|
+
expect(flags.cache_mode).to be_a BinData::Bit1
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it_behaves_like 'bit field with one flag set', :cache_mode, 'v', 0x1000
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe 'writethrough' do
|
|
47
|
+
it 'should be a 1-bit field per the SMB spec' do
|
|
48
|
+
expect(flags.writethrough).to be_a BinData::Bit1
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it_behaves_like 'bit field with one flag set', :writethrough, 'v', 0x4000
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
describe '#set_access_mode' do
|
|
55
|
+
it 'sets access mode to 0 when given :r' do
|
|
56
|
+
flags.set_access_mode :r
|
|
57
|
+
expect(flags.access_mode).to eq 0
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it 'sets access mode to 1 when given :w' do
|
|
61
|
+
flags.set_access_mode :w
|
|
62
|
+
expect(flags.access_mode).to eq 1
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'sets access mode to 2 when given :rw' do
|
|
66
|
+
flags.set_access_mode :rw
|
|
67
|
+
expect(flags.access_mode).to eq 2
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it 'sets access mode to 3 when given :x' do
|
|
71
|
+
flags.set_access_mode :r
|
|
72
|
+
expect(flags.access_mode).to eq 0
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it 'raises an ArgumentError if given an invalid mode' do
|
|
76
|
+
expect{flags.set_access_mode('abcd')}.to raise_error(ArgumentError)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
RSpec.describe RubySMB::SMB1::BitField::Open2Flags do
|
|
2
|
+
subject(:flags) { described_class.new }
|
|
3
|
+
|
|
4
|
+
it { is_expected.to respond_to :req_easize }
|
|
5
|
+
it { is_expected.to respond_to :req_opbatch }
|
|
6
|
+
it { is_expected.to respond_to :req_oplock }
|
|
7
|
+
it { is_expected.to respond_to :req_attrib }
|
|
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 'req_attrib' do
|
|
14
|
+
it 'should be a 1-bit field per the SMB spec' do
|
|
15
|
+
expect(flags.req_attrib).to be_a BinData::Bit1
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'should have a default value of 1' do
|
|
19
|
+
expect(flags.req_attrib).to eq 1
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it_behaves_like 'bit field with one flag set', :req_attrib, 'v', 0x0001
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe 'req_oplock' do
|
|
26
|
+
it 'should be a 1-bit field per the SMB spec' do
|
|
27
|
+
expect(flags.req_oplock).to be_a BinData::Bit1
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'should have a default value of 0' do
|
|
31
|
+
expect(flags.req_oplock).to eq 0
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it_behaves_like 'bit field with one flag set', :req_oplock, 'v', 0x0002
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe 'req_opbatch' do
|
|
38
|
+
it 'should be a 1-bit field per the SMB spec' do
|
|
39
|
+
expect(flags.req_opbatch).to be_a BinData::Bit1
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'should have a default value of 0' do
|
|
43
|
+
expect(flags.req_opbatch).to eq 0
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it_behaves_like 'bit field with one flag set', :req_opbatch, 'v', 0x0004
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe 'req_easize' do
|
|
50
|
+
it 'should be a 1-bit field per the SMB spec' do
|
|
51
|
+
expect(flags.req_easize).to be_a BinData::Bit1
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'should have a default value of 1' do
|
|
55
|
+
expect(flags.req_easize).to eq 1
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it_behaves_like 'bit field with one flag set', :req_easize, 'v', 0x0008
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
RSpec.describe RubySMB::SMB1::BitField::Open2OpenMode do
|
|
2
|
+
subject(:flags) { described_class.new }
|
|
3
|
+
|
|
4
|
+
it { is_expected.to respond_to :file_exists_opts }
|
|
5
|
+
it { is_expected.to respond_to :create_file }
|
|
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 'file_exists_opts' do
|
|
12
|
+
it 'should be a 2-bit field per the SMB spec' do
|
|
13
|
+
expect(flags.file_exists_opts).to be_a BinData::Bit2
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it_behaves_like 'bit field with one flag set', :file_exists_opts, 'v', 0x0001
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe 'create_file' do
|
|
20
|
+
it 'should be a 1-bit field per the SMB spec' do
|
|
21
|
+
expect(flags.create_file).to be_a BinData::Bit1
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it_behaves_like 'bit field with one flag set', :create_file, 'v', 0x0010
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|