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,38 @@
|
|
1
|
+
RSpec.describe RubySMB::SMB1::BitField::ShareAccess do
|
2
|
+
subject(:flags) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :share_delete }
|
5
|
+
it { is_expected.to respond_to :share_write }
|
6
|
+
it { is_expected.to respond_to :share_read }
|
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 '#share_read' do
|
13
|
+
it 'should be a 1-bit field per the SMB spec' do
|
14
|
+
expect(flags.share_read).to be_a BinData::Bit1
|
15
|
+
end
|
16
|
+
|
17
|
+
it_behaves_like 'bit field with one flag set', :share_read, 'V', 0x00000001
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#share_write' do
|
21
|
+
it 'should be a 1-bit field per the SMB spec' do
|
22
|
+
expect(flags.share_write).to be_a BinData::Bit1
|
23
|
+
end
|
24
|
+
|
25
|
+
it_behaves_like 'bit field with one flag set', :share_write, 'V', 0x00000002
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#share_delete' do
|
29
|
+
it 'should be a 1-bit field per the SMB spec' do
|
30
|
+
expect(flags.share_delete).to be_a BinData::Bit1
|
31
|
+
end
|
32
|
+
|
33
|
+
it_behaves_like 'bit field with one flag set', :share_delete, 'V', 0x00000004
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
RSpec.describe RubySMB::SMB1::BitField::SmbExtFileAttributes do
|
2
|
+
subject(:attrs) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :archive }
|
5
|
+
it { is_expected.to respond_to :directory }
|
6
|
+
it { is_expected.to respond_to :normal }
|
7
|
+
it { is_expected.to respond_to :system }
|
8
|
+
it { is_expected.to respond_to :hidden }
|
9
|
+
it { is_expected.to respond_to :read_only }
|
10
|
+
it { is_expected.to respond_to :compressed }
|
11
|
+
it { is_expected.to respond_to :temporary }
|
12
|
+
it { is_expected.to respond_to :write_through }
|
13
|
+
it { is_expected.to respond_to :no_buffering }
|
14
|
+
it { is_expected.to respond_to :random_access }
|
15
|
+
it { is_expected.to respond_to :sequential_scan }
|
16
|
+
it { is_expected.to respond_to :delete_on_close }
|
17
|
+
it { is_expected.to respond_to :backup_semantics }
|
18
|
+
it { is_expected.to respond_to :posix_semantics }
|
19
|
+
|
20
|
+
it 'is little endian' do
|
21
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'read_only' do
|
25
|
+
it 'should be a 1-bit field per the SMB spec' do
|
26
|
+
expect(attrs.read_only).to be_a BinData::Bit1
|
27
|
+
end
|
28
|
+
|
29
|
+
it_behaves_like 'bit field with one flag set', :read_only, 'V', 0x00000001
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'hidden' do
|
33
|
+
it 'should be a 1-bit field per the SMB spec' do
|
34
|
+
expect(attrs.hidden).to be_a BinData::Bit1
|
35
|
+
end
|
36
|
+
|
37
|
+
it_behaves_like 'bit field with one flag set', :hidden, 'V', 0x00000002
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'system' do
|
41
|
+
it 'should be a 1-bit field per the SMB spec' do
|
42
|
+
expect(attrs.system).to be_a BinData::Bit1
|
43
|
+
end
|
44
|
+
|
45
|
+
it_behaves_like 'bit field with one flag set', :system, 'V', 0x00000004
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'directory' do
|
49
|
+
it 'should be a 1-bit field per the SMB spec' do
|
50
|
+
expect(attrs.directory).to be_a BinData::Bit1
|
51
|
+
end
|
52
|
+
|
53
|
+
it_behaves_like 'bit field with one flag set', :directory, 'V', 0x00000010
|
54
|
+
end
|
55
|
+
|
56
|
+
describe 'archive' do
|
57
|
+
it 'should be a 1-bit field per the SMB spec' do
|
58
|
+
expect(attrs.archive).to be_a BinData::Bit1
|
59
|
+
end
|
60
|
+
|
61
|
+
it_behaves_like 'bit field with one flag set', :archive, 'V', 0x00000020
|
62
|
+
end
|
63
|
+
|
64
|
+
describe 'normal' do
|
65
|
+
it 'should be a 1-bit field per the SMB spec' do
|
66
|
+
expect(attrs.normal).to be_a BinData::Bit1
|
67
|
+
end
|
68
|
+
|
69
|
+
it_behaves_like 'bit field with one flag set', :normal, 'V', 0x00000080
|
70
|
+
end
|
71
|
+
|
72
|
+
describe 'temporary' do
|
73
|
+
it 'should be a 1-bit field per the SMB spec' do
|
74
|
+
expect(attrs.temporary).to be_a BinData::Bit1
|
75
|
+
end
|
76
|
+
|
77
|
+
it_behaves_like 'bit field with one flag set', :temporary, 'V', 0x00000100
|
78
|
+
end
|
79
|
+
|
80
|
+
describe 'compressed' do
|
81
|
+
it 'should be a 1-bit field per the SMB spec' do
|
82
|
+
expect(attrs.compressed).to be_a BinData::Bit1
|
83
|
+
end
|
84
|
+
|
85
|
+
it_behaves_like 'bit field with one flag set', :compressed, 'V', 0x00000800
|
86
|
+
end
|
87
|
+
|
88
|
+
describe 'posix_semantics' do
|
89
|
+
it 'should be a 1-bit field per the SMB spec' do
|
90
|
+
expect(attrs.posix_semantics).to be_a BinData::Bit1
|
91
|
+
end
|
92
|
+
|
93
|
+
it_behaves_like 'bit field with one flag set', :posix_semantics, 'V', 0x01000000
|
94
|
+
end
|
95
|
+
|
96
|
+
describe 'backup_semantics' do
|
97
|
+
it 'should be a 1-bit field per the SMB spec' do
|
98
|
+
expect(attrs.backup_semantics).to be_a BinData::Bit1
|
99
|
+
end
|
100
|
+
|
101
|
+
it_behaves_like 'bit field with one flag set', :backup_semantics, 'V', 0x02000000
|
102
|
+
end
|
103
|
+
|
104
|
+
describe 'delete_on_close' do
|
105
|
+
it 'should be a 1-bit field per the SMB spec' do
|
106
|
+
expect(attrs.delete_on_close).to be_a BinData::Bit1
|
107
|
+
end
|
108
|
+
|
109
|
+
it_behaves_like 'bit field with one flag set', :delete_on_close, 'V', 0x04000000
|
110
|
+
end
|
111
|
+
|
112
|
+
describe 'sequential_scan' do
|
113
|
+
it 'should be a 1-bit field per the SMB spec' do
|
114
|
+
expect(attrs.sequential_scan).to be_a BinData::Bit1
|
115
|
+
end
|
116
|
+
|
117
|
+
it_behaves_like 'bit field with one flag set', :sequential_scan, 'V', 0x08000000
|
118
|
+
end
|
119
|
+
|
120
|
+
describe 'random_access' do
|
121
|
+
it 'should be a 1-bit field per the SMB spec' do
|
122
|
+
expect(attrs.random_access).to be_a BinData::Bit1
|
123
|
+
end
|
124
|
+
|
125
|
+
it_behaves_like 'bit field with one flag set', :random_access, 'V', 0x10000000
|
126
|
+
end
|
127
|
+
|
128
|
+
describe 'no_buffering' do
|
129
|
+
it 'should be a 1-bit field per the SMB spec' do
|
130
|
+
expect(attrs.no_buffering).to be_a BinData::Bit1
|
131
|
+
end
|
132
|
+
|
133
|
+
it_behaves_like 'bit field with one flag set', :no_buffering, 'V', 0x20000000
|
134
|
+
end
|
135
|
+
|
136
|
+
describe 'write_through' do
|
137
|
+
it 'should be a 1-bit field per the SMB spec' do
|
138
|
+
expect(attrs.write_through).to be_a BinData::Bit1
|
139
|
+
end
|
140
|
+
|
141
|
+
it_behaves_like 'bit field with one flag set', :write_through, 'V', 0x80000000
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
RSpec.describe RubySMB::SMB1::BitField::SmbFileAttributes do
|
2
|
+
subject(:attrs) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :archive }
|
5
|
+
it { is_expected.to respond_to :directory }
|
6
|
+
it { is_expected.to respond_to :volume }
|
7
|
+
it { is_expected.to respond_to :system }
|
8
|
+
it { is_expected.to respond_to :hidden }
|
9
|
+
it { is_expected.to respond_to :read_only }
|
10
|
+
it { is_expected.to respond_to :search_archive }
|
11
|
+
it { is_expected.to respond_to :search_directory }
|
12
|
+
it { is_expected.to respond_to :search_system }
|
13
|
+
it { is_expected.to respond_to :search_hidden }
|
14
|
+
it { is_expected.to respond_to :search_read_only }
|
15
|
+
|
16
|
+
it 'is little endian' do
|
17
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'read_only' do
|
21
|
+
it 'should be a 1-bit field per the SMB spec' do
|
22
|
+
expect(attrs.read_only).to be_a BinData::Bit1
|
23
|
+
end
|
24
|
+
|
25
|
+
it_behaves_like 'bit field with one flag set', :read_only, 'v', 0x0001
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'hidden' do
|
29
|
+
it 'should be a 1-bit field per the SMB spec' do
|
30
|
+
expect(attrs.hidden).to be_a BinData::Bit1
|
31
|
+
end
|
32
|
+
|
33
|
+
it_behaves_like 'bit field with one flag set', :hidden, 'v', 0x0002
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'system' do
|
37
|
+
it 'should be a 1-bit field per the SMB spec' do
|
38
|
+
expect(attrs.system).to be_a BinData::Bit1
|
39
|
+
end
|
40
|
+
|
41
|
+
it_behaves_like 'bit field with one flag set', :system, 'v', 0x0004
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'volume' do
|
45
|
+
it 'should be a 1-bit field per the SMB spec' do
|
46
|
+
expect(attrs.volume).to be_a BinData::Bit1
|
47
|
+
end
|
48
|
+
|
49
|
+
it_behaves_like 'bit field with one flag set', :volume, 'v', 0x0008
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'directory' do
|
53
|
+
it 'should be a 1-bit field per the SMB spec' do
|
54
|
+
expect(attrs.directory).to be_a BinData::Bit1
|
55
|
+
end
|
56
|
+
|
57
|
+
it_behaves_like 'bit field with one flag set', :directory, 'v', 0x0010
|
58
|
+
end
|
59
|
+
|
60
|
+
describe 'archive' do
|
61
|
+
it 'should be a 1-bit field per the SMB spec' do
|
62
|
+
expect(attrs.archive).to be_a BinData::Bit1
|
63
|
+
end
|
64
|
+
|
65
|
+
it_behaves_like 'bit field with one flag set', :archive, 'v', 0x0020
|
66
|
+
end
|
67
|
+
|
68
|
+
describe 'search_read_only' do
|
69
|
+
it 'should be a 1-bit field per the SMB spec' do
|
70
|
+
expect(attrs.search_read_only).to be_a BinData::Bit1
|
71
|
+
end
|
72
|
+
|
73
|
+
it_behaves_like 'bit field with one flag set', :search_read_only, 'v', 0x0100
|
74
|
+
end
|
75
|
+
|
76
|
+
describe 'search_hidden' do
|
77
|
+
it 'should be a 1-bit field per the SMB spec' do
|
78
|
+
expect(attrs.search_hidden).to be_a BinData::Bit1
|
79
|
+
end
|
80
|
+
|
81
|
+
it_behaves_like 'bit field with one flag set', :search_hidden, 'v', 0x0200
|
82
|
+
end
|
83
|
+
|
84
|
+
describe 'search_system' do
|
85
|
+
it 'should be a 1-bit field per the SMB spec' do
|
86
|
+
expect(attrs.search_system).to be_a BinData::Bit1
|
87
|
+
end
|
88
|
+
|
89
|
+
it_behaves_like 'bit field with one flag set', :search_system, 'v', 0x0400
|
90
|
+
end
|
91
|
+
|
92
|
+
describe 'search_directory' do
|
93
|
+
it 'should be a 1-bit field per the SMB spec' do
|
94
|
+
expect(attrs.search_directory).to be_a BinData::Bit1
|
95
|
+
end
|
96
|
+
|
97
|
+
it_behaves_like 'bit field with one flag set', :search_directory, 'v', 0x1000
|
98
|
+
end
|
99
|
+
|
100
|
+
describe 'search_archive' do
|
101
|
+
it 'should be a 1-bit field per the SMB spec' do
|
102
|
+
expect(attrs.search_archive).to be_a BinData::Bit1
|
103
|
+
end
|
104
|
+
|
105
|
+
it_behaves_like 'bit field with one flag set', :search_archive, 'v', 0x2000
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
RSpec.describe RubySMB::SMB1::BitField::SmbNmpipeStatus do
|
2
|
+
subject(:flags) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :icount }
|
5
|
+
it { is_expected.to respond_to :nonblocking }
|
6
|
+
it { is_expected.to respond_to :endpoint }
|
7
|
+
it { is_expected.to respond_to :nmpipe_type }
|
8
|
+
it { is_expected.to respond_to :read_mode }
|
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 'icount' do
|
15
|
+
it 'should be a 8-bit field per the SMB spec' do
|
16
|
+
expect(flags.icount).to be_a BinData::Bit8
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'read_mode' do
|
21
|
+
it 'should be a 1-bit field per the SMB spec' do
|
22
|
+
expect(flags.read_mode).to be_a BinData::Bit1
|
23
|
+
end
|
24
|
+
|
25
|
+
it_behaves_like 'bit field with one flag set', :read_mode, 'v', 0x0100
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'nmpipe_type' do
|
29
|
+
it 'should be a 1-bit field per the SMB spec' do
|
30
|
+
expect(flags.nmpipe_type).to be_a BinData::Bit1
|
31
|
+
end
|
32
|
+
|
33
|
+
it_behaves_like 'bit field with one flag set', :nmpipe_type, 'v', 0x0400
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'endpoint' do
|
37
|
+
it 'should be a 1-bit field per the SMB spec' do
|
38
|
+
expect(flags.endpoint).to be_a BinData::Bit1
|
39
|
+
end
|
40
|
+
|
41
|
+
it_behaves_like 'bit field with one flag set', :endpoint, 'v', 0x4000
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'nonblocking' do
|
45
|
+
it 'should be a 1-bit field per the SMB spec' do
|
46
|
+
expect(flags.nonblocking).to be_a BinData::Bit1
|
47
|
+
end
|
48
|
+
|
49
|
+
it_behaves_like 'bit field with one flag set', :nonblocking, 'v', 0x8000
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
RSpec.describe RubySMB::SMB1::BitField::Trans2Flags do
|
2
|
+
subject(:flags) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :no_response }
|
5
|
+
it { is_expected.to respond_to :disconnect }
|
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 '#no_response' do
|
12
|
+
it 'should be a 1-bit field per the SMB spec' do
|
13
|
+
expect(flags.no_response).to be_a BinData::Bit1
|
14
|
+
end
|
15
|
+
|
16
|
+
it_behaves_like 'bit field with one flag set', :no_response, 'C', 0x02
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#disconnect' do
|
20
|
+
it 'should be a 1-bit field per the SMB spec' do
|
21
|
+
expect(flags.disconnect).to be_a BinData::Bit1
|
22
|
+
end
|
23
|
+
|
24
|
+
it_behaves_like 'bit field with one flag set', :disconnect, 'C', 0x01
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::SMB1::Packet::EchoRequest 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_ECHO
|
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_expected.to respond_to :echo_count }
|
27
|
+
|
28
|
+
it 'is a standard ParameterBlock' do
|
29
|
+
expect(parameter_block).to be_a RubySMB::SMB1::ParameterBlock
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#data_block' do
|
34
|
+
subject(:data_block) { packet.data_block }
|
35
|
+
|
36
|
+
it { is_expected.to respond_to :data }
|
37
|
+
|
38
|
+
it 'is a standard DataBlock' do
|
39
|
+
expect(data_block).to be_a RubySMB::SMB1::DataBlock
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::SMB1::Packet::EchoResponse 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_ECHO
|
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_expected.to respond_to :sequence_number }
|
27
|
+
|
28
|
+
it 'is a standard ParameterBlock' do
|
29
|
+
expect(parameter_block).to be_a RubySMB::SMB1::ParameterBlock
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#data_block' do
|
34
|
+
subject(:data_block) { packet.data_block }
|
35
|
+
|
36
|
+
it { is_expected.to respond_to :data }
|
37
|
+
|
38
|
+
it 'is a standard DataBlock' do
|
39
|
+
expect(data_block).to be_a RubySMB::SMB1::DataBlock
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,194 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::SMB1::Packet::NtTrans::CreateRequest 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_NEGOTIATE' do
|
14
|
+
expect(header.command).to eq RubySMB::SMB1::Commands::SMB_COM_NT_TRANSACT
|
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 NtTrans Request ParameterBlock' do
|
26
|
+
expect(parameter_block).to be_a RubySMB::SMB1::Packet::NtTrans::Request::ParameterBlock
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'parameter_count' do
|
30
|
+
it 'is a count of bytes in the data_block trans2_parameters field' do
|
31
|
+
expect(parameter_block.parameter_count).to eq packet.data_block.trans2_parameters.do_num_bytes
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'parameter_offset' do
|
36
|
+
it ' contains the absolute_offset to the data_block trans2_parameters field' do
|
37
|
+
expect(parameter_block.parameter_offset).to eq packet.data_block.trans2_parameters.abs_offset
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'data_count' do
|
42
|
+
it 'is a count of bytes in the data_block trans2_data field' do
|
43
|
+
expect(parameter_block.data_count).to eq packet.data_block.trans2_data.do_num_bytes
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'data_offset' do
|
48
|
+
it 'contains the absolute_offset to the data_block trans2_data field' do
|
49
|
+
expect(parameter_block.data_offset).to eq packet.data_block.trans2_data.abs_offset
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#function' do
|
54
|
+
it 'should be a CREATE' do
|
55
|
+
expect(parameter_block.function).to eq RubySMB::SMB1::Packet::NtTrans::Subcommands::CREATE
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#data_block' do
|
61
|
+
subject(:data_block) { packet.data_block }
|
62
|
+
|
63
|
+
it 'is a Trans2 style DataBlock' do
|
64
|
+
expect(data_block).to be_a RubySMB::SMB1::Packet::Trans2::DataBlock
|
65
|
+
end
|
66
|
+
|
67
|
+
it { is_expected.to respond_to :trans2_parameters }
|
68
|
+
it { is_expected.to respond_to :trans2_data }
|
69
|
+
|
70
|
+
it 'should keep #trans2_parameters 4-byte aligned' do
|
71
|
+
expect(data_block.trans2_parameters.abs_offset % 4).to eq 0
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should keep #trans2_data 4-byte aligned' do
|
75
|
+
expect(data_block.trans2_data.abs_offset % 4).to eq 0
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#trans2_parameters' do
|
79
|
+
subject(:parameters) { data_block.trans2_parameters }
|
80
|
+
it { is_expected.to respond_to :flags }
|
81
|
+
it { is_expected.to respond_to :root_directory_fid }
|
82
|
+
it { is_expected.to respond_to :desired_access }
|
83
|
+
it { is_expected.to respond_to :allocation_size }
|
84
|
+
it { is_expected.to respond_to :ext_file_attribute }
|
85
|
+
it { is_expected.to respond_to :share_access }
|
86
|
+
it { is_expected.to respond_to :create_disposition }
|
87
|
+
it { is_expected.to respond_to :create_options }
|
88
|
+
it { is_expected.to respond_to :security_descriptor_length }
|
89
|
+
it { is_expected.to respond_to :ea_length }
|
90
|
+
it { is_expected.to respond_to :impersonation_level }
|
91
|
+
it { is_expected.to respond_to :security_flags }
|
92
|
+
it { is_expected.to respond_to :name }
|
93
|
+
|
94
|
+
describe '#desired_access' do
|
95
|
+
it 'is a File Access Mask' do
|
96
|
+
expect(parameters.desired_access).to be_a RubySMB::SMB1::BitField::FileAccessMask
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '#ext_file_attribute' do
|
101
|
+
it 'is a SMB Extended File Attributes struct' do
|
102
|
+
expect(parameters.ext_file_attribute).to be_a RubySMB::SMB1::BitField::SmbExtFileAttributes
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe '#share_access' do
|
107
|
+
it 'is a ShareAcess bitfield' do
|
108
|
+
expect(parameters.share_access).to be_a RubySMB::SMB1::BitField::ShareAccess
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe '#create_options' do
|
113
|
+
it 'is a CreateOptions bit field' do
|
114
|
+
expect(parameters.create_options).to be_a RubySMB::SMB1::BitField::CreateOptions
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe '#flags' do
|
119
|
+
subject(:flags) { parameters.flags }
|
120
|
+
|
121
|
+
it { is_expected.to respond_to :open_target_dir }
|
122
|
+
it { is_expected.to respond_to :request_opbatch }
|
123
|
+
it { is_expected.to respond_to :request_oplock }
|
124
|
+
|
125
|
+
describe '#open_target_dir' do
|
126
|
+
it 'is a 1-bit flag' do
|
127
|
+
expect(flags.open_target_dir).to be_a BinData::Bit1
|
128
|
+
end
|
129
|
+
|
130
|
+
it_behaves_like 'bit field with one flag set', :open_target_dir, 'V', 0x00000008
|
131
|
+
end
|
132
|
+
|
133
|
+
describe '#request_opbatch' do
|
134
|
+
it 'is a 1-bit flag' do
|
135
|
+
expect(flags.request_opbatch).to be_a BinData::Bit1
|
136
|
+
end
|
137
|
+
|
138
|
+
it_behaves_like 'bit field with one flag set', :request_opbatch, 'V', 0x00000004
|
139
|
+
end
|
140
|
+
|
141
|
+
describe '#request_oplock' do
|
142
|
+
it 'is a 1-bit flag' do
|
143
|
+
expect(flags.request_oplock).to be_a BinData::Bit1
|
144
|
+
end
|
145
|
+
|
146
|
+
it_behaves_like 'bit field with one flag set', :request_oplock, 'V', 0x00000002
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
describe '#security_flags' do
|
151
|
+
subject(:sec_flags) { parameters.security_flags }
|
152
|
+
|
153
|
+
it { is_expected.to respond_to :effective_only }
|
154
|
+
it { is_expected.to respond_to :context_tracking }
|
155
|
+
|
156
|
+
describe '#effective_only' do
|
157
|
+
it 'is a 1-bit flag' do
|
158
|
+
expect(sec_flags.effective_only).to be_a BinData::Bit1
|
159
|
+
end
|
160
|
+
|
161
|
+
it_behaves_like 'bit field with one flag set', :effective_only, 'C', 0x02
|
162
|
+
end
|
163
|
+
|
164
|
+
describe '#context_tracking' do
|
165
|
+
it 'is a 1-bit flag' do
|
166
|
+
expect(sec_flags.context_tracking).to be_a BinData::Bit1
|
167
|
+
end
|
168
|
+
|
169
|
+
it_behaves_like 'bit field with one flag set', :context_tracking, 'C', 0x01
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
describe '#trans2_data' do
|
175
|
+
subject(:data) { data_block.trans2_data}
|
176
|
+
|
177
|
+
it { is_expected.to respond_to :security_descriptor }
|
178
|
+
it { is_expected.to respond_to :extended_attributes }
|
179
|
+
|
180
|
+
describe '#security_descriptor' do
|
181
|
+
it 'is a Security Descriptor struct' do
|
182
|
+
expect(data.security_descriptor).to be_a RubySMB::Field::SecurityDescriptor
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
describe '#extended_attributes' do
|
187
|
+
it 'is a FileFullEAInfo struct' do
|
188
|
+
expect(data.extended_attributes).to be_a RubySMB::Field::FileFullEaInfo
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|
194
|
+
end
|