ruby_smb 3.1.5 → 3.2.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/.github/workflows/verify.yml +27 -4
- data/README.md +1 -2
- data/lib/ruby_smb/client/authentication.rb +4 -30
- data/lib/ruby_smb/dcerpc/client.rb +6 -261
- data/lib/ruby_smb/dcerpc/dfsnm/netr_dfs_add_std_root_request.rb +24 -0
- data/lib/ruby_smb/dcerpc/dfsnm/netr_dfs_add_std_root_response.rb +21 -0
- data/lib/ruby_smb/dcerpc/dfsnm/netr_dfs_remove_std_root_request.rb +23 -0
- data/lib/ruby_smb/dcerpc/dfsnm/netr_dfs_remove_std_root_response.rb +21 -0
- data/lib/ruby_smb/dcerpc/dfsnm.rb +84 -0
- data/lib/ruby_smb/dcerpc/error.rb +21 -0
- data/lib/ruby_smb/dcerpc/icpr/cert_server_request_request.rb +27 -0
- data/lib/ruby_smb/dcerpc/icpr/cert_server_request_response.rb +28 -0
- data/lib/ruby_smb/dcerpc/icpr.rb +84 -0
- data/lib/ruby_smb/dcerpc/ndr.rb +38 -2
- data/lib/ruby_smb/dcerpc/request.rb +10 -1
- data/lib/ruby_smb/dcerpc.rb +246 -12
- data/lib/ruby_smb/error.rb +25 -11
- data/lib/ruby_smb/peer_info.rb +39 -0
- data/lib/ruby_smb/signing.rb +2 -0
- data/lib/ruby_smb/smb1/pipe.rb +23 -1
- data/lib/ruby_smb/smb2/packet/tree_connect_response.rb +5 -1
- data/lib/ruby_smb/smb2/pipe.rb +23 -0
- data/lib/ruby_smb/version.rb +1 -1
- data/spec/lib/ruby_smb/dcerpc/dfsnm/netr_dfs_add_std_root_request_spec.rb +57 -0
- data/spec/lib/ruby_smb/dcerpc/dfsnm/netr_dfs_add_std_root_response_spec.rb +34 -0
- data/spec/lib/ruby_smb/dcerpc/dfsnm/netr_dfs_remove_std_root_request_spec.rb +49 -0
- data/spec/lib/ruby_smb/dcerpc/dfsnm/netr_dfs_remove_std_root_response_spec.rb +34 -0
- data/spec/lib/ruby_smb/dcerpc/icpr/cert_server_request_request_spec.rb +64 -0
- data/spec/lib/ruby_smb/dcerpc/icpr/cert_server_request_response_spec.rb +71 -0
- data/spec/lib/ruby_smb/dcerpc/icpr/cert_trans_blob_spec.rb +33 -0
- data/spec/lib/ruby_smb/dcerpc_spec.rb +2 -1
- data/spec/spec_helper.rb +6 -8
- data/spec/support/openssl.conf +14 -0
- data.tar.gz.sig +0 -0
- metadata +27 -2
- metadata.gz.sig +0 -0
data/lib/ruby_smb/smb2/pipe.rb
CHANGED
@@ -25,10 +25,20 @@ module RubySMB
|
|
25
25
|
extend RubySMB::Dcerpc::Samr
|
26
26
|
when 'wkssvc', '\\wkssvc'
|
27
27
|
extend RubySMB::Dcerpc::Wkssvc
|
28
|
+
when 'netdfs', '\\netdfs'
|
29
|
+
extend RubySMB::Dcerpc::Dfsnm
|
30
|
+
when 'cert', '\\cert'
|
31
|
+
extend RubySMB::Dcerpc::Icpr
|
28
32
|
end
|
29
33
|
super(tree: tree, response: response, name: name)
|
30
34
|
end
|
31
35
|
|
36
|
+
def bind(options={})
|
37
|
+
@size = 1024
|
38
|
+
@ntlm_client = @tree.client.ntlm_client
|
39
|
+
super
|
40
|
+
end
|
41
|
+
|
32
42
|
# Performs a peek operation on the named pipe
|
33
43
|
#
|
34
44
|
# @param peek_size [Integer] Amount of data to peek
|
@@ -89,6 +99,11 @@ module RubySMB
|
|
89
99
|
options.merge!(endpoint: stub_packet.class.name.split('::').at(-2))
|
90
100
|
dcerpc_request = RubySMB::Dcerpc::Request.new({ opnum: stub_packet.opnum }, options)
|
91
101
|
dcerpc_request.stub.read(stub_packet.to_binary_s)
|
102
|
+
if options[:auth_level] &&
|
103
|
+
[RPC_C_AUTHN_LEVEL_PKT_INTEGRITY, RPC_C_AUTHN_LEVEL_PKT_PRIVACY].include?(options[:auth_level])
|
104
|
+
set_integrity_privacy(dcerpc_request, auth_level: options[:auth_level], auth_type: options[:auth_type])
|
105
|
+
end
|
106
|
+
|
92
107
|
ioctl_send_recv(dcerpc_request, options)
|
93
108
|
end
|
94
109
|
|
@@ -120,6 +135,10 @@ module RubySMB
|
|
120
135
|
unless dcerpc_response.pdu_header.pfc_flags.first_frag == 1
|
121
136
|
raise RubySMB::Dcerpc::Error::InvalidPacket, "Not the first fragment"
|
122
137
|
end
|
138
|
+
if options[:auth_level] &&
|
139
|
+
[RPC_C_AUTHN_LEVEL_PKT_INTEGRITY, RPC_C_AUTHN_LEVEL_PKT_PRIVACY].include?(options[:auth_level])
|
140
|
+
handle_integrity_privacy(dcerpc_response, auth_level: options[:auth_level], auth_type: options[:auth_type])
|
141
|
+
end
|
123
142
|
stub_data = dcerpc_response.stub.to_s
|
124
143
|
|
125
144
|
loop do
|
@@ -131,6 +150,10 @@ module RubySMB
|
|
131
150
|
stub_data
|
132
151
|
else
|
133
152
|
dcerpc_response = dcerpc_response_from_raw_response(raw_data)
|
153
|
+
if options[:auth_level] &&
|
154
|
+
[RPC_C_AUTHN_LEVEL_PKT_INTEGRITY, RPC_C_AUTHN_LEVEL_PKT_PRIVACY].include?(options[:auth_level])
|
155
|
+
handle_integrity_privacy(dcerpc_response, auth_level: options[:auth_level], auth_type: options[:auth_type])
|
156
|
+
end
|
134
157
|
dcerpc_response.stub.to_s
|
135
158
|
end
|
136
159
|
end
|
data/lib/ruby_smb/version.rb
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Dfsnm::NetrDfsAddStdRootRequest do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :server_name }
|
5
|
+
it { is_expected.to respond_to :root_share }
|
6
|
+
it { is_expected.to respond_to :comment }
|
7
|
+
it { is_expected.to respond_to :api_flags }
|
8
|
+
it { is_expected.to respond_to :opnum }
|
9
|
+
|
10
|
+
it 'is little endian' do
|
11
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
12
|
+
end
|
13
|
+
it 'is a BinData::Record' do
|
14
|
+
expect(packet).to be_a(BinData::Record)
|
15
|
+
end
|
16
|
+
describe '#server_name' do
|
17
|
+
it 'is a NdrConfVarWideStringz structure' do
|
18
|
+
expect(packet.server_name).to be_a RubySMB::Dcerpc::Ndr::NdrConfVarWideStringz
|
19
|
+
end
|
20
|
+
end
|
21
|
+
describe '#root_share' do
|
22
|
+
it 'is a NdrConfVarWideStringz structure' do
|
23
|
+
expect(packet.root_share).to be_a RubySMB::Dcerpc::Ndr::NdrConfVarWideStringz
|
24
|
+
end
|
25
|
+
end
|
26
|
+
describe '#comment' do
|
27
|
+
it 'is a NdrConfVarWideStringz structure' do
|
28
|
+
expect(packet.comment).to be_a RubySMB::Dcerpc::Ndr::NdrConfVarWideStringz
|
29
|
+
end
|
30
|
+
end
|
31
|
+
describe '#api_flags' do
|
32
|
+
it 'is a NdrUint32 structure' do
|
33
|
+
expect(packet.api_flags).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
34
|
+
end
|
35
|
+
end
|
36
|
+
describe '#initialize_instance' do
|
37
|
+
it 'sets #opnum to NETR_DFS_ADD_STD_ROOT constant' do
|
38
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Dfsnm::NETR_DFS_ADD_STD_ROOT)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
it 'reads itself' do
|
42
|
+
new_packet = described_class.new({
|
43
|
+
server_name: 'serverName',
|
44
|
+
root_share: 'rootShare',
|
45
|
+
comment: 'comment'
|
46
|
+
})
|
47
|
+
expected_output = {
|
48
|
+
server_name: 'serverName'.encode('utf-16le'),
|
49
|
+
root_share: 'rootShare'.encode('utf-16le'),
|
50
|
+
comment: 'comment'.encode('utf-16le'),
|
51
|
+
api_flags: 0
|
52
|
+
}
|
53
|
+
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Dfsnm::NetrDfsAddStdRootResponse do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :error_status }
|
5
|
+
it { is_expected.to respond_to :opnum }
|
6
|
+
|
7
|
+
it 'is little endian' do
|
8
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
9
|
+
end
|
10
|
+
it 'is a BinData::Record' do
|
11
|
+
expect(packet).to be_a(BinData::Record)
|
12
|
+
end
|
13
|
+
describe '#error_status' do
|
14
|
+
it 'is a NdrUint32 structure' do
|
15
|
+
expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
16
|
+
end
|
17
|
+
end
|
18
|
+
describe '#initialize_instance' do
|
19
|
+
it 'sets #opnum to NETR_DFS_ADD_STD_ROOT constant' do
|
20
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Dfsnm::NETR_DFS_ADD_STD_ROOT)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
it 'reads itself' do
|
24
|
+
new_packet = described_class.new({
|
25
|
+
error_status: 0
|
26
|
+
})
|
27
|
+
expected_output = {
|
28
|
+
error_status: 0
|
29
|
+
}
|
30
|
+
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Dfsnm::NetrDfsRemoveStdRootRequest do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :server_name }
|
5
|
+
it { is_expected.to respond_to :root_share }
|
6
|
+
it { is_expected.to respond_to :api_flags }
|
7
|
+
it { is_expected.to respond_to :opnum }
|
8
|
+
|
9
|
+
it 'is little endian' do
|
10
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
11
|
+
end
|
12
|
+
it 'is a BinData::Record' do
|
13
|
+
expect(packet).to be_a(BinData::Record)
|
14
|
+
end
|
15
|
+
describe '#server_name' do
|
16
|
+
it 'is a NdrConfVarWideStringz structure' do
|
17
|
+
expect(packet.server_name).to be_a RubySMB::Dcerpc::Ndr::NdrConfVarWideStringz
|
18
|
+
end
|
19
|
+
end
|
20
|
+
describe '#root_share' do
|
21
|
+
it 'is a NdrConfVarWideStringz structure' do
|
22
|
+
expect(packet.root_share).to be_a RubySMB::Dcerpc::Ndr::NdrConfVarWideStringz
|
23
|
+
end
|
24
|
+
end
|
25
|
+
describe '#api_flags' do
|
26
|
+
it 'is a NdrUint32 structure' do
|
27
|
+
expect(packet.api_flags).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
28
|
+
end
|
29
|
+
end
|
30
|
+
describe '#initialize_instance' do
|
31
|
+
it 'sets #opnum to NETR_DFS_REMOVE_STD_ROOT constant' do
|
32
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Dfsnm::NETR_DFS_REMOVE_STD_ROOT)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
it 'reads itself' do
|
36
|
+
new_packet = described_class.new({
|
37
|
+
server_name: 'serverName',
|
38
|
+
root_share: 'rootShare',
|
39
|
+
})
|
40
|
+
expected_output = {
|
41
|
+
server_name: 'serverName'.encode('utf-16le'),
|
42
|
+
root_share: 'rootShare'.encode('utf-16le'),
|
43
|
+
api_flags: 0
|
44
|
+
}
|
45
|
+
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Dfsnm::NetrDfsRemoveStdRootResponse do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :error_status }
|
5
|
+
it { is_expected.to respond_to :opnum }
|
6
|
+
|
7
|
+
it 'is little endian' do
|
8
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
9
|
+
end
|
10
|
+
it 'is a BinData::Record' do
|
11
|
+
expect(packet).to be_a(BinData::Record)
|
12
|
+
end
|
13
|
+
describe '#error_status' do
|
14
|
+
it 'is a NdrUint32 structure' do
|
15
|
+
expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
16
|
+
end
|
17
|
+
end
|
18
|
+
describe '#initialize_instance' do
|
19
|
+
it 'sets #opnum to NETR_DFS_REMOVE_STD_ROOT constant' do
|
20
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Dfsnm::NETR_DFS_REMOVE_STD_ROOT)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
it 'reads itself' do
|
24
|
+
new_packet = described_class.new({
|
25
|
+
error_status: 0
|
26
|
+
})
|
27
|
+
expected_output = {
|
28
|
+
error_status: 0
|
29
|
+
}
|
30
|
+
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
@@ -0,0 +1,64 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Icpr::CertServerRequestRequest do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :dw_flags }
|
5
|
+
it { is_expected.to respond_to :pwsz_authority }
|
6
|
+
it { is_expected.to respond_to :pdw_request_id }
|
7
|
+
it { is_expected.to respond_to :pctb_attribs }
|
8
|
+
it { is_expected.to respond_to :pctb_request }
|
9
|
+
it { is_expected.to respond_to :opnum }
|
10
|
+
|
11
|
+
it 'is little endian' do
|
12
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
13
|
+
end
|
14
|
+
it 'is a BinData::Record' do
|
15
|
+
expect(packet).to be_a(BinData::Record)
|
16
|
+
end
|
17
|
+
describe '#dw_flags' do
|
18
|
+
it 'is a NdrUint32 structure' do
|
19
|
+
expect(packet.dw_flags).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
20
|
+
end
|
21
|
+
end
|
22
|
+
describe '#pwsz_authority' do
|
23
|
+
it 'is a NdrWideStringzPtr structure' do
|
24
|
+
expect(packet.pwsz_authority).to be_a RubySMB::Dcerpc::Ndr::NdrWideStringzPtr
|
25
|
+
end
|
26
|
+
end
|
27
|
+
describe '#pdw_request_id' do
|
28
|
+
it 'is a NdrUint32 structure' do
|
29
|
+
expect(packet.pdw_request_id).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
30
|
+
end
|
31
|
+
end
|
32
|
+
describe '#pctb_attribs' do
|
33
|
+
it 'is a CertTransBlob structure' do
|
34
|
+
expect(packet.pctb_attribs).to be_a RubySMB::Dcerpc::Icpr::CertTransBlob
|
35
|
+
end
|
36
|
+
end
|
37
|
+
describe '#pctb_request' do
|
38
|
+
it 'is a CertTransBlob structure' do
|
39
|
+
expect(packet.pctb_request).to be_a RubySMB::Dcerpc::Icpr::CertTransBlob
|
40
|
+
end
|
41
|
+
end
|
42
|
+
describe '#initialize_instance' do
|
43
|
+
it 'sets #opnum to CERT_SERVER_REQUEST constant' do
|
44
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Icpr::CERT_SERVER_REQUEST)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
it 'reads itself' do
|
48
|
+
new_packet = described_class.new({
|
49
|
+
dw_flags: 0,
|
50
|
+
pwsz_authority: 'DC-CA',
|
51
|
+
pdw_request_id: 1,
|
52
|
+
pctb_attribs: { pb: 'ATTRIBUTES'.bytes },
|
53
|
+
pctb_request: { pb: 'REQUEST'.bytes }
|
54
|
+
})
|
55
|
+
expected_output = {
|
56
|
+
dw_flags: 0,
|
57
|
+
pwsz_authority: 'DC-CA'.encode('utf-16le'),
|
58
|
+
pdw_request_id: 1,
|
59
|
+
pctb_attribs: { cb: 10, pb: 'ATTRIBUTES'.bytes },
|
60
|
+
pctb_request: { cb: 7, pb: 'REQUEST'.bytes }
|
61
|
+
}
|
62
|
+
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Icpr::CertServerRequestResponse do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :pdw_request_id }
|
5
|
+
it { is_expected.to respond_to :pdw_disposition }
|
6
|
+
it { is_expected.to respond_to :pctb_cert }
|
7
|
+
it { is_expected.to respond_to :pctb_encoded_cert }
|
8
|
+
it { is_expected.to respond_to :pctb_disposition_message }
|
9
|
+
it { is_expected.to respond_to :error_status }
|
10
|
+
|
11
|
+
it 'is little endian' do
|
12
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
13
|
+
end
|
14
|
+
it 'is a BinData::Record' do
|
15
|
+
expect(packet).to be_a(BinData::Record)
|
16
|
+
end
|
17
|
+
describe '#pdw_request_id' do
|
18
|
+
it 'is a NdrUint32 structure' do
|
19
|
+
expect(packet.pdw_request_id).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
20
|
+
end
|
21
|
+
end
|
22
|
+
describe '#pdw_disposition' do
|
23
|
+
it 'is a NdrUint32 structure' do
|
24
|
+
expect(packet.pdw_disposition).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
25
|
+
end
|
26
|
+
end
|
27
|
+
describe '#pctb_cert' do
|
28
|
+
it 'is a CertTransBlob structure' do
|
29
|
+
expect(packet.pctb_cert).to be_a RubySMB::Dcerpc::Icpr::CertTransBlob
|
30
|
+
end
|
31
|
+
end
|
32
|
+
describe '#pctb_encoded_cert' do
|
33
|
+
it 'is a CertTransBlob structure' do
|
34
|
+
expect(packet.pctb_encoded_cert).to be_a RubySMB::Dcerpc::Icpr::CertTransBlob
|
35
|
+
end
|
36
|
+
end
|
37
|
+
describe '#pctb_disposition_message' do
|
38
|
+
it 'is a CertTransBlob structure' do
|
39
|
+
expect(packet.pctb_disposition_message).to be_a RubySMB::Dcerpc::Icpr::CertTransBlob
|
40
|
+
end
|
41
|
+
end
|
42
|
+
describe '#error_status' do
|
43
|
+
it 'is a NdrUint32 structure' do
|
44
|
+
expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
45
|
+
end
|
46
|
+
end
|
47
|
+
describe '#initialize_instance' do
|
48
|
+
it 'sets #opnum to CERT_SERVER_REQUEST constant' do
|
49
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Icpr::CERT_SERVER_REQUEST)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
it 'reads itself' do
|
53
|
+
new_packet = described_class.new({
|
54
|
+
pdw_request_id: 1,
|
55
|
+
pdw_disposition: 0,
|
56
|
+
pctb_cert: { pb: 'CERT'.bytes },
|
57
|
+
pctb_encoded_cert: { pb: 'ENCODED_CERT'.bytes },
|
58
|
+
pctb_disposition_message: { pb: 'DISPOSITION_MESSAGE'.bytes },
|
59
|
+
error_status: 0
|
60
|
+
})
|
61
|
+
expected_output = {
|
62
|
+
pdw_request_id: 1,
|
63
|
+
pdw_disposition: 0,
|
64
|
+
pctb_cert: { cb: 4, pb: 'CERT'.bytes },
|
65
|
+
pctb_encoded_cert: { cb: 12, pb: 'ENCODED_CERT'.bytes },
|
66
|
+
pctb_disposition_message: { cb: 19, pb: 'DISPOSITION_MESSAGE'.bytes },
|
67
|
+
error_status: 0
|
68
|
+
}
|
69
|
+
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Icpr::CertTransBlob do
|
2
|
+
subject(:struct) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :cb }
|
5
|
+
it { is_expected.to respond_to :pb }
|
6
|
+
|
7
|
+
it 'is little endian' do
|
8
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
9
|
+
end
|
10
|
+
it 'is a BinData::Record' do
|
11
|
+
expect(struct).to be_a(BinData::Record)
|
12
|
+
end
|
13
|
+
describe '#cb' do
|
14
|
+
it 'is a NdrUint32 structure' do
|
15
|
+
expect(struct.cb).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
16
|
+
end
|
17
|
+
end
|
18
|
+
describe '#pb' do
|
19
|
+
it 'is a NdrByteConfArrayPtr structure' do
|
20
|
+
expect(struct.pb).to be_a RubySMB::Dcerpc::Ndr::NdrByteConfArrayPtr
|
21
|
+
end
|
22
|
+
end
|
23
|
+
describe '#buffer' do
|
24
|
+
it 'returns a string' do
|
25
|
+
expect(struct.buffer).to be_a String
|
26
|
+
end
|
27
|
+
end
|
28
|
+
it 'reads itself' do
|
29
|
+
new_struct = described_class.new({ pb: 'BUFFER' })
|
30
|
+
expected_output = { cb: 6, pb: 'BUFFER'.bytes }
|
31
|
+
expect(struct.read(new_struct.to_binary_s)).to eq(expected_output)
|
32
|
+
end
|
33
|
+
end
|
@@ -23,6 +23,7 @@ RSpec.describe RubySMB::Dcerpc do
|
|
23
23
|
allow(RubySMB::Dcerpc::BindAck).to receive(:read).and_return(bind_ack_packet)
|
24
24
|
allow(tree).to receive(:client).and_return(client)
|
25
25
|
allow(client).to receive(:max_buffer_size=)
|
26
|
+
allow(client).to receive(:ntlm_client)
|
26
27
|
end
|
27
28
|
|
28
29
|
it 'creates a Bind packet' do
|
@@ -49,7 +50,7 @@ RSpec.describe RubySMB::Dcerpc do
|
|
49
50
|
|
50
51
|
it 'raises the expected exception when an invalid packet is received' do
|
51
52
|
allow(RubySMB::Dcerpc::BindAck).to receive(:read).and_raise(IOError)
|
52
|
-
expect { pipe.bind(options) }.to raise_error(RubySMB::Dcerpc::Error::
|
53
|
+
expect { pipe.bind(options) }.to raise_error(RubySMB::Dcerpc::Error::BindError)
|
53
54
|
end
|
54
55
|
|
55
56
|
it 'raises the expected exception when it is not a BindAck packet' do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,18 +1,16 @@
|
|
1
|
+
# Enable legacy providers
|
2
|
+
ENV['OPENSSL_CONF'] = File.expand_path(
|
3
|
+
File.join(File.dirname(__FILE__), 'support', 'openssl.conf')
|
4
|
+
)
|
5
|
+
|
1
6
|
require 'simplecov'
|
2
7
|
|
3
8
|
SimpleCov.start unless SimpleCov.running
|
4
9
|
SimpleCov.add_filter '/spec/'
|
5
10
|
|
6
|
-
require 'coveralls'
|
7
11
|
require 'ruby_smb'
|
8
12
|
|
9
|
-
|
10
|
-
# don't generate local report as it is inaccessible on travis-ci, which is
|
11
|
-
# why coveralls is being used.
|
12
|
-
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
13
|
-
else
|
14
|
-
SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
|
15
|
-
end
|
13
|
+
SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
|
16
14
|
|
17
15
|
Dir['./spec/support/**/*.rb'].sort.each { |f| require f }
|
18
16
|
|
data.tar.gz.sig
CHANGED
Binary file
|
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: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Metasploit Hackers
|
@@ -97,7 +97,7 @@ cert_chain:
|
|
97
97
|
EknWpNgVhohbot1lfVAMmIhdtOVaRVcQQixWPwprDj/ydB8ryDMDosIMcw+fkoXU
|
98
98
|
9GJsSaSRRYQ9UUkVL27b64okU8D48m8=
|
99
99
|
-----END CERTIFICATE-----
|
100
|
-
date: 2022-
|
100
|
+
date: 2022-08-30 00:00:00.000000000 Z
|
101
101
|
dependencies:
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: redcarpet
|
@@ -298,6 +298,11 @@ files:
|
|
298
298
|
- lib/ruby_smb/dcerpc/bind.rb
|
299
299
|
- lib/ruby_smb/dcerpc/bind_ack.rb
|
300
300
|
- lib/ruby_smb/dcerpc/client.rb
|
301
|
+
- lib/ruby_smb/dcerpc/dfsnm.rb
|
302
|
+
- lib/ruby_smb/dcerpc/dfsnm/netr_dfs_add_std_root_request.rb
|
303
|
+
- lib/ruby_smb/dcerpc/dfsnm/netr_dfs_add_std_root_response.rb
|
304
|
+
- lib/ruby_smb/dcerpc/dfsnm/netr_dfs_remove_std_root_request.rb
|
305
|
+
- lib/ruby_smb/dcerpc/dfsnm/netr_dfs_remove_std_root_response.rb
|
301
306
|
- lib/ruby_smb/dcerpc/drsr.rb
|
302
307
|
- lib/ruby_smb/dcerpc/drsr/drs_bind_request.rb
|
303
308
|
- lib/ruby_smb/dcerpc/drsr/drs_bind_response.rb
|
@@ -321,6 +326,9 @@ files:
|
|
321
326
|
- lib/ruby_smb/dcerpc/epm/epm_twrt.rb
|
322
327
|
- lib/ruby_smb/dcerpc/error.rb
|
323
328
|
- lib/ruby_smb/dcerpc/fault.rb
|
329
|
+
- lib/ruby_smb/dcerpc/icpr.rb
|
330
|
+
- lib/ruby_smb/dcerpc/icpr/cert_server_request_request.rb
|
331
|
+
- lib/ruby_smb/dcerpc/icpr/cert_server_request_response.rb
|
324
332
|
- lib/ruby_smb/dcerpc/ndr.rb
|
325
333
|
- lib/ruby_smb/dcerpc/netlogon.rb
|
326
334
|
- lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_request.rb
|
@@ -485,6 +493,7 @@ files:
|
|
485
493
|
- lib/ruby_smb/nbss/session_request.rb
|
486
494
|
- lib/ruby_smb/ntlm.rb
|
487
495
|
- lib/ruby_smb/ntlm/client.rb
|
496
|
+
- lib/ruby_smb/peer_info.rb
|
488
497
|
- lib/ruby_smb/server.rb
|
489
498
|
- lib/ruby_smb/server/cli.rb
|
490
499
|
- lib/ruby_smb/server/server_client.rb
|
@@ -672,11 +681,18 @@ files:
|
|
672
681
|
- spec/lib/ruby_smb/dcerpc/bind_ack_spec.rb
|
673
682
|
- spec/lib/ruby_smb/dcerpc/bind_spec.rb
|
674
683
|
- spec/lib/ruby_smb/dcerpc/client_spec.rb
|
684
|
+
- spec/lib/ruby_smb/dcerpc/dfsnm/netr_dfs_add_std_root_request_spec.rb
|
685
|
+
- spec/lib/ruby_smb/dcerpc/dfsnm/netr_dfs_add_std_root_response_spec.rb
|
686
|
+
- spec/lib/ruby_smb/dcerpc/dfsnm/netr_dfs_remove_std_root_request_spec.rb
|
687
|
+
- spec/lib/ruby_smb/dcerpc/dfsnm/netr_dfs_remove_std_root_response_spec.rb
|
675
688
|
- spec/lib/ruby_smb/dcerpc/drsr_spec.rb
|
676
689
|
- spec/lib/ruby_smb/dcerpc/encrypting_file_system/efs_rpc_encrypt_file_srv_request_spec.rb
|
677
690
|
- spec/lib/ruby_smb/dcerpc/encrypting_file_system/efs_rpc_encrypt_file_srv_response_spec.rb
|
678
691
|
- spec/lib/ruby_smb/dcerpc/encrypting_file_system/efs_rpc_open_file_raw_request_spec.rb
|
679
692
|
- spec/lib/ruby_smb/dcerpc/encrypting_file_system/efs_rpc_open_file_raw_response_spec.rb
|
693
|
+
- spec/lib/ruby_smb/dcerpc/icpr/cert_server_request_request_spec.rb
|
694
|
+
- spec/lib/ruby_smb/dcerpc/icpr/cert_server_request_response_spec.rb
|
695
|
+
- spec/lib/ruby_smb/dcerpc/icpr/cert_trans_blob_spec.rb
|
680
696
|
- spec/lib/ruby_smb/dcerpc/ndr_spec.rb
|
681
697
|
- spec/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_request_spec.rb
|
682
698
|
- spec/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_response_spec.rb
|
@@ -962,6 +978,7 @@ files:
|
|
962
978
|
- spec/spec_helper.rb
|
963
979
|
- spec/support/bin_helper.rb
|
964
980
|
- spec/support/mock_socket_dispatcher.rb
|
981
|
+
- spec/support/openssl.conf
|
965
982
|
- spec/support/shared/examples/bit_field_single_flag.rb
|
966
983
|
homepage: https://github.com/rapid7/ruby_smb
|
967
984
|
licenses:
|
@@ -994,11 +1011,18 @@ test_files:
|
|
994
1011
|
- spec/lib/ruby_smb/dcerpc/bind_ack_spec.rb
|
995
1012
|
- spec/lib/ruby_smb/dcerpc/bind_spec.rb
|
996
1013
|
- spec/lib/ruby_smb/dcerpc/client_spec.rb
|
1014
|
+
- spec/lib/ruby_smb/dcerpc/dfsnm/netr_dfs_add_std_root_request_spec.rb
|
1015
|
+
- spec/lib/ruby_smb/dcerpc/dfsnm/netr_dfs_add_std_root_response_spec.rb
|
1016
|
+
- spec/lib/ruby_smb/dcerpc/dfsnm/netr_dfs_remove_std_root_request_spec.rb
|
1017
|
+
- spec/lib/ruby_smb/dcerpc/dfsnm/netr_dfs_remove_std_root_response_spec.rb
|
997
1018
|
- spec/lib/ruby_smb/dcerpc/drsr_spec.rb
|
998
1019
|
- spec/lib/ruby_smb/dcerpc/encrypting_file_system/efs_rpc_encrypt_file_srv_request_spec.rb
|
999
1020
|
- spec/lib/ruby_smb/dcerpc/encrypting_file_system/efs_rpc_encrypt_file_srv_response_spec.rb
|
1000
1021
|
- spec/lib/ruby_smb/dcerpc/encrypting_file_system/efs_rpc_open_file_raw_request_spec.rb
|
1001
1022
|
- spec/lib/ruby_smb/dcerpc/encrypting_file_system/efs_rpc_open_file_raw_response_spec.rb
|
1023
|
+
- spec/lib/ruby_smb/dcerpc/icpr/cert_server_request_request_spec.rb
|
1024
|
+
- spec/lib/ruby_smb/dcerpc/icpr/cert_server_request_response_spec.rb
|
1025
|
+
- spec/lib/ruby_smb/dcerpc/icpr/cert_trans_blob_spec.rb
|
1002
1026
|
- spec/lib/ruby_smb/dcerpc/ndr_spec.rb
|
1003
1027
|
- spec/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_request_spec.rb
|
1004
1028
|
- spec/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_response_spec.rb
|
@@ -1284,4 +1308,5 @@ test_files:
|
|
1284
1308
|
- spec/spec_helper.rb
|
1285
1309
|
- spec/support/bin_helper.rb
|
1286
1310
|
- spec/support/mock_socket_dispatcher.rb
|
1311
|
+
- spec/support/openssl.conf
|
1287
1312
|
- spec/support/shared/examples/bit_field_single_flag.rb
|
metadata.gz.sig
CHANGED
Binary file
|