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
@@ -195,7 +195,7 @@ RSpec.describe RubySMB::SMB2::File do
|
|
195
195
|
end
|
196
196
|
end
|
197
197
|
end
|
198
|
-
|
198
|
+
|
199
199
|
describe '#rename_packet' do
|
200
200
|
it 'creates a new SetInfoRequest packet' do
|
201
201
|
expect(RubySMB::SMB2::Packet::SetInfoRequest).to receive(:new).and_call_original
|
@@ -231,3 +231,4 @@ RSpec.describe RubySMB::SMB2::File do
|
|
231
231
|
end
|
232
232
|
end
|
233
233
|
end
|
234
|
+
|
@@ -61,4 +61,199 @@ RSpec.describe RubySMB::SMB2::Pipe do
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
|
64
|
+
context 'with DCERPC' do
|
65
|
+
describe '#net_share_enum_all' do
|
66
|
+
let(:host) { '1.2.3.4' }
|
67
|
+
let(:dcerpc_response) { RubySMB::Dcerpc::Response.new }
|
68
|
+
|
69
|
+
before :example do
|
70
|
+
allow(pipe).to receive(:bind)
|
71
|
+
allow(pipe).to receive(:request).and_return(dcerpc_response)
|
72
|
+
allow(RubySMB::Dcerpc::Srvsvc::NetShareEnumAll).to receive(:parse_response).and_return([])
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'calls #bind with the expected arguments' do
|
76
|
+
expect(pipe).to receive(:bind).with(endpoint: RubySMB::Dcerpc::Srvsvc)
|
77
|
+
pipe.net_share_enum_all(host)
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'calls #request with the expected arguments' do
|
81
|
+
expect(pipe).to receive(:request).with(RubySMB::Dcerpc::Srvsvc::NET_SHARE_ENUM_ALL, host: host)
|
82
|
+
pipe.net_share_enum_all(host)
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'parse the response with NetShareEnumAll #parse_response method' do
|
86
|
+
stub = 'ABCD'
|
87
|
+
dcerpc_response.alloc_hint = stub.size
|
88
|
+
dcerpc_response.stub = stub
|
89
|
+
expect(RubySMB::Dcerpc::Srvsvc::NetShareEnumAll).to receive(:parse_response).with(stub)
|
90
|
+
pipe.net_share_enum_all(host)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'returns the remote shares' do
|
94
|
+
shares = [
|
95
|
+
["C$", "DISK", "Default share"],
|
96
|
+
["Shared", "DISK", ""],
|
97
|
+
["IPC$", "IPC", "Remote IPC"],
|
98
|
+
["ADMIN$", "DISK", "Remote Admin"]
|
99
|
+
]
|
100
|
+
output = [
|
101
|
+
{:name=>"C$", :type=>"DISK", :comment=>"Default share"},
|
102
|
+
{:name=>"Shared", :type=>"DISK", :comment=>""},
|
103
|
+
{:name=>"IPC$", :type=>"IPC", :comment=>"Remote IPC"},
|
104
|
+
{:name=>"ADMIN$", :type=>"DISK", :comment=>"Remote Admin"},
|
105
|
+
]
|
106
|
+
allow(RubySMB::Dcerpc::Srvsvc::NetShareEnumAll).to receive(:parse_response).and_return(shares)
|
107
|
+
expect(pipe.net_share_enum_all(host)).to eq(output)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe '#bind' do
|
112
|
+
let(:options) { { endpoint: RubySMB::Dcerpc::Srvsvc } }
|
113
|
+
let(:bind_packet) { RubySMB::Dcerpc::Bind.new(options) }
|
114
|
+
let(:ioctl_response) { RubySMB::SMB2::Packet::IoctlResponse.new }
|
115
|
+
let(:bind_ack_packet) { RubySMB::Dcerpc::BindAck.new }
|
116
|
+
|
117
|
+
before :example do
|
118
|
+
allow(RubySMB::Dcerpc::Bind).to receive(:new).and_return(bind_packet)
|
119
|
+
allow(pipe).to receive(:ioctl_send_recv).and_return(ioctl_response)
|
120
|
+
bind_ack_packet.p_result_list.n_results = 1
|
121
|
+
bind_ack_packet.p_result_list.p_results[0].result = RubySMB::Dcerpc::BindAck::ACCEPTANCE
|
122
|
+
allow(RubySMB::Dcerpc::BindAck).to receive(:read).and_return(bind_ack_packet)
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'creates a Bind packet' do
|
126
|
+
expect(RubySMB::Dcerpc::Bind).to receive(:new).with(options).and_return(bind_packet)
|
127
|
+
pipe.bind(options)
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'calls #ioctl_send_recv' do
|
131
|
+
expect(pipe).to receive(:ioctl_send_recv).with(bind_packet, options)
|
132
|
+
pipe.bind(options)
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'creates a BindAck packet from the response' do
|
136
|
+
expect(RubySMB::Dcerpc::BindAck).to receive(:read).with(ioctl_response.output_data).and_return(bind_ack_packet)
|
137
|
+
pipe.bind(options)
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'raises the expected exception when an invalid packet is received' do
|
141
|
+
allow(RubySMB::Dcerpc::BindAck).to receive(:read).and_raise(IOError)
|
142
|
+
expect { pipe.bind(options) }.to raise_error(RubySMB::Dcerpc::Error::InvalidPacket)
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'raises the expected exception when it is not a BindAck packet' do
|
146
|
+
response = RubySMB::Dcerpc::Bind.new
|
147
|
+
allow(RubySMB::Dcerpc::BindAck).to receive(:read).and_return(response)
|
148
|
+
expect { pipe.bind(options) }.to raise_error(RubySMB::Dcerpc::Error::BindError)
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'raises an exception when no result is returned' do
|
152
|
+
bind_ack_packet.p_result_list.n_results = 0
|
153
|
+
expect { pipe.bind(options) }.to raise_error(RubySMB::Dcerpc::Error::BindError)
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'raises an exception when result is not ACCEPTANCE' do
|
157
|
+
bind_ack_packet.p_result_list.p_results[0].result = RubySMB::Dcerpc::BindAck::USER_REJECTION
|
158
|
+
expect { pipe.bind(options) }.to raise_error(RubySMB::Dcerpc::Error::BindError)
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'returns the expected BindAck packet' do
|
162
|
+
expect(pipe.bind(options)).to eq(bind_ack_packet)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
describe '#request' do
|
167
|
+
let(:options) { { host: '1.2.3.4' } }
|
168
|
+
let(:opnum) { RubySMB::Dcerpc::Srvsvc::NET_SHARE_ENUM_ALL }
|
169
|
+
let(:req_packet) { RubySMB::Dcerpc::Request.new({ :opnum => opnum }, options) }
|
170
|
+
let(:ioctl_response) { RubySMB::SMB2::Packet::IoctlResponse.new }
|
171
|
+
let(:res_packet) { RubySMB::Dcerpc::Response.new }
|
172
|
+
|
173
|
+
before :example do
|
174
|
+
allow(RubySMB::Dcerpc::Request).to receive(:new).and_return(req_packet)
|
175
|
+
allow(pipe).to receive(:ioctl_send_recv).and_return(ioctl_response)
|
176
|
+
allow(RubySMB::Dcerpc::Response).to receive(:read).and_return(res_packet)
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'creates a Request packet' do
|
180
|
+
expect(RubySMB::Dcerpc::Request).to receive(:new).and_return(req_packet)
|
181
|
+
pipe.request(opnum, options)
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'calls #ioctl_send_recv' do
|
185
|
+
expect(pipe).to receive(:ioctl_send_recv).with(req_packet, options)
|
186
|
+
pipe.request(opnum, options)
|
187
|
+
end
|
188
|
+
|
189
|
+
it 'creates a DCERPC Response packet from the response' do
|
190
|
+
expect(RubySMB::Dcerpc::Response).to receive(:read).with(ioctl_response.output_data)
|
191
|
+
pipe.request(opnum, options)
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'raises the expected exception when an invalid packet is received' do
|
195
|
+
allow(RubySMB::Dcerpc::Response).to receive(:read).and_raise(IOError)
|
196
|
+
expect { pipe.request(opnum, options) }.to raise_error(RubySMB::Dcerpc::Error::InvalidPacket)
|
197
|
+
end
|
198
|
+
|
199
|
+
it 'raises the expected exception when it is not a BindAck packet' do
|
200
|
+
response = RubySMB::Dcerpc::Request.new
|
201
|
+
allow(RubySMB::Dcerpc::Response).to receive(:read).and_return(response)
|
202
|
+
expect { pipe.bind(options) }.to raise_error(RubySMB::Dcerpc::Error::InvalidPacket)
|
203
|
+
end
|
204
|
+
|
205
|
+
it 'returns the expected DCERPC Response' do
|
206
|
+
expect(pipe.request(opnum, options)).to eq(res_packet)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
describe '#ioctl_send_recv' do
|
211
|
+
let(:action) { RubySMB::Dcerpc::Request.new({ :opnum => RubySMB::Dcerpc::Srvsvc::NET_SHARE_ENUM_ALL }, host: '1.2.3.4') }
|
212
|
+
let(:options) { {} }
|
213
|
+
let(:ioctl_request) { RubySMB::SMB2::Packet::IoctlRequest.new(options) }
|
214
|
+
let(:ioctl_response) { RubySMB::SMB2::Packet::IoctlResponse.new }
|
215
|
+
|
216
|
+
before :example do
|
217
|
+
allow(client).to receive(:send_recv).and_return(ioctl_response.to_binary_s)
|
218
|
+
end
|
219
|
+
|
220
|
+
it 'calls #set_header_fields' do
|
221
|
+
expect(pipe).to receive(:set_header_fields).with(ioctl_request).and_call_original
|
222
|
+
pipe.ioctl_send_recv(action, options)
|
223
|
+
end
|
224
|
+
|
225
|
+
it 'calls Client #send_recv with the expected request' do
|
226
|
+
expect(client).to receive(:send_recv) do |req|
|
227
|
+
expect(req.ctl_code).to eq(0x0011C017)
|
228
|
+
expect(req.flags.is_fsctl).to eq(0x00000001)
|
229
|
+
expect(req.buffer).to eq(action.to_binary_s)
|
230
|
+
ioctl_response.to_binary_s
|
231
|
+
end
|
232
|
+
pipe.ioctl_send_recv(action, options)
|
233
|
+
end
|
234
|
+
|
235
|
+
it 'creates a IoctlResponse packet from the response' do
|
236
|
+
expect(RubySMB::SMB2::Packet::IoctlResponse).to receive(:read).with(ioctl_response.to_binary_s).and_call_original
|
237
|
+
pipe.ioctl_send_recv(action, options)
|
238
|
+
end
|
239
|
+
|
240
|
+
it 'raises the expected exception when it is not a IoctlResponse packet' do
|
241
|
+
response = RubySMB::SMB2::Packet::LogoffResponse.new
|
242
|
+
allow(RubySMB::SMB2::Packet::IoctlResponse).to receive(:read).and_return(response)
|
243
|
+
expect { pipe.ioctl_send_recv(action, options) }.to raise_error(RubySMB::Error::InvalidPacket)
|
244
|
+
end
|
245
|
+
|
246
|
+
it 'raises the expected exception when the status code is not STATUS_SUCCESS' do
|
247
|
+
ioctl_response_packet = RubySMB::SMB2::Packet::IoctlResponse.new
|
248
|
+
ioctl_response_packet.smb2_header.nt_status = WindowsError::NTStatus::STATUS_INVALID_HANDLE.value
|
249
|
+
allow(RubySMB::SMB2::Packet::IoctlResponse).to receive(:read).with(ioctl_response.to_binary_s).and_return(ioctl_response_packet)
|
250
|
+
expect { pipe.ioctl_send_recv(action, options) }.to raise_error(RubySMB::Error::UnexpectedStatusCode)
|
251
|
+
end
|
252
|
+
|
253
|
+
it 'returns the expected DCERPC Response' do
|
254
|
+
expect(pipe.ioctl_send_recv(action, options)).to eq(ioctl_response)
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_smb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Maloney
|
@@ -89,7 +89,7 @@ cert_chain:
|
|
89
89
|
G+Hmcg1v810agasPdoydE0RTVZgEOOMoQ07qu7JFXVWZ9ZQpHT7qJATWL/b2csFG
|
90
90
|
8mVuTXnyJOKRJA==
|
91
91
|
-----END CERTIFICATE-----
|
92
|
-
date: 2018-03-
|
92
|
+
date: 2018-03-06 00:00:00.000000000 Z
|
93
93
|
dependencies:
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: redcarpet
|
@@ -244,8 +244,12 @@ files:
|
|
244
244
|
- lib/ruby_smb/client/utils.rb
|
245
245
|
- lib/ruby_smb/dcerpc.rb
|
246
246
|
- lib/ruby_smb/dcerpc/bind.rb
|
247
|
-
- lib/ruby_smb/dcerpc/
|
247
|
+
- lib/ruby_smb/dcerpc/bind_ack.rb
|
248
|
+
- lib/ruby_smb/dcerpc/error.rb
|
248
249
|
- lib/ruby_smb/dcerpc/ndr.rb
|
250
|
+
- lib/ruby_smb/dcerpc/p_syntax_id_t.rb
|
251
|
+
- lib/ruby_smb/dcerpc/pdu_header.rb
|
252
|
+
- lib/ruby_smb/dcerpc/ptypes.rb
|
249
253
|
- lib/ruby_smb/dcerpc/request.rb
|
250
254
|
- lib/ruby_smb/dcerpc/response.rb
|
251
255
|
- lib/ruby_smb/dcerpc/srvsvc.rb
|
@@ -310,12 +314,12 @@ files:
|
|
310
314
|
- lib/ruby_smb/smb1/bit_field/smb_ext_file_attributes.rb
|
311
315
|
- lib/ruby_smb/smb1/bit_field/smb_file_attributes.rb
|
312
316
|
- lib/ruby_smb/smb1/bit_field/smb_nmpipe_status.rb
|
313
|
-
- lib/ruby_smb/smb1/bit_field/trans2_flags.rb
|
314
317
|
- lib/ruby_smb/smb1/bit_field/trans_flags.rb
|
315
318
|
- lib/ruby_smb/smb1/bit_field/tree_connect_flags.rb
|
316
319
|
- lib/ruby_smb/smb1/commands.rb
|
317
320
|
- lib/ruby_smb/smb1/create_actions.rb
|
318
321
|
- lib/ruby_smb/smb1/data_block.rb
|
322
|
+
- lib/ruby_smb/smb1/dcerpc.rb
|
319
323
|
- lib/ruby_smb/smb1/dialect.rb
|
320
324
|
- lib/ruby_smb/smb1/file.rb
|
321
325
|
- lib/ruby_smb/smb1/oplock_levels.rb
|
@@ -351,6 +355,8 @@ files:
|
|
351
355
|
- lib/ruby_smb/smb1/packet/trans/request.rb
|
352
356
|
- lib/ruby_smb/smb1/packet/trans/response.rb
|
353
357
|
- lib/ruby_smb/smb1/packet/trans/subcommands.rb
|
358
|
+
- lib/ruby_smb/smb1/packet/trans/transact_nmpipe_request.rb
|
359
|
+
- lib/ruby_smb/smb1/packet/trans/transact_nmpipe_response.rb
|
354
360
|
- lib/ruby_smb/smb1/packet/trans2.rb
|
355
361
|
- lib/ruby_smb/smb1/packet/trans2/data_block.rb
|
356
362
|
- lib/ruby_smb/smb1/packet/trans2/find_first2_request.rb
|
@@ -391,6 +397,7 @@ files:
|
|
391
397
|
- lib/ruby_smb/smb2/bit_field/smb2_security_mode_single.rb
|
392
398
|
- lib/ruby_smb/smb2/commands.rb
|
393
399
|
- lib/ruby_smb/smb2/create_context.rb
|
400
|
+
- lib/ruby_smb/smb2/dcerpc.rb
|
394
401
|
- lib/ruby_smb/smb2/file.rb
|
395
402
|
- lib/ruby_smb/smb2/info_type.rb
|
396
403
|
- lib/ruby_smb/smb2/packet.rb
|
@@ -427,11 +434,13 @@ files:
|
|
427
434
|
- lib/ruby_smb/version.rb
|
428
435
|
- ruby_smb.gemspec
|
429
436
|
- spec/lib/ruby_smb/client_spec.rb
|
437
|
+
- spec/lib/ruby_smb/dcerpc/bind_ack_spec.rb
|
430
438
|
- spec/lib/ruby_smb/dcerpc/bind_spec.rb
|
431
|
-
- spec/lib/ruby_smb/dcerpc/
|
439
|
+
- spec/lib/ruby_smb/dcerpc/p_syntax_id_t_spec.rb
|
440
|
+
- spec/lib/ruby_smb/dcerpc/pdu_header_spec.rb
|
432
441
|
- spec/lib/ruby_smb/dcerpc/request_spec.rb
|
433
442
|
- spec/lib/ruby_smb/dcerpc/response_spec.rb
|
434
|
-
- spec/lib/ruby_smb/dcerpc/
|
443
|
+
- spec/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all_spec.rb
|
435
444
|
- spec/lib/ruby_smb/dcerpc/uuid_spec.rb
|
436
445
|
- spec/lib/ruby_smb/dispatcher/base_spec.rb
|
437
446
|
- spec/lib/ruby_smb/dispatcher/socket_spec.rb
|
@@ -479,7 +488,6 @@ files:
|
|
479
488
|
- spec/lib/ruby_smb/smb1/bit_field/smb_ext_file_attributes_spec.rb
|
480
489
|
- spec/lib/ruby_smb/smb1/bit_field/smb_file_attributes_spec.rb
|
481
490
|
- spec/lib/ruby_smb/smb1/bit_field/smb_nmpipe_status_spec.rb
|
482
|
-
- spec/lib/ruby_smb/smb1/bit_field/trans2_flags_spec.rb
|
483
491
|
- spec/lib/ruby_smb/smb1/bit_field/trans_flags_spec.rb
|
484
492
|
- spec/lib/ruby_smb/smb1/bit_field/tree_connect_flags_spec.rb
|
485
493
|
- spec/lib/ruby_smb/smb1/data_block_spec.rb
|
@@ -507,10 +515,13 @@ files:
|
|
507
515
|
- spec/lib/ruby_smb/smb1/packet/session_setup_legacy_response_spec.rb
|
508
516
|
- spec/lib/ruby_smb/smb1/packet/session_setup_request_spec.rb
|
509
517
|
- spec/lib/ruby_smb/smb1/packet/session_setup_response_spec.rb
|
518
|
+
- spec/lib/ruby_smb/smb1/packet/trans/data_block_spec.rb
|
510
519
|
- spec/lib/ruby_smb/smb1/packet/trans/peek_nmpipe_request_spec.rb
|
511
520
|
- spec/lib/ruby_smb/smb1/packet/trans/peek_nmpipe_response_spec.rb
|
512
521
|
- spec/lib/ruby_smb/smb1/packet/trans/request_spec.rb
|
513
522
|
- spec/lib/ruby_smb/smb1/packet/trans/response_spec.rb
|
523
|
+
- spec/lib/ruby_smb/smb1/packet/trans/transact_nmpipe_request_spec.rb
|
524
|
+
- spec/lib/ruby_smb/smb1/packet/trans/transact_nmpipe_response_spec.rb
|
514
525
|
- spec/lib/ruby_smb/smb1/packet/trans2/find_first2_request_spec.rb
|
515
526
|
- spec/lib/ruby_smb/smb1/packet/trans2/find_first2_response_spec.rb
|
516
527
|
- spec/lib/ruby_smb/smb1/packet/trans2/find_information_level/find_file_full_directory_info_spec.rb
|
@@ -601,11 +612,13 @@ specification_version: 4
|
|
601
612
|
summary: A pure Ruby implementation of the SMB Protocol Family
|
602
613
|
test_files:
|
603
614
|
- spec/lib/ruby_smb/client_spec.rb
|
615
|
+
- spec/lib/ruby_smb/dcerpc/bind_ack_spec.rb
|
604
616
|
- spec/lib/ruby_smb/dcerpc/bind_spec.rb
|
605
|
-
- spec/lib/ruby_smb/dcerpc/
|
617
|
+
- spec/lib/ruby_smb/dcerpc/p_syntax_id_t_spec.rb
|
618
|
+
- spec/lib/ruby_smb/dcerpc/pdu_header_spec.rb
|
606
619
|
- spec/lib/ruby_smb/dcerpc/request_spec.rb
|
607
620
|
- spec/lib/ruby_smb/dcerpc/response_spec.rb
|
608
|
-
- spec/lib/ruby_smb/dcerpc/
|
621
|
+
- spec/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all_spec.rb
|
609
622
|
- spec/lib/ruby_smb/dcerpc/uuid_spec.rb
|
610
623
|
- spec/lib/ruby_smb/dispatcher/base_spec.rb
|
611
624
|
- spec/lib/ruby_smb/dispatcher/socket_spec.rb
|
@@ -653,7 +666,6 @@ test_files:
|
|
653
666
|
- spec/lib/ruby_smb/smb1/bit_field/smb_ext_file_attributes_spec.rb
|
654
667
|
- spec/lib/ruby_smb/smb1/bit_field/smb_file_attributes_spec.rb
|
655
668
|
- spec/lib/ruby_smb/smb1/bit_field/smb_nmpipe_status_spec.rb
|
656
|
-
- spec/lib/ruby_smb/smb1/bit_field/trans2_flags_spec.rb
|
657
669
|
- spec/lib/ruby_smb/smb1/bit_field/trans_flags_spec.rb
|
658
670
|
- spec/lib/ruby_smb/smb1/bit_field/tree_connect_flags_spec.rb
|
659
671
|
- spec/lib/ruby_smb/smb1/data_block_spec.rb
|
@@ -681,10 +693,13 @@ test_files:
|
|
681
693
|
- spec/lib/ruby_smb/smb1/packet/session_setup_legacy_response_spec.rb
|
682
694
|
- spec/lib/ruby_smb/smb1/packet/session_setup_request_spec.rb
|
683
695
|
- spec/lib/ruby_smb/smb1/packet/session_setup_response_spec.rb
|
696
|
+
- spec/lib/ruby_smb/smb1/packet/trans/data_block_spec.rb
|
684
697
|
- spec/lib/ruby_smb/smb1/packet/trans/peek_nmpipe_request_spec.rb
|
685
698
|
- spec/lib/ruby_smb/smb1/packet/trans/peek_nmpipe_response_spec.rb
|
686
699
|
- spec/lib/ruby_smb/smb1/packet/trans/request_spec.rb
|
687
700
|
- spec/lib/ruby_smb/smb1/packet/trans/response_spec.rb
|
701
|
+
- spec/lib/ruby_smb/smb1/packet/trans/transact_nmpipe_request_spec.rb
|
702
|
+
- spec/lib/ruby_smb/smb1/packet/trans/transact_nmpipe_response_spec.rb
|
688
703
|
- spec/lib/ruby_smb/smb1/packet/trans2/find_first2_request_spec.rb
|
689
704
|
- spec/lib/ruby_smb/smb1/packet/trans2/find_first2_response_spec.rb
|
690
705
|
- spec/lib/ruby_smb/smb1/packet/trans2/find_information_level/find_file_full_directory_info_spec.rb
|
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,60 +0,0 @@
|
|
1
|
-
module RubySMB
|
2
|
-
module Dcerpc
|
3
|
-
class Handle
|
4
|
-
|
5
|
-
attr_accessor :pipe
|
6
|
-
attr_accessor :last_msg
|
7
|
-
attr_accessor :response
|
8
|
-
|
9
|
-
PTYPES = [
|
10
|
-
RubySMB::Dcerpc::Request,
|
11
|
-
nil,
|
12
|
-
RubySMB::Dcerpc::Response
|
13
|
-
]
|
14
|
-
|
15
|
-
# @param [RubySMB::SMB2::File] named_pipe
|
16
|
-
# @return [RubySMB::Dcerpc::Handle]
|
17
|
-
def initialize(named_pipe)
|
18
|
-
@pipe = named_pipe
|
19
|
-
end
|
20
|
-
|
21
|
-
# @param [Class] endpoint
|
22
|
-
def bind(options={})
|
23
|
-
ioctl_request(RubySMB::Dcerpc::Bind.new(options))
|
24
|
-
end
|
25
|
-
|
26
|
-
# @param [Hash] options
|
27
|
-
def request(opnum:, stub:, options:{})
|
28
|
-
ioctl_request(
|
29
|
-
RubySMB::Dcerpc::Request.new(
|
30
|
-
opnum: opnum,
|
31
|
-
stub: stub.new(options).to_binary_s
|
32
|
-
)
|
33
|
-
)
|
34
|
-
end
|
35
|
-
|
36
|
-
# @param [BinData::Record] action
|
37
|
-
# @param [Hash] options
|
38
|
-
def ioctl_request(action, options={})
|
39
|
-
request = @pipe.set_header_fields(RubySMB::SMB2::Packet::IoctlRequest.new(options))
|
40
|
-
request.ctl_code = 0x0011C017
|
41
|
-
request.flags.is_fsctl = 0x00000001
|
42
|
-
request.buffer = action.to_binary_s
|
43
|
-
@last_msg = @pipe.tree.client.send_recv(request)
|
44
|
-
handle_msg(RubySMB::SMB2::Packet::IoctlResponse.read(@last_msg))
|
45
|
-
end
|
46
|
-
|
47
|
-
# @param [BinData::Record] msg
|
48
|
-
def handle_msg(msg)
|
49
|
-
data = msg.buffer.to_binary_s
|
50
|
-
headz = RubySMB::Dcerpc::PduHeader.read(data)
|
51
|
-
pdu = PTYPES[headz.ptype]
|
52
|
-
if pdu
|
53
|
-
dcerpc_response_stub = pdu.read(msg.output_data).stub
|
54
|
-
@response = dcerpc_response_stub.to_binary_s
|
55
|
-
end
|
56
|
-
data
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module RubySMB
|
2
|
-
module SMB1
|
3
|
-
module BitField
|
4
|
-
# The Flags bit-field for a Trans2 Request Packet
|
5
|
-
# [2.2.4.46.1 Request](https://msdn.microsoft.com/en-us/library/ee442192.aspx)
|
6
|
-
class Trans2Flags < BinData::Record
|
7
|
-
endian :little
|
8
|
-
bit6 :reserved, label: 'Reserved Space', initial_value: 0
|
9
|
-
bit1 :no_response, label: 'Do Not reply', initial_value: 0
|
10
|
-
bit1 :disconnect, label: 'Disconnect Tree', initial_value: 0
|
11
|
-
bit8 :reserved2, label: 'Reserved Space', initial_value: 0
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe RubySMB::Dcerpc::Handle do
|
4
|
-
|
5
|
-
describe 'A dce/rpc handle' do
|
6
|
-
let(:output){double('Output')}
|
7
|
-
let(:tree){double('Tree')}
|
8
|
-
let(:response){double('Response')}
|
9
|
-
let(:file){double('File')}
|
10
|
-
let(:handle){described_class.new(file)}
|
11
|
-
let(:endpoint){ RubySMB::Dcerpc::Srvsvc }
|
12
|
-
let(:ioctl_response){ double('IoctlResponse') }
|
13
|
-
|
14
|
-
it 'should #bind' do
|
15
|
-
expect(handle).to receive(:ioctl_request)#.with([response_socket], nil, nil, timeout)
|
16
|
-
handle.bind(endpoint: endpoint)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'should #request' do
|
20
|
-
expect(handle).to receive(:ioctl_request)#.with([response_socket], nil, nil, timeout)
|
21
|
-
handle.request(opnum: 15, stub: RubySMB::Dcerpc::Srvsvc::NetShareEnumAll, options: {host: '127.0.0.1'})
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should #handle_msg' do
|
25
|
-
expect(ioctl_response).to receive(:buffer).and_return RubySMB::Dcerpc::Response.new.stub
|
26
|
-
expect(RubySMB::Dcerpc::PduHeader).to receive(:read).and_return(RubySMB::Dcerpc::PduHeader.new(ptype: 1))
|
27
|
-
expect(handle.handle_msg(ioctl_response)).to eq(RubySMB::Dcerpc::Response.new.stub.to_binary_s)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|