ruby_smb 0.0.21 → 0.0.22
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.tar.gz.sig +0 -0
- data/examples/net_share_enum_all.rb +5 -2
- data/lib/ruby_smb.rb +1 -1
- data/lib/ruby_smb/client.rb +4 -35
- data/lib/ruby_smb/dcerpc.rb +7 -22
- data/lib/ruby_smb/dcerpc/bind.rb +30 -36
- data/lib/ruby_smb/dcerpc/bind_ack.rb +72 -0
- data/lib/ruby_smb/dcerpc/error.rb +15 -0
- data/lib/ruby_smb/dcerpc/ndr.rb +31 -30
- data/lib/ruby_smb/dcerpc/p_syntax_id_t.rb +11 -0
- data/lib/ruby_smb/dcerpc/pdu_header.rb +29 -0
- data/lib/ruby_smb/dcerpc/ptypes.rb +26 -0
- data/lib/ruby_smb/dcerpc/request.rb +17 -30
- data/lib/ruby_smb/dcerpc/response.rb +15 -34
- data/lib/ruby_smb/dcerpc/srvsvc.rb +5 -7
- data/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all.rb +8 -4
- data/lib/ruby_smb/dcerpc/uuid.rb +31 -13
- data/lib/ruby_smb/smb1/bit_field.rb +0 -1
- data/lib/ruby_smb/smb1/bit_field/trans_flags.rb +3 -2
- data/lib/ruby_smb/smb1/data_block.rb +5 -0
- data/lib/ruby_smb/smb1/dcerpc.rb +67 -0
- data/lib/ruby_smb/smb1/packet.rb +1 -0
- data/lib/ruby_smb/smb1/packet/trans.rb +7 -1
- data/lib/ruby_smb/smb1/packet/trans/data_block.rb +19 -7
- data/lib/ruby_smb/smb1/packet/trans/request.rb +36 -25
- data/lib/ruby_smb/smb1/packet/trans/response.rb +22 -21
- data/lib/ruby_smb/smb1/packet/trans/subcommands.rb +1 -0
- data/lib/ruby_smb/smb1/packet/trans/transact_nmpipe_request.rb +61 -0
- data/lib/ruby_smb/smb1/packet/trans/transact_nmpipe_response.rb +44 -0
- data/lib/ruby_smb/smb1/packet/trans2/request.rb +1 -1
- data/lib/ruby_smb/smb1/pipe.rb +3 -0
- data/lib/ruby_smb/smb2/dcerpc.rb +68 -0
- data/lib/ruby_smb/smb2/pipe.rb +3 -0
- data/lib/ruby_smb/version.rb +1 -1
- data/spec/lib/ruby_smb/client_spec.rb +53 -6
- data/spec/lib/ruby_smb/dcerpc/bind_ack_spec.rb +224 -0
- data/spec/lib/ruby_smb/dcerpc/bind_spec.rb +255 -7
- data/spec/lib/ruby_smb/dcerpc/p_syntax_id_t_spec.rb +31 -0
- data/spec/lib/ruby_smb/dcerpc/pdu_header_spec.rb +84 -0
- data/spec/lib/ruby_smb/dcerpc/request_spec.rb +106 -13
- data/spec/lib/ruby_smb/dcerpc/response_spec.rb +89 -8
- data/spec/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all_spec.rb +176 -0
- data/spec/lib/ruby_smb/dcerpc/uuid_spec.rb +97 -1
- data/spec/lib/ruby_smb/smb1/data_block_spec.rb +43 -3
- data/spec/lib/ruby_smb/smb1/packet/trans/data_block_spec.rb +137 -0
- data/spec/lib/ruby_smb/smb1/packet/trans/request_spec.rb +239 -13
- data/spec/lib/ruby_smb/smb1/packet/trans/response_spec.rb +122 -13
- data/spec/lib/ruby_smb/smb1/packet/trans/transact_nmpipe_request_spec.rb +254 -0
- data/spec/lib/ruby_smb/smb1/packet/trans/transact_nmpipe_response_spec.rb +122 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/request_spec.rb +2 -2
- data/spec/lib/ruby_smb/smb1/pipe_spec.rb +199 -1
- data/spec/lib/ruby_smb/smb2/file_spec.rb +2 -1
- data/spec/lib/ruby_smb/smb2/pipe_spec.rb +196 -1
- metadata +25 -10
- metadata.gz.sig +0 -0
- data/lib/ruby_smb/dcerpc/handle.rb +0 -60
- data/lib/ruby_smb/smb1/bit_field/trans2_flags.rb +0 -15
- data/spec/lib/ruby_smb/dcerpc/handle_spec.rb +0 -31
- data/spec/lib/ruby_smb/dcerpc/srvsvc_spec.rb +0 -13
- data/spec/lib/ruby_smb/smb1/bit_field/trans2_flags_spec.rb +0 -26
@@ -1,14 +1,262 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
RSpec.describe RubySMB::Dcerpc::Bind do
|
2
|
+
let(:uuid) { '12345678-1234-4321-5678-123456789012' }
|
3
|
+
let(:ver_major) { 2 }
|
4
|
+
let(:ver_minor) { 8 }
|
5
|
+
let :endpoint do
|
6
|
+
endpoint = Module.new
|
7
|
+
endpoint.const_set('UUID', uuid)
|
8
|
+
endpoint.const_set('VER_MAJOR', ver_major)
|
9
|
+
endpoint.const_set('VER_MINOR', ver_minor)
|
10
|
+
endpoint
|
11
|
+
end
|
12
|
+
|
13
|
+
subject(:packet) { described_class.new }
|
14
|
+
|
15
|
+
it { is_expected.to respond_to :pdu_header }
|
16
|
+
it { is_expected.to respond_to :max_xmit_frag }
|
17
|
+
it { is_expected.to respond_to :max_recv_frag }
|
18
|
+
it { is_expected.to respond_to :assoc_group_id }
|
19
|
+
it { is_expected.to respond_to :p_context_list }
|
20
|
+
it { is_expected.to respond_to :auth_verifier }
|
21
|
+
|
22
|
+
it 'is little endian' do
|
23
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#pdu_header' do
|
27
|
+
subject(:header) { packet.pdu_header }
|
28
|
+
|
29
|
+
it 'is a standard PDU Header' do
|
30
|
+
expect(header).to be_a RubySMB::Dcerpc::PDUHeader
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should have the #ptype field set to PTypes::BIND' do
|
34
|
+
expect(header.ptype).to eq RubySMB::Dcerpc::PTypes::BIND
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#max_xmit_frag' do
|
39
|
+
it 'should be a 16-bit unsigned integer' do
|
40
|
+
expect(packet.max_xmit_frag).to be_a BinData::Uint16le
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should have a default value of 0xFFFF' do
|
44
|
+
expect(packet.max_xmit_frag).to eq 0xFFFF
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#max_recv_frag' do
|
49
|
+
it 'should be a 16-bit unsigned integer' do
|
50
|
+
expect(packet.max_recv_frag).to be_a BinData::Uint16le
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should have a default value of 0xFFFF' do
|
54
|
+
expect(packet.max_recv_frag).to eq 0xFFFF
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#assoc_group_id' do
|
59
|
+
it 'should be a 32-bit unsigned integer' do
|
60
|
+
expect(packet.assoc_group_id).to be_a BinData::Uint32le
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '#p_context_list' do
|
65
|
+
it 'should be a PContListT structure' do
|
66
|
+
expect(packet.p_context_list).to be_a RubySMB::Dcerpc::PContListT
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should have an #endpoint parameter' do
|
70
|
+
expect(packet.p_context_list.has_parameter?(:endpoint)).to be true
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '#auth_verifier' do
|
75
|
+
it 'should be a string' do
|
76
|
+
expect(packet.auth_verifier).to be_a BinData::String
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should not exist if the #auth_length PDU header field is 0' do
|
80
|
+
packet.pdu_header.auth_length = 0
|
81
|
+
expect(packet.auth_verifier?).to be false
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should exist only if the #auth_length PDU header field is greater than 0' do
|
85
|
+
packet.pdu_header.auth_length = 10
|
86
|
+
expect(packet.auth_verifier?).to be true
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'reads #auth_length bytes' do
|
90
|
+
auth_verifier = '12345678'
|
91
|
+
packet.pdu_header.auth_length = 6
|
92
|
+
packet.auth_verifier.read(auth_verifier)
|
93
|
+
expect(packet.auth_verifier).to eq(auth_verifier[0,6])
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'reads its own binary representation and output the same packet' do
|
98
|
+
packet = described_class.new(endpoint: endpoint)
|
99
|
+
packet.auth_verifier = '123456'
|
100
|
+
packet.pdu_header.auth_length = 6
|
101
|
+
binary = packet.to_binary_s
|
102
|
+
expect(described_class.read(binary)).to eq(packet)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
RSpec.describe RubySMB::Dcerpc::PContListT do
|
107
|
+
let(:uuid) { '12345678-1234-4321-5678-123456789012' }
|
108
|
+
let(:ver_major) { 2 }
|
109
|
+
let(:ver_minor) { 8 }
|
110
|
+
let :endpoint do
|
111
|
+
endpoint = Module.new
|
112
|
+
endpoint.const_set('UUID', uuid)
|
113
|
+
endpoint.const_set('VER_MAJOR', ver_major)
|
114
|
+
endpoint.const_set('VER_MINOR', ver_minor)
|
115
|
+
endpoint
|
116
|
+
end
|
117
|
+
|
118
|
+
subject(:packet) { described_class.new }
|
119
|
+
|
120
|
+
it { is_expected.to respond_to :n_context_elem }
|
121
|
+
it { is_expected.to respond_to :p_cont_elem }
|
122
|
+
|
123
|
+
it 'is little endian' do
|
124
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
125
|
+
end
|
4
126
|
|
5
|
-
describe '#
|
127
|
+
describe '#n_context_elem' do
|
128
|
+
it 'should be a 8-bit unsigned integer' do
|
129
|
+
expect(packet.n_context_elem).to be_a BinData::Uint8
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'should have the default value 1' do
|
133
|
+
expect(packet.n_context_elem).to eq 1
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe '#p_cont_elem' do
|
138
|
+
it 'should be an array of type PContElemT' do
|
139
|
+
expect(packet.p_cont_elem).to be_a BinData::Array
|
140
|
+
type = packet.p_cont_elem.get_parameter(:type)
|
141
|
+
expect(type.instantiate).to be_a RubySMB::Dcerpc::PContElemT
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'should have #n_context_elem elements' do
|
145
|
+
n_elements = 4
|
146
|
+
packet.n_context_elem = n_elements
|
147
|
+
expect(packet.p_cont_elem.size).to eq n_elements
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'should have an #endpoint parameter' do
|
151
|
+
expect(packet.p_cont_elem.has_parameter?(:endpoint)).to be true
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'reads its own binary representation and output the same packet' do
|
156
|
+
packet = described_class.new(endpoint: endpoint)
|
157
|
+
binary = packet.to_binary_s
|
158
|
+
expect(described_class.read(binary)).to eq(packet)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
RSpec.describe RubySMB::Dcerpc::PContElemT do
|
163
|
+
let(:uuid) { '12345678-1234-4321-5678-123456789012' }
|
164
|
+
let(:ver_major) { 2 }
|
165
|
+
let(:ver_minor) { 8 }
|
166
|
+
let :endpoint do
|
167
|
+
endpoint = Module.new
|
168
|
+
endpoint.const_set('UUID', uuid)
|
169
|
+
endpoint.const_set('VER_MAJOR', ver_major)
|
170
|
+
endpoint.const_set('VER_MINOR', ver_minor)
|
171
|
+
endpoint
|
172
|
+
end
|
173
|
+
|
174
|
+
subject(:packet) { described_class.new }
|
175
|
+
|
176
|
+
it { is_expected.to respond_to :p_cont_id }
|
177
|
+
it { is_expected.to respond_to :n_transfer_syn }
|
178
|
+
it { is_expected.to respond_to :abstract_syntax }
|
179
|
+
it { is_expected.to respond_to :transfer_syntaxes }
|
180
|
+
|
181
|
+
it 'is little endian' do
|
182
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
183
|
+
end
|
184
|
+
|
185
|
+
describe '#p_cont_id' do
|
186
|
+
it 'should be a 16-bit unsigned integer' do
|
187
|
+
expect(packet.p_cont_id).to be_a BinData::Uint16le
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
describe '#n_transfer_syn' do
|
192
|
+
it 'should be a 8-bit unsigned integer' do
|
193
|
+
expect(packet.n_transfer_syn).to be_a BinData::Uint8
|
194
|
+
end
|
195
|
+
|
196
|
+
it 'should have the default value 1' do
|
197
|
+
expect(packet.n_transfer_syn).to eq 1
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
describe '#abstract_syntax' do
|
202
|
+
it 'should be a PSyntaxIdT structure' do
|
203
|
+
expect(packet.abstract_syntax).to be_a RubySMB::Dcerpc::PSyntaxIdT
|
204
|
+
end
|
205
|
+
|
206
|
+
it 'should have an #uuid parameter' do
|
207
|
+
expect(packet.abstract_syntax.has_parameter?(:uuid)).to be true
|
208
|
+
end
|
209
|
+
|
210
|
+
it 'should have a #ver_major parameter' do
|
211
|
+
expect(packet.abstract_syntax.has_parameter?(:ver_major)).to be true
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'should have a #ver_minor parameter' do
|
215
|
+
expect(packet.abstract_syntax.has_parameter?(:ver_minor)).to be true
|
216
|
+
end
|
6
217
|
|
7
|
-
|
8
|
-
|
218
|
+
it 'should be initialized with the #endpoint constants' do
|
219
|
+
p_cont_elem_t = described_class.new(endpoint: endpoint)
|
9
220
|
|
10
|
-
|
11
|
-
expect(abstract_syntax).to eq
|
221
|
+
expect(p_cont_elem_t.abstract_syntax.if_uuid).to eq(uuid)
|
222
|
+
expect(p_cont_elem_t.abstract_syntax.if_ver_major).to eq(ver_major)
|
223
|
+
expect(p_cont_elem_t.abstract_syntax.if_ver_minor).to eq(ver_minor)
|
12
224
|
end
|
225
|
+
|
226
|
+
it 'should be initialized with the #endpoint constants when passed as a parameter to Bind' do
|
227
|
+
bind = RubySMB::Dcerpc::Bind.new(endpoint: endpoint)
|
228
|
+
p_cont_elem_t = bind.p_context_list.p_cont_elem.first
|
229
|
+
|
230
|
+
expect(p_cont_elem_t.abstract_syntax.if_uuid).to eq(uuid)
|
231
|
+
expect(p_cont_elem_t.abstract_syntax.if_ver_major).to eq(ver_major)
|
232
|
+
expect(p_cont_elem_t.abstract_syntax.if_ver_minor).to eq(ver_minor)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
describe '#transfer_syntaxes' do
|
237
|
+
it 'should be an array of type PSyntaxIdT' do
|
238
|
+
expect(packet.transfer_syntaxes).to be_a BinData::Array
|
239
|
+
type = packet.transfer_syntaxes.get_parameter(:type)
|
240
|
+
expect(type.instantiate).to be_a RubySMB::Dcerpc::PSyntaxIdT
|
241
|
+
end
|
242
|
+
|
243
|
+
it 'should have #n_transfer_syn elements' do
|
244
|
+
n_elements = 4
|
245
|
+
packet.n_transfer_syn = n_elements
|
246
|
+
expect(packet.transfer_syntaxes.size).to eq n_elements
|
247
|
+
end
|
248
|
+
|
249
|
+
it 'sets its elements to the NDR presentation syntax' do
|
250
|
+
expect(packet.transfer_syntaxes[0].if_uuid).to eq RubySMB::Dcerpc::Ndr::UUID
|
251
|
+
expect(packet.transfer_syntaxes[0].if_ver_major).to eq RubySMB::Dcerpc::Ndr::VER_MAJOR
|
252
|
+
expect(packet.transfer_syntaxes[0].if_ver_minor).to eq RubySMB::Dcerpc::Ndr::VER_MINOR
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
it 'reads its own binary representation and output the same packet' do
|
257
|
+
packet = described_class.new(endpoint: endpoint)
|
258
|
+
packet.n_transfer_syn = 2
|
259
|
+
binary = packet.to_binary_s
|
260
|
+
expect(described_class.read(binary)).to eq(packet)
|
13
261
|
end
|
14
262
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::PSyntaxIdT do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :if_uuid }
|
5
|
+
it { is_expected.to respond_to :if_ver_major }
|
6
|
+
it { is_expected.to respond_to :if_ver_minor }
|
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 '#if_uuid' do
|
13
|
+
it 'is a Uuid' do
|
14
|
+
expect(packet.if_uuid).to be_a RubySMB::Dcerpc::Uuid
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#if_ver_major' do
|
19
|
+
it 'should be a 16-bit unsigned integer' do
|
20
|
+
expect(packet.if_ver_major).to be_a BinData::Uint16le
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#if_ver_minor' do
|
25
|
+
it 'should be a 16-bit unsigned integer' do
|
26
|
+
expect(packet.if_ver_minor).to be_a BinData::Uint16le
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,84 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::PDUHeader do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :rpc_vers }
|
5
|
+
it { is_expected.to respond_to :rpc_vers_minor }
|
6
|
+
it { is_expected.to respond_to :ptype }
|
7
|
+
it { is_expected.to respond_to :pfc_flags }
|
8
|
+
it { is_expected.to respond_to :packed_drep }
|
9
|
+
it { is_expected.to respond_to :frag_length }
|
10
|
+
it { is_expected.to respond_to :auth_length }
|
11
|
+
it { is_expected.to respond_to :call_id }
|
12
|
+
|
13
|
+
it 'is little endian' do
|
14
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#rpc_vers' do
|
18
|
+
it 'should be a 8-bit unsigned integer' do
|
19
|
+
expect(packet.rpc_vers).to be_a BinData::Uint8
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should have a default value of 5' do
|
23
|
+
expect(packet.rpc_vers).to eq 5
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#rpc_vers_minor' do
|
28
|
+
it 'should be a 8-bit unsigned integer' do
|
29
|
+
expect(packet.rpc_vers_minor).to be_a BinData::Uint8
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#ptype' do
|
34
|
+
it 'should be a 8-bit unsigned integer' do
|
35
|
+
expect(packet.ptype).to be_a BinData::Uint8
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#pfc_flags' do
|
40
|
+
it 'should be a custom structure' do
|
41
|
+
expect(packet.pfc_flags).to be_a BinData::Struct
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#packed_drep' do
|
46
|
+
it 'should be a 32-bit unsigned integer' do
|
47
|
+
expect(packet.packed_drep).to be_a BinData::Uint32le
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should have a default value of 0x10' do
|
51
|
+
expect(packet.packed_drep).to eq 0x10
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#frag_length' do
|
56
|
+
it 'should be a 16-bit unsigned integer' do
|
57
|
+
expect(packet.frag_length).to be_a BinData::Uint16le
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should be the size of the full packet' do
|
61
|
+
bind_ack = RubySMB::Dcerpc::BindAck.new
|
62
|
+
expect(bind_ack.pdu_header.frag_length).to eq(bind_ack.do_num_bytes)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#auth_length' do
|
67
|
+
it 'should be a 16-bit unsigned integer' do
|
68
|
+
expect(packet.auth_length).to be_a BinData::Uint16le
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#call_id' do
|
73
|
+
it 'should be a 32-bit unsigned integer' do
|
74
|
+
expect(packet.call_id).to be_a BinData::Uint32le
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should have a default value of 1' do
|
78
|
+
expect(packet.call_id).to eq 1
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
|
@@ -1,21 +1,114 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
RSpec.describe RubySMB::Dcerpc::Request do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :pdu_header }
|
5
|
+
it { is_expected.to respond_to :alloc_hint }
|
6
|
+
it { is_expected.to respond_to :p_cont_id }
|
7
|
+
it { is_expected.to respond_to :opnum }
|
8
|
+
it { is_expected.to respond_to :object }
|
9
|
+
it { is_expected.to respond_to :stub }
|
10
|
+
it { is_expected.to respond_to :auth_verifier }
|
11
|
+
|
12
|
+
it 'is little endian' do
|
13
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#pdu_header' do
|
17
|
+
subject(:header) { packet.pdu_header }
|
18
|
+
|
19
|
+
it 'is a standard PDU Header' do
|
20
|
+
expect(header).to be_a RubySMB::Dcerpc::PDUHeader
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should have the #ptype field set to PTypes::BIND_ACK' do
|
24
|
+
expect(header.ptype).to eq RubySMB::Dcerpc::PTypes::REQUEST
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#alloc_hint' do
|
29
|
+
it 'should be a 32-bit unsigned integer' do
|
30
|
+
expect(packet.alloc_hint).to be_a BinData::Uint32le
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should be the size of the #stub field' do
|
34
|
+
packet = described_class.new({ :opnum => RubySMB::Dcerpc::Srvsvc::NET_SHARE_ENUM_ALL }, host: '1.2.3.4')
|
35
|
+
expect(packet.alloc_hint).to eq(packet.stub.do_num_bytes)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#p_cont_id' do
|
40
|
+
it 'should be a 16-bit unsigned integer' do
|
41
|
+
expect(packet.p_cont_id).to be_a BinData::Uint16le
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#opnum' do
|
46
|
+
it 'should be a 16-bit unsigned integer' do
|
47
|
+
expect(packet.opnum).to be_a BinData::Uint16le
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#object' do
|
52
|
+
it 'is a Uuid' do
|
53
|
+
expect(packet.object).to be_a RubySMB::Dcerpc::Uuid
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'only exists if #object_uuid header flag is set' do
|
57
|
+
packet.pdu_header.pfc_flags.object_uuid = 1
|
58
|
+
expect(packet.object?).to be true
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'does not exist if #object_uuid header flag is not set' do
|
62
|
+
packet.pdu_header.pfc_flags.object_uuid = 0
|
63
|
+
expect(packet.object?).to be false
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#stub' do
|
68
|
+
it 'is a Bindata Choice' do
|
69
|
+
expect(packet.stub).to be_a BinData::Choice
|
70
|
+
end
|
4
71
|
|
5
|
-
|
6
|
-
let(:request){
|
7
|
-
described_class.new(
|
8
|
-
opnum: RubySMB::Dcerpc::Srvsvc::NetShareEnumAll::Opnum,
|
9
|
-
stub: RubySMB::Dcerpc::Srvsvc::NetShareEnumAll.new(host: '192.161.204.122').to_binary_s
|
10
|
-
)
|
11
|
-
}
|
72
|
+
context 'with a NetShareEnumAll stub' do
|
12
73
|
|
13
|
-
|
14
|
-
|
74
|
+
it 'uses opnum as a selector' do
|
75
|
+
packet = described_class.new({ :opnum => RubySMB::Dcerpc::Srvsvc::NET_SHARE_ENUM_ALL }, host: '1.2.3.4')
|
76
|
+
expect(packet.stub.selection).to eq(packet.opnum)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#auth_verifier' do
|
82
|
+
it 'should be a string' do
|
83
|
+
expect(packet.auth_verifier).to be_a BinData::String
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should not exist if the #auth_length PDU header field is 0' do
|
87
|
+
packet.pdu_header.auth_length = 0
|
88
|
+
expect(packet.auth_verifier?).to be false
|
15
89
|
end
|
16
90
|
|
17
|
-
it 'should
|
18
|
-
|
91
|
+
it 'should exist only if the #auth_length PDU header field is greater than 0' do
|
92
|
+
packet.pdu_header.auth_length = 10
|
93
|
+
expect(packet.auth_verifier?).to be true
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'reads #auth_length bytes' do
|
97
|
+
auth_verifier = '12345678'
|
98
|
+
packet.pdu_header.auth_length = 6
|
99
|
+
packet.auth_verifier.read(auth_verifier)
|
100
|
+
expect(packet.auth_verifier).to eq(auth_verifier[0,6])
|
19
101
|
end
|
20
102
|
end
|
103
|
+
|
104
|
+
it 'reads its own binary representation and output the same packet' do
|
105
|
+
packet = described_class.new({ :opnum => RubySMB::Dcerpc::Srvsvc::NET_SHARE_ENUM_ALL }, host: '1.2.3.4')
|
106
|
+
packet.pdu_header.pfc_flags.object_uuid = 1
|
107
|
+
packet.object = '8a885d04-1ceb-11c9-9fe8-08002b104860'
|
108
|
+
packet.auth_verifier = '123456'
|
109
|
+
packet.pdu_header.auth_length = 6
|
110
|
+
binary = packet.to_binary_s
|
111
|
+
expect(described_class.read(binary)).to eq(packet)
|
112
|
+
end
|
21
113
|
end
|
114
|
+
|