ruby_smb 1.0.5 → 1.1.0
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 +0 -0
- data.tar.gz.sig +0 -0
- data/.travis.yml +4 -1
- data/README.md +35 -47
- data/examples/enum_registry_key.rb +28 -0
- data/examples/enum_registry_values.rb +30 -0
- data/examples/pipes.rb +2 -1
- data/examples/read_registry_key_value.rb +32 -0
- data/lib/ruby_smb.rb +0 -1
- data/lib/ruby_smb/client.rb +2 -0
- data/lib/ruby_smb/client/winreg.rb +46 -0
- data/lib/ruby_smb/dcerpc.rb +38 -0
- data/lib/ruby_smb/dcerpc/bind.rb +2 -2
- data/lib/ruby_smb/dcerpc/bind_ack.rb +2 -2
- data/lib/ruby_smb/dcerpc/error.rb +3 -0
- data/lib/ruby_smb/dcerpc/ndr.rb +95 -16
- data/lib/ruby_smb/dcerpc/pdu_header.rb +1 -1
- data/lib/ruby_smb/dcerpc/request.rb +28 -9
- data/lib/ruby_smb/dcerpc/rrp_unicode_string.rb +35 -0
- data/lib/ruby_smb/dcerpc/srvsvc.rb +10 -0
- data/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all.rb +9 -0
- data/lib/ruby_smb/dcerpc/winreg.rb +340 -0
- data/lib/ruby_smb/dcerpc/winreg/close_key_request.rb +24 -0
- data/lib/ruby_smb/dcerpc/winreg/close_key_response.rb +27 -0
- data/lib/ruby_smb/dcerpc/winreg/enum_key_request.rb +45 -0
- data/lib/ruby_smb/dcerpc/winreg/enum_key_response.rb +42 -0
- data/lib/ruby_smb/dcerpc/winreg/enum_value_request.rb +39 -0
- data/lib/ruby_smb/dcerpc/winreg/enum_value_response.rb +36 -0
- data/lib/ruby_smb/dcerpc/winreg/open_key_request.rb +34 -0
- data/lib/ruby_smb/dcerpc/winreg/open_key_response.rb +25 -0
- data/lib/ruby_smb/dcerpc/winreg/open_root_key_request.rb +43 -0
- data/lib/ruby_smb/dcerpc/winreg/open_root_key_response.rb +35 -0
- data/lib/ruby_smb/dcerpc/winreg/query_info_key_request.rb +27 -0
- data/lib/ruby_smb/dcerpc/winreg/query_info_key_response.rb +40 -0
- data/lib/ruby_smb/dcerpc/winreg/query_value_request.rb +39 -0
- data/lib/ruby_smb/dcerpc/winreg/query_value_response.rb +57 -0
- data/lib/ruby_smb/dcerpc/winreg/regsam.rb +40 -0
- data/lib/ruby_smb/smb1/file.rb +2 -0
- data/lib/ruby_smb/smb1/pipe.rb +78 -2
- data/lib/ruby_smb/smb2/packet/error_packet.rb +2 -4
- data/lib/ruby_smb/smb2/pipe.rb +89 -2
- data/lib/ruby_smb/version.rb +1 -1
- data/ruby_smb.gemspec +3 -3
- data/spec/lib/ruby_smb/client_spec.rb +148 -0
- data/spec/lib/ruby_smb/dcerpc/bind_ack_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/bind_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/ndr_spec.rb +410 -0
- data/spec/lib/ruby_smb/dcerpc/request_spec.rb +50 -7
- data/spec/lib/ruby_smb/dcerpc/rrp_unicode_string_spec.rb +98 -0
- data/spec/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all_spec.rb +13 -0
- data/spec/lib/ruby_smb/dcerpc/srvsvc_spec.rb +60 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/close_key_request_spec.rb +28 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/close_key_response_spec.rb +36 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/enum_key_request_spec.rb +108 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/enum_key_response_spec.rb +97 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_request_spec.rb +94 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_response_spec.rb +82 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/open_key_request_spec.rb +74 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/open_key_response_spec.rb +35 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_request_spec.rb +90 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_response_spec.rb +38 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/query_info_key_request_spec.rb +39 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/query_info_key_response_spec.rb +113 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/query_value_request_spec.rb +88 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/query_value_response_spec.rb +150 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/regsam_spec.rb +32 -0
- data/spec/lib/ruby_smb/dcerpc/winreg_spec.rb +710 -0
- data/spec/lib/ruby_smb/dcerpc_spec.rb +81 -0
- data/spec/lib/ruby_smb/smb1/file_spec.rb +9 -1
- data/spec/lib/ruby_smb/smb1/pipe_spec.rb +210 -148
- data/spec/lib/ruby_smb/smb2/packet/error_packet_spec.rb +3 -24
- data/spec/lib/ruby_smb/smb2/pipe_spec.rb +256 -145
- metadata +66 -9
- metadata.gz.sig +0 -0
- data/lib/ruby_smb/smb1/dcerpc.rb +0 -72
- data/lib/ruby_smb/smb2/dcerpc.rb +0 -75
@@ -31,7 +31,7 @@ RSpec.describe RubySMB::Dcerpc::BindAck do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'should have a default value of 0xFFFF' do
|
34
|
-
expect(packet.max_xmit_frag).to eq
|
34
|
+
expect(packet.max_xmit_frag).to eq RubySMB::Dcerpc::MAX_XMIT_FRAG
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -41,7 +41,7 @@ RSpec.describe RubySMB::Dcerpc::BindAck do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'should have a default value of 0xFFFF' do
|
44
|
-
expect(packet.max_recv_frag).to eq
|
44
|
+
expect(packet.max_recv_frag).to eq RubySMB::Dcerpc::MAX_RECV_FRAG
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -41,7 +41,7 @@ RSpec.describe RubySMB::Dcerpc::Bind do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'should have a default value of 0xFFFF' do
|
44
|
-
expect(packet.max_xmit_frag).to eq
|
44
|
+
expect(packet.max_xmit_frag).to eq RubySMB::Dcerpc::MAX_XMIT_FRAG
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -51,7 +51,7 @@ RSpec.describe RubySMB::Dcerpc::Bind do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'should have a default value of 0xFFFF' do
|
54
|
-
expect(packet.max_recv_frag).to eq
|
54
|
+
expect(packet.max_recv_frag).to eq RubySMB::Dcerpc::MAX_RECV_FRAG
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -0,0 +1,410 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Ndr::NdrTopLevelFullPointer do
|
2
|
+
subject(:packet) do
|
3
|
+
Class.new(described_class) do
|
4
|
+
endian :little
|
5
|
+
string :referent
|
6
|
+
end.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it { is_expected.to respond_to :referent_identifier }
|
10
|
+
|
11
|
+
it 'is little endian' do
|
12
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#referent_identifier' do
|
16
|
+
it 'is a 32-bit unsigned integer' do
|
17
|
+
expect(packet.referent_identifier).to be_a BinData::Uint32le
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'has an initial value of 0x00020000' do
|
21
|
+
expect(packet.referent_identifier).to eq(0x00020000)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#get' do
|
26
|
+
it 'returns 0 when #referent_identifier is 0' do
|
27
|
+
packet.referent_identifier = 0
|
28
|
+
expect(packet.get).to eq(0)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'returns #referent when #referent_identifier is greater than 0' do
|
32
|
+
packet.set('spec_test')
|
33
|
+
expect(packet.get).to eq(packet.referent)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#set' do
|
38
|
+
context 'when the value is 0' do
|
39
|
+
it 'sets #referent_identifier to 0' do
|
40
|
+
packet.set(0)
|
41
|
+
expect(packet.referent_identifier).to eq(0)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when the value is a string' do
|
46
|
+
it 'sets #referent to the value' do
|
47
|
+
str = 'spec_test'
|
48
|
+
packet.set(str)
|
49
|
+
expect(packet.referent).to eq(str)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
RSpec.describe RubySMB::Dcerpc::Ndr::NdrString do
|
56
|
+
subject(:packet) { described_class.new }
|
57
|
+
|
58
|
+
it { is_expected.to respond_to :max_count }
|
59
|
+
it { is_expected.to respond_to :offset }
|
60
|
+
it { is_expected.to respond_to :actual_count }
|
61
|
+
it { is_expected.to respond_to :str }
|
62
|
+
|
63
|
+
it 'is little endian' do
|
64
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#max_count' do
|
68
|
+
it 'is a 32-bit unsigned integer' do
|
69
|
+
expect(packet.max_count).to be_a BinData::Uint32le
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '#offset' do
|
74
|
+
it 'is a 32-bit unsigned integer' do
|
75
|
+
expect(packet.offset).to be_a BinData::Uint32le
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'has an initial valu of 0' do
|
79
|
+
expect(packet.offset).to eq(0)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '#actual_count' do
|
84
|
+
it 'is a 32-bit unsigned integer' do
|
85
|
+
expect(packet.actual_count).to be_a BinData::Uint32le
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe '#str' do
|
90
|
+
it 'is a RubySMB::Field::Stringz16' do
|
91
|
+
expect(packet.str).to be_a RubySMB::Field::Stringz16
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'exists if #actual_count is greater than 0' do
|
95
|
+
packet.actual_count = 4
|
96
|
+
expect(packet.str?).to be true
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'does not exist if #actual_count is 0' do
|
100
|
+
expect(packet.str?).to be false
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe '#get' do
|
105
|
+
it 'returns 0 when #actual_count is 0' do
|
106
|
+
expect(packet.get).to eq(0)
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'returns #str when #actual_count is greater than 0' do
|
110
|
+
str = 'spec_test'
|
111
|
+
strz16 = RubySMB::Field::Stringz16.new(str)
|
112
|
+
packet.set(str)
|
113
|
+
expect(packet.get).to eq(strz16)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe '#set' do
|
118
|
+
context 'when the value is 0' do
|
119
|
+
it 'sets #actual_count to 0' do
|
120
|
+
packet.set(0)
|
121
|
+
expect(packet.actual_count).to eq(0)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context 'when the value is a string' do
|
126
|
+
let(:str) { 'spec_test' }
|
127
|
+
|
128
|
+
it 'sets #str to the value' do
|
129
|
+
packet.set(str)
|
130
|
+
strz16 = RubySMB::Field::Stringz16.new(str)
|
131
|
+
expect(packet.str).to eq(strz16)
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'sets #max_count and #actual_count to the expected value' do
|
135
|
+
packet.set(str)
|
136
|
+
expect(packet.max_count).to eq(str.length + 1)
|
137
|
+
expect(packet.actual_count).to eq(str.length + 1)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
RSpec.describe RubySMB::Dcerpc::Ndr::NdrLpStr do
|
144
|
+
it 'is NdrTopLevelFullPointer subclass' do
|
145
|
+
expect(described_class).to be < RubySMB::Dcerpc::Ndr::NdrTopLevelFullPointer
|
146
|
+
end
|
147
|
+
|
148
|
+
subject(:packet) { described_class.new }
|
149
|
+
|
150
|
+
it { is_expected.to respond_to :referent }
|
151
|
+
|
152
|
+
it 'is little endian' do
|
153
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
154
|
+
end
|
155
|
+
|
156
|
+
describe '#referent' do
|
157
|
+
it 'is a NdrString' do
|
158
|
+
expect(packet.referent).to be_a RubySMB::Dcerpc::Ndr::NdrString
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'exists if superclass #referent_identifier is not zero' do
|
162
|
+
expect(packet.referent?).to be true
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'does not exist if superclass #referent_identifier is zero' do
|
166
|
+
packet.referent_identifier = 0
|
167
|
+
expect(packet.referent?).to be false
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
describe '#to_s' do
|
172
|
+
it 'returns "\0" when #referent_identifier is 0' do
|
173
|
+
packet.referent_identifier = 0
|
174
|
+
expect(packet.to_s).to eq("\0")
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'returns #referent when #referent_identifier is greater than 0' do
|
178
|
+
packet.set('spec_test')
|
179
|
+
expect(packet.to_s).to eq(packet.referent)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
RSpec.describe RubySMB::Dcerpc::Ndr::NdrContextHandle do
|
185
|
+
let(:uuid) { 'c3bce70d-5155-472b-9f2f-b824e5fc9b60' }
|
186
|
+
let(:attr) { 123 }
|
187
|
+
subject(:packet) { described_class.new }
|
188
|
+
|
189
|
+
it { is_expected.to respond_to :context_handle_attributes }
|
190
|
+
it { is_expected.to respond_to :context_handle_uuid }
|
191
|
+
|
192
|
+
it 'is little endian' do
|
193
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
194
|
+
end
|
195
|
+
|
196
|
+
describe '#context_handle_attributes' do
|
197
|
+
it 'is a 32-bit unsigned integer' do
|
198
|
+
expect(packet.context_handle_attributes).to be_a BinData::Uint32le
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
describe '#context_handle_uuid' do
|
203
|
+
it 'is a UUID' do
|
204
|
+
expect(packet.context_handle_uuid).to be_a RubySMB::Dcerpc::Uuid
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
describe '#get' do
|
209
|
+
it 'returns the expeted hash' do
|
210
|
+
packet.context_handle_attributes = attr
|
211
|
+
packet.context_handle_uuid = uuid
|
212
|
+
expect(packet.get).to eq({context_handle_attributes: attr, context_handle_uuid: uuid})
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
describe '#set' do
|
217
|
+
let(:handle) { {context_handle_attributes: attr, context_handle_uuid: uuid} }
|
218
|
+
|
219
|
+
context 'when the value is a hash' do
|
220
|
+
it 'sets #context_handle_attributes and #context_handle_uuid to the expected values' do
|
221
|
+
packet.set(handle)
|
222
|
+
expect(packet.context_handle_attributes).to eq(attr)
|
223
|
+
expect(packet.context_handle_uuid).to eq(uuid)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
context 'when the value is a NdrContextHandle'do
|
228
|
+
it 'reads the value binary representaion ' do
|
229
|
+
ndr_context_handle = described_class.new(handle)
|
230
|
+
allow(ndr_context_handle).to receive(:to_binary_s).and_call_original
|
231
|
+
packet.set(ndr_context_handle)
|
232
|
+
expect(ndr_context_handle).to have_received(:to_binary_s)
|
233
|
+
expect(packet.get).to eq(ndr_context_handle)
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
context 'when the value is a binary string'do
|
238
|
+
it 'reads the value' do
|
239
|
+
ndr_context_handle = described_class.new(handle)
|
240
|
+
packet.set(ndr_context_handle.to_binary_s)
|
241
|
+
expect(packet.get).to eq(ndr_context_handle)
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
RSpec.describe RubySMB::Dcerpc::Ndr::NdrLpDword do
|
248
|
+
it 'is NdrTopLevelFullPointer subclass' do
|
249
|
+
expect(described_class).to be < RubySMB::Dcerpc::Ndr::NdrTopLevelFullPointer
|
250
|
+
end
|
251
|
+
|
252
|
+
subject(:packet) { described_class.new }
|
253
|
+
|
254
|
+
it { is_expected.to respond_to :referent }
|
255
|
+
|
256
|
+
it 'is little endian' do
|
257
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
258
|
+
end
|
259
|
+
|
260
|
+
describe '#referent' do
|
261
|
+
it 'is a 32-bit unsigned integer' do
|
262
|
+
expect(packet.referent).to be_a BinData::Uint32le
|
263
|
+
end
|
264
|
+
|
265
|
+
it 'exists if superclass #referent_identifier is not zero' do
|
266
|
+
expect(packet.referent?).to be true
|
267
|
+
end
|
268
|
+
|
269
|
+
it 'does not exist if superclass #referent_identifier is zero' do
|
270
|
+
packet.referent_identifier = 0
|
271
|
+
expect(packet.referent?).to be false
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
RSpec.describe RubySMB::Dcerpc::Ndr::NdrLpByte do
|
277
|
+
subject(:packet) { described_class.new }
|
278
|
+
|
279
|
+
it { is_expected.to respond_to :referent_identifier }
|
280
|
+
it { is_expected.to respond_to :max_count }
|
281
|
+
it { is_expected.to respond_to :offset }
|
282
|
+
it { is_expected.to respond_to :actual_count }
|
283
|
+
it { is_expected.to respond_to :bytes }
|
284
|
+
|
285
|
+
it 'is little endian' do
|
286
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
287
|
+
end
|
288
|
+
|
289
|
+
describe '#referent_identifier' do
|
290
|
+
it 'is a 32-bit unsigned integer' do
|
291
|
+
expect(packet.referent_identifier).to be_a BinData::Uint32le
|
292
|
+
end
|
293
|
+
|
294
|
+
it 'has an initial value of 0x00020000' do
|
295
|
+
expect(packet.referent_identifier).to eq(0x00020000)
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
describe '#max_count' do
|
300
|
+
it 'is a 32-bit unsigned integer' do
|
301
|
+
expect(packet.max_count).to be_a BinData::Uint32le
|
302
|
+
end
|
303
|
+
|
304
|
+
it 'has an initial value equal to #actual_count' do
|
305
|
+
packet.actual_count = 345
|
306
|
+
expect(packet.max_count).to eq(345)
|
307
|
+
end
|
308
|
+
|
309
|
+
it 'exists if #referent_identifier is not zero' do
|
310
|
+
expect(packet.max_count?).to be true
|
311
|
+
end
|
312
|
+
|
313
|
+
it 'does not exist if #referent_identifier is zero' do
|
314
|
+
packet.referent_identifier = 0
|
315
|
+
expect(packet.max_count?).to be false
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
describe '#offset' do
|
320
|
+
it 'is a 32-bit unsigned integer' do
|
321
|
+
expect(packet.offset).to be_a BinData::Uint32le
|
322
|
+
end
|
323
|
+
|
324
|
+
it 'has an initial value of 0' do
|
325
|
+
expect(packet.offset).to eq(0)
|
326
|
+
end
|
327
|
+
|
328
|
+
it 'exists if #referent_identifier is not zero' do
|
329
|
+
expect(packet.offset?).to be true
|
330
|
+
end
|
331
|
+
|
332
|
+
it 'does not exist if #referent_identifier is zero' do
|
333
|
+
packet.referent_identifier = 0
|
334
|
+
expect(packet.offset?).to be false
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
describe '#actual_count' do
|
339
|
+
it 'is a 32-bit unsigned integer' do
|
340
|
+
expect(packet.actual_count).to be_a BinData::Uint32le
|
341
|
+
end
|
342
|
+
|
343
|
+
it 'has an initial value equal to #bytes size' do
|
344
|
+
packet.bytes << 2 << 3 << 4 << 5
|
345
|
+
expect(packet.actual_count).to eq(4)
|
346
|
+
end
|
347
|
+
|
348
|
+
it 'exists if #referent_identifier is not zero' do
|
349
|
+
expect(packet.actual_count?).to be true
|
350
|
+
end
|
351
|
+
|
352
|
+
it 'does not exist if #referent_identifier is zero' do
|
353
|
+
packet.referent_identifier = 0
|
354
|
+
expect(packet.actual_count?).to be false
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
describe '#bytes' do
|
359
|
+
it 'is a Bindata::Array' do
|
360
|
+
expect(packet.bytes).to be_a BinData::Array
|
361
|
+
end
|
362
|
+
|
363
|
+
it 'has an initial length equal to #actual_count' do
|
364
|
+
packet.actual_count = 3
|
365
|
+
expect(packet.bytes.size).to eq(3)
|
366
|
+
end
|
367
|
+
|
368
|
+
it 'is 8-bit unsigned integer elements' do
|
369
|
+
expect(packet.bytes[0]).to be_a BinData::Uint8
|
370
|
+
end
|
371
|
+
|
372
|
+
it 'exists if #referent_identifier is not zero' do
|
373
|
+
expect(packet.bytes?).to be true
|
374
|
+
end
|
375
|
+
|
376
|
+
it 'does not exist if #referent_identifier is zero' do
|
377
|
+
packet.referent_identifier = 0
|
378
|
+
expect(packet.bytes?).to be false
|
379
|
+
end
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
383
|
+
RSpec.describe RubySMB::Dcerpc::Ndr::NdrLpFileTime do
|
384
|
+
it 'is NdrTopLevelFullPointer subclass' do
|
385
|
+
expect(described_class).to be < RubySMB::Dcerpc::Ndr::NdrTopLevelFullPointer
|
386
|
+
end
|
387
|
+
|
388
|
+
subject(:packet) { described_class.new }
|
389
|
+
|
390
|
+
it { is_expected.to respond_to :referent }
|
391
|
+
|
392
|
+
it 'is little endian' do
|
393
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
394
|
+
end
|
395
|
+
|
396
|
+
describe '#referent' do
|
397
|
+
it 'is a FileTime' do
|
398
|
+
expect(packet.referent).to be_a RubySMB::Field::FileTime
|
399
|
+
end
|
400
|
+
|
401
|
+
it 'exists if superclass #referent_identifier is not zero' do
|
402
|
+
expect(packet.referent?).to be true
|
403
|
+
end
|
404
|
+
|
405
|
+
it 'does not exist if superclass #referent_identifier is zero' do
|
406
|
+
packet.referent_identifier = 0
|
407
|
+
expect(packet.referent?).to be false
|
408
|
+
end
|
409
|
+
end
|
410
|
+
end
|
@@ -69,11 +69,51 @@ RSpec.describe RubySMB::Dcerpc::Request do
|
|
69
69
|
expect(packet.stub).to be_a BinData::Choice
|
70
70
|
end
|
71
71
|
|
72
|
-
context 'with a
|
72
|
+
context 'with a Srvsvc endpoint' do
|
73
|
+
let(:host) { '1.2.3.4' }
|
74
|
+
let(:packet) do
|
75
|
+
described_class.new(
|
76
|
+
{ :opnum => RubySMB::Dcerpc::Srvsvc::NET_SHARE_ENUM_ALL },
|
77
|
+
{ :endpoint => 'Srvsvc', :host => host }
|
78
|
+
)
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'uses endpoint parameter to select a Srvsvc stub packet' do
|
82
|
+
expect(packet.stub.selection).to eq('Srvsvc')
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'selects the expected packet structure' do
|
86
|
+
expect(packet.stub).to eq(RubySMB::Dcerpc::Srvsvc::NetShareEnumAll.new(host: host))
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context 'with a Winreg endpoint' do
|
91
|
+
let(:opnum) { RubySMB::Dcerpc::Winreg::OPEN_HKCR }
|
92
|
+
let(:packet) do
|
93
|
+
described_class.new(
|
94
|
+
{ :opnum => opnum },
|
95
|
+
{ :endpoint => 'Winreg' }
|
96
|
+
)
|
97
|
+
end
|
73
98
|
|
74
|
-
it 'uses
|
75
|
-
packet
|
76
|
-
|
99
|
+
it 'uses endpoint parameter to select a Winreg stub packet' do
|
100
|
+
expect(packet.stub.selection).to eq('Winreg')
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'selects the expected packet structure' do
|
104
|
+
expect(packet.stub).to eq(RubySMB::Dcerpc::Winreg::OpenRootKeyRequest.new(opnum: opnum))
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'with an unknown endpoint' do
|
109
|
+
let(:packet) do
|
110
|
+
described_class.new(
|
111
|
+
{ :endpoint => 'Unknown' }
|
112
|
+
)
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'sets #stub to an empty string' do
|
116
|
+
expect(packet.stub).to eq('')
|
77
117
|
end
|
78
118
|
end
|
79
119
|
end
|
@@ -102,13 +142,16 @@ RSpec.describe RubySMB::Dcerpc::Request do
|
|
102
142
|
end
|
103
143
|
|
104
144
|
it 'reads its own binary representation and output the same packet' do
|
105
|
-
packet = described_class.new(
|
145
|
+
packet = described_class.new(
|
146
|
+
{ :opnum => RubySMB::Dcerpc::Srvsvc::NET_SHARE_ENUM_ALL },
|
147
|
+
{ :endpoint => 'Srvsvc', :host => '1.2.3.4' }
|
148
|
+
)
|
106
149
|
packet.pdu_header.pfc_flags.object_uuid = 1
|
107
150
|
packet.object = '8a885d04-1ceb-11c9-9fe8-08002b104860'
|
108
151
|
packet.auth_verifier = '123456'
|
109
152
|
packet.pdu_header.auth_length = 6
|
110
153
|
binary = packet.to_binary_s
|
111
|
-
|
154
|
+
packet2 = described_class.new( { :endpoint => 'Srvsvc' } )
|
155
|
+
expect(packet2.read(binary)).to eq(packet)
|
112
156
|
end
|
113
157
|
end
|
114
|
-
|