ruby_smb 3.1.4 → 3.1.5
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/lib/ruby_smb/client/authentication.rb +17 -2
- data/lib/ruby_smb/client.rb +10 -1
- data/lib/ruby_smb/dcerpc/error.rb +13 -0
- data/lib/ruby_smb/dcerpc/fault.rb +83 -0
- data/lib/ruby_smb/dcerpc/ndr.rb +19 -8
- data/lib/ruby_smb/dcerpc/request.rb +15 -10
- data/lib/ruby_smb/dcerpc/rrp_rpc_unicode_string.rb +5 -0
- data/lib/ruby_smb/dcerpc/samr/samr_create_user2_in_domain_request.rb +24 -0
- data/lib/ruby_smb/dcerpc/samr/samr_create_user2_in_domain_response.rb +24 -0
- data/lib/ruby_smb/dcerpc/samr/samr_delete_user_request.rb +21 -0
- data/lib/ruby_smb/dcerpc/samr/samr_delete_user_response.rb +22 -0
- data/lib/ruby_smb/dcerpc/samr/samr_enumerate_domains_in_sam_server_request.rb +25 -0
- data/lib/ruby_smb/dcerpc/samr/samr_enumerate_domains_in_sam_server_response.rb +25 -0
- data/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_response.rb +0 -31
- data/lib/ruby_smb/dcerpc/samr/samr_get_alias_membership_response.rb +1 -14
- data/lib/ruby_smb/dcerpc/samr/samr_lookup_names_in_domain_request.rb +23 -0
- data/lib/ruby_smb/dcerpc/samr/samr_lookup_names_in_domain_response.rb +23 -0
- data/lib/ruby_smb/dcerpc/samr/samr_set_information_user2_request.rb +23 -0
- data/lib/ruby_smb/dcerpc/samr/samr_set_information_user2_response.rb +21 -0
- data/lib/ruby_smb/dcerpc/samr.rb +453 -83
- data/lib/ruby_smb/dcerpc.rb +1 -0
- data/lib/ruby_smb/smb1/pipe.rb +4 -1
- data/lib/ruby_smb/smb2/pipe.rb +4 -2
- data/lib/ruby_smb/version.rb +1 -1
- data/spec/lib/ruby_smb/client_spec.rb +1 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_create_user2_in_domain_request_spec.rb +69 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_create_user2_in_domain_response_spec.rb +69 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_delete_user_request_spec.rb +42 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_delete_user_response_spec.rb +51 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_enumerate_domains_in_sam_server_request_spec.rb +60 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_enumerate_domains_in_sam_server_response_spec.rb +75 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_response_spec.rb +0 -195
- data/spec/lib/ruby_smb/dcerpc/samr/samr_lookup_names_in_domain_request_spec.rb +62 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_lookup_names_in_domain_response_spec.rb +54 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_set_information_user2_request_spec.rb +67 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_set_information_user2_response_spec.rb +35 -0
- data/spec/lib/ruby_smb/dcerpc/samr_spec.rb +194 -0
- data.tar.gz.sig +0 -0
- metadata +33 -2
- metadata.gz.sig +0 -0
@@ -0,0 +1,69 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Samr::SamrCreateUser2InDomainRequest do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :domain_handle }
|
5
|
+
it { is_expected.to respond_to :name }
|
6
|
+
it { is_expected.to respond_to :account_type }
|
7
|
+
it { is_expected.to respond_to :desired_access }
|
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
|
+
|
14
|
+
it 'is a BinData::Record' do
|
15
|
+
expect(packet).to be_a(BinData::Record)
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#domain_handle' do
|
19
|
+
it 'is a SamprHandle structure' do
|
20
|
+
expect(packet.domain_handle).to be_a RubySMB::Dcerpc::Samr::SamprHandle
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#name' do
|
25
|
+
it 'is a RpcUnicodeString' do
|
26
|
+
expect(packet.name).to be_a RubySMB::Dcerpc::RpcUnicodeString
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#account_type' do
|
31
|
+
it 'is a NdrUint32 structure' do
|
32
|
+
expect(packet.account_type).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#desired_access' do
|
37
|
+
it 'is a NdrUint32 structure' do
|
38
|
+
expect(packet.desired_access).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#initialize_instance' do
|
43
|
+
it 'sets #opnum to SAMR_CREATE_USER2_IN_DOMAIN constant' do
|
44
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Samr::SAMR_CREATE_USER2_IN_DOMAIN)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'reads itself' do
|
49
|
+
new_packet = described_class.new({
|
50
|
+
domain_handle: {
|
51
|
+
context_handle_attributes: 0,
|
52
|
+
context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
|
53
|
+
},
|
54
|
+
name: 'test',
|
55
|
+
account_type: 1,
|
56
|
+
desired_access: 2
|
57
|
+
})
|
58
|
+
expected_output = {
|
59
|
+
domain_handle: {
|
60
|
+
context_handle_attributes: 0,
|
61
|
+
context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
|
62
|
+
},
|
63
|
+
name: {:buffer=>"test".encode('utf-16le'), :buffer_length=>8, :maximum_length=>8},
|
64
|
+
account_type: 1,
|
65
|
+
desired_access: 2
|
66
|
+
}
|
67
|
+
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Samr::SamrCreateUser2InDomainResponse do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :user_handle }
|
5
|
+
it { is_expected.to respond_to :granted_access }
|
6
|
+
it { is_expected.to respond_to :relative_id }
|
7
|
+
it { is_expected.to respond_to :error_status }
|
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
|
+
|
14
|
+
it 'is a BinData::Record' do
|
15
|
+
expect(packet).to be_a(BinData::Record)
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#user_handle' do
|
19
|
+
it 'is a SamprHandle structure' do
|
20
|
+
expect(packet.user_handle).to be_a RubySMB::Dcerpc::Samr::SamprHandle
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#granted_access' do
|
25
|
+
it 'is a NdrUint32' do
|
26
|
+
expect(packet.granted_access).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#relative_id' do
|
31
|
+
it 'is a NdrUint32 structure' do
|
32
|
+
expect(packet.relative_id).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#error_status' do
|
37
|
+
it 'is a NdrUint32 structure' do
|
38
|
+
expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#initialize_instance' do
|
43
|
+
it 'sets #opnum to SAMR_CREATE_USER2_IN_DOMAIN constant' do
|
44
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Samr::SAMR_CREATE_USER2_IN_DOMAIN)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'reads itself' do
|
49
|
+
new_packet = described_class.new({
|
50
|
+
user_handle: {
|
51
|
+
context_handle_attributes: 0,
|
52
|
+
context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
|
53
|
+
},
|
54
|
+
granted_access: 1,
|
55
|
+
relative_id: 2,
|
56
|
+
error_status: 0x11223344
|
57
|
+
})
|
58
|
+
expected_output = {
|
59
|
+
user_handle: {
|
60
|
+
context_handle_attributes: 0,
|
61
|
+
context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
|
62
|
+
},
|
63
|
+
granted_access: 1,
|
64
|
+
relative_id: 2,
|
65
|
+
error_status: 0x11223344
|
66
|
+
}
|
67
|
+
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Samr::SamrDeleteUserRequest do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :user_handle }
|
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
|
+
|
11
|
+
it 'is a BinData::Record' do
|
12
|
+
expect(packet).to be_a(BinData::Record)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#user_handle' do
|
16
|
+
it 'is a SamprHandle structure' do
|
17
|
+
expect(packet.user_handle).to be_a RubySMB::Dcerpc::Samr::SamprHandle
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#initialize_instance' do
|
22
|
+
it 'sets #opnum to SAMR_DELETE_USER constant' do
|
23
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Samr::SAMR_DELETE_USER)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'reads itself' do
|
28
|
+
new_packet = described_class.new({
|
29
|
+
user_handle: {
|
30
|
+
context_handle_attributes: 0,
|
31
|
+
context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
|
32
|
+
}
|
33
|
+
})
|
34
|
+
expected_output = {
|
35
|
+
user_handle: {
|
36
|
+
context_handle_attributes: 0,
|
37
|
+
context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
|
38
|
+
}
|
39
|
+
}
|
40
|
+
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Samr::SamrDeleteUserResponse do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :user_handle }
|
5
|
+
it { is_expected.to respond_to :error_status }
|
6
|
+
it { is_expected.to respond_to :opnum }
|
7
|
+
|
8
|
+
it 'is little endian' do
|
9
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'is a BinData::Record' do
|
13
|
+
expect(packet).to be_a(BinData::Record)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#user_handle' do
|
17
|
+
it 'is a SamprHandle structure' do
|
18
|
+
expect(packet.user_handle).to be_a RubySMB::Dcerpc::Samr::SamprHandle
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#error_status' do
|
23
|
+
it 'is a NdrUint32 structure' do
|
24
|
+
expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#initialize_instance' do
|
29
|
+
it 'sets #opnum to SAMR_DELETE_USER constant' do
|
30
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Samr::SAMR_DELETE_USER)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'reads itself' do
|
35
|
+
new_packet = described_class.new({
|
36
|
+
user_handle: {
|
37
|
+
context_handle_attributes: 0,
|
38
|
+
context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
|
39
|
+
},
|
40
|
+
error_status: 0x11223344
|
41
|
+
})
|
42
|
+
expected_output = {
|
43
|
+
user_handle: {
|
44
|
+
context_handle_attributes: 0,
|
45
|
+
context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
|
46
|
+
},
|
47
|
+
error_status: 0x11223344
|
48
|
+
}
|
49
|
+
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Samr::SamrEnumerateDomainsInSamServerRequest do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :server_handle }
|
5
|
+
it { is_expected.to respond_to :enumeration_context }
|
6
|
+
it { is_expected.to respond_to :prefered_maximum_length }
|
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
|
+
|
13
|
+
it 'is a BinData::Record' do
|
14
|
+
expect(packet).to be_a(BinData::Record)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#server_handle' do
|
18
|
+
it 'is a SamprHandle structure' do
|
19
|
+
expect(packet.server_handle).to be_a RubySMB::Dcerpc::Samr::SamprHandle
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#enumeration_context' do
|
24
|
+
it 'is a NdrUint32 structure' do
|
25
|
+
expect(packet.enumeration_context).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#prefered_maximum_length' do
|
30
|
+
it 'is a NdrUint32 structure' do
|
31
|
+
expect(packet.prefered_maximum_length).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#initialize_instance' do
|
36
|
+
it 'sets #opnum to SAMR_ENUMERATE_DOMAINS_IN_SAM_SERVER constant' do
|
37
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Samr::SAMR_ENUMERATE_DOMAINS_IN_SAM_SERVER)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'reads itself' do
|
42
|
+
new_packet = described_class.new({
|
43
|
+
server_handle: {
|
44
|
+
context_handle_attributes: 0,
|
45
|
+
context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
|
46
|
+
},
|
47
|
+
enumeration_context: 1,
|
48
|
+
prefered_maximum_length: 2
|
49
|
+
})
|
50
|
+
expected_output = {
|
51
|
+
server_handle: {
|
52
|
+
context_handle_attributes: 0,
|
53
|
+
context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
|
54
|
+
},
|
55
|
+
enumeration_context: 1,
|
56
|
+
prefered_maximum_length: 2
|
57
|
+
}
|
58
|
+
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Samr::SamrEnumerateDomainsInSamServerResponse do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :enumeration_context }
|
5
|
+
it { is_expected.to respond_to :buffer }
|
6
|
+
it { is_expected.to respond_to :count_returned }
|
7
|
+
it { is_expected.to respond_to :error_status }
|
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
|
+
|
14
|
+
it 'is a BinData::Record' do
|
15
|
+
expect(packet).to be_a(BinData::Record)
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#enumeration_context' do
|
19
|
+
it 'is a NdrUint32 structure' do
|
20
|
+
expect(packet.enumeration_context).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#buffer' do
|
25
|
+
it 'is a PsamprEnumerationBuffer structure' do
|
26
|
+
expect(packet.buffer).to be_a RubySMB::Dcerpc::Samr::PsamprEnumerationBuffer
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#count_returned' do
|
31
|
+
it 'is a NdrUint32 structure' do
|
32
|
+
expect(packet.count_returned).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#error_status' do
|
37
|
+
it 'is a NdrUint32 structure' do
|
38
|
+
expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#initialize_instance' do
|
43
|
+
it 'sets #opnum to SAMR_ENUMERATE_DOMAINS_IN_SAM_SERVER constant' do
|
44
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Samr::SAMR_ENUMERATE_DOMAINS_IN_SAM_SERVER)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'reads itself' do
|
49
|
+
new_packet = described_class.new({
|
50
|
+
enumeration_context: 1,
|
51
|
+
buffer: {
|
52
|
+
entries_read: 2,
|
53
|
+
buffer: [
|
54
|
+
{relative_id: 500, name: { buffer_length: 26, maximum_length: 26, buffer: "Builtin".encode('utf-16le') }},
|
55
|
+
{relative_id: 501, name: { buffer_length: 10, maximum_length: 10, buffer: "RUBYSMB".encode('utf-16le') }},
|
56
|
+
]
|
57
|
+
},
|
58
|
+
count_returned: 2,
|
59
|
+
error_status: 0x11223344
|
60
|
+
})
|
61
|
+
expected_output = {
|
62
|
+
enumeration_context: 1,
|
63
|
+
buffer: {
|
64
|
+
entries_read: 2,
|
65
|
+
buffer: [
|
66
|
+
{relative_id: 500, name: { buffer_length: 26, maximum_length: 26, buffer: "Builtin".encode('utf-16le') }},
|
67
|
+
{relative_id: 501, name: { buffer_length: 10, maximum_length: 10, buffer: "RUBYSMB".encode('utf-16le') }},
|
68
|
+
]
|
69
|
+
},
|
70
|
+
count_returned: 2,
|
71
|
+
error_status: 0x11223344
|
72
|
+
}
|
73
|
+
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
74
|
+
end
|
75
|
+
end
|
@@ -1,197 +1,3 @@
|
|
1
|
-
RSpec.describe RubySMB::Dcerpc::Samr::SamprRidEnumeration do
|
2
|
-
subject(:packet) { described_class.new }
|
3
|
-
|
4
|
-
it { is_expected.to respond_to :relative_id }
|
5
|
-
it { is_expected.to respond_to :name }
|
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 Ndr::NdrStruct' do
|
11
|
-
expect(packet).to be_a(RubySMB::Dcerpc::Ndr::NdrStruct)
|
12
|
-
end
|
13
|
-
it 'is four-byte aligned' do
|
14
|
-
expect(packet.eval_parameter(:byte_align)).to eq(4)
|
15
|
-
end
|
16
|
-
describe '#relative_id' do
|
17
|
-
it 'is a NdrUint32 structure' do
|
18
|
-
expect(packet.relative_id).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
19
|
-
end
|
20
|
-
end
|
21
|
-
describe '#name' do
|
22
|
-
it 'is a RpcUnicodeString structure' do
|
23
|
-
expect(packet.name).to be_a RubySMB::Dcerpc::RpcUnicodeString
|
24
|
-
end
|
25
|
-
end
|
26
|
-
it 'reads itself' do
|
27
|
-
new_packet = described_class.new(relative_id: 4, name: 'Test String')
|
28
|
-
expected_output = {
|
29
|
-
relative_id: 4,
|
30
|
-
name: {
|
31
|
-
buffer_length: 22,
|
32
|
-
maximum_length: 22,
|
33
|
-
buffer: "Test String".encode('utf-16le')
|
34
|
-
}
|
35
|
-
}
|
36
|
-
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
RSpec.describe RubySMB::Dcerpc::Samr::SamprRidEnumerationArray do
|
41
|
-
subject(:packet) { described_class.new }
|
42
|
-
|
43
|
-
it 'is a Ndr::NdrConfArray' do
|
44
|
-
expect(packet).to be_a(RubySMB::Dcerpc::Ndr::NdrConfArray)
|
45
|
-
end
|
46
|
-
it 'has element of type SamprRidEnumeration' do
|
47
|
-
packet << {relative_id: 4, name: ''}
|
48
|
-
expect(packet[0]).to be_a(RubySMB::Dcerpc::Samr::SamprRidEnumeration)
|
49
|
-
end
|
50
|
-
it 'reads itself' do
|
51
|
-
new_packet = described_class.new([
|
52
|
-
{relative_id: 4, name: 'Test1'},
|
53
|
-
{relative_id: 1, name: 'Test2'}
|
54
|
-
])
|
55
|
-
expected_output = [
|
56
|
-
{
|
57
|
-
relative_id: 4,
|
58
|
-
name: {
|
59
|
-
buffer_length: 10,
|
60
|
-
maximum_length: 10,
|
61
|
-
buffer: "Test1".encode('utf-16le')
|
62
|
-
}
|
63
|
-
},
|
64
|
-
{
|
65
|
-
relative_id: 1,
|
66
|
-
name: {
|
67
|
-
buffer_length: 10,
|
68
|
-
maximum_length: 10,
|
69
|
-
buffer: "Test2".encode('utf-16le')
|
70
|
-
}
|
71
|
-
}]
|
72
|
-
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
RSpec.describe RubySMB::Dcerpc::Samr::PsamprRidEnumerationArray do
|
77
|
-
subject(:packet) { described_class.new }
|
78
|
-
|
79
|
-
it 'is a SamprRidEnumerationArray' do
|
80
|
-
expect(packet).to be_a(RubySMB::Dcerpc::Samr::SamprRidEnumerationArray)
|
81
|
-
end
|
82
|
-
it 'is a NdrPointer' do
|
83
|
-
expect(described_class).to be_a(RubySMB::Dcerpc::Ndr::PointerClassPlugin)
|
84
|
-
expect(packet).to be_a(RubySMB::Dcerpc::Ndr::PointerPlugin)
|
85
|
-
end
|
86
|
-
it 'is four-byte aligned' do
|
87
|
-
expect(packet.eval_parameter(:byte_align)).to eq(4)
|
88
|
-
end
|
89
|
-
it 'reads itself' do
|
90
|
-
new_packet = described_class.new([
|
91
|
-
{relative_id: 4, name: 'Test1'},
|
92
|
-
{relative_id: 1, name: 'Test2'}
|
93
|
-
])
|
94
|
-
expected_output = [
|
95
|
-
{
|
96
|
-
relative_id: 4,
|
97
|
-
name: {
|
98
|
-
buffer_length: 10,
|
99
|
-
maximum_length: 10,
|
100
|
-
buffer: "Test1".encode('utf-16le')
|
101
|
-
}
|
102
|
-
},
|
103
|
-
{
|
104
|
-
relative_id: 1,
|
105
|
-
name: {
|
106
|
-
buffer_length: 10,
|
107
|
-
maximum_length: 10,
|
108
|
-
buffer: "Test2".encode('utf-16le')
|
109
|
-
}
|
110
|
-
}]
|
111
|
-
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
RSpec.describe RubySMB::Dcerpc::Samr::SamprEnumerationBuffer do
|
116
|
-
subject(:packet) { described_class.new }
|
117
|
-
|
118
|
-
it { is_expected.to respond_to :entries_read }
|
119
|
-
it { is_expected.to respond_to :buffer }
|
120
|
-
|
121
|
-
it 'is little endian' do
|
122
|
-
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
123
|
-
end
|
124
|
-
it 'is a Ndr::NdrStruct' do
|
125
|
-
expect(packet).to be_a(RubySMB::Dcerpc::Ndr::NdrStruct)
|
126
|
-
end
|
127
|
-
it 'is four-byte aligned' do
|
128
|
-
expect(packet.eval_parameter(:byte_align)).to eq(4)
|
129
|
-
end
|
130
|
-
describe '#entries_read' do
|
131
|
-
it 'is a NdrUint32 structure' do
|
132
|
-
expect(packet.entries_read).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
133
|
-
end
|
134
|
-
end
|
135
|
-
describe '#buffer' do
|
136
|
-
it 'is a PsamprRidEnumerationArray structure' do
|
137
|
-
expect(packet.buffer).to be_a RubySMB::Dcerpc::Samr::PsamprRidEnumerationArray
|
138
|
-
end
|
139
|
-
end
|
140
|
-
it 'reads itself' do
|
141
|
-
new_packet = described_class.new(
|
142
|
-
entries_read: 3,
|
143
|
-
buffer: [
|
144
|
-
{ relative_id: 500, name: "Administrator" },
|
145
|
-
{ relative_id: 501, name: "Guest" },
|
146
|
-
{ relative_id: 1001, name: "WIN-DP0M1BC768$" }
|
147
|
-
]
|
148
|
-
)
|
149
|
-
expected_output = {
|
150
|
-
entries_read: 3,
|
151
|
-
buffer: [
|
152
|
-
{relative_id: 500, name: { buffer_length: 26, maximum_length: 26, buffer: "Administrator".encode('utf-16le') }},
|
153
|
-
{relative_id: 501, name: { buffer_length: 10, maximum_length: 10, buffer: "Guest".encode('utf-16le') }},
|
154
|
-
{relative_id: 1001, name: { buffer_length: 30, maximum_length: 30, buffer: "WIN-DP0M1BC768$".encode('utf-16le') }}
|
155
|
-
]
|
156
|
-
}
|
157
|
-
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
RSpec.describe RubySMB::Dcerpc::Samr::PsamprEnumerationBuffer do
|
162
|
-
subject(:packet) { described_class.new }
|
163
|
-
|
164
|
-
it 'is a SamprEnumerationBuffer' do
|
165
|
-
expect(packet).to be_a(RubySMB::Dcerpc::Samr::SamprEnumerationBuffer)
|
166
|
-
end
|
167
|
-
it 'is a NdrPointer' do
|
168
|
-
expect(described_class).to be_a(RubySMB::Dcerpc::Ndr::PointerClassPlugin)
|
169
|
-
expect(packet).to be_a(RubySMB::Dcerpc::Ndr::PointerPlugin)
|
170
|
-
end
|
171
|
-
it 'is four-byte aligned' do
|
172
|
-
expect(packet.eval_parameter(:byte_align)).to eq(4)
|
173
|
-
end
|
174
|
-
it 'reads itself' do
|
175
|
-
new_packet = described_class.new(
|
176
|
-
entries_read: 3,
|
177
|
-
buffer: [
|
178
|
-
{ relative_id: 500, name: "Administrator" },
|
179
|
-
{ relative_id: 501, name: "Guest" },
|
180
|
-
{ relative_id: 1001, name: "WIN-DP0M1BC768$" }
|
181
|
-
]
|
182
|
-
)
|
183
|
-
expected_output = {
|
184
|
-
entries_read: 3,
|
185
|
-
buffer: [
|
186
|
-
{relative_id: 500, name: { buffer_length: 26, maximum_length: 26, buffer: "Administrator".encode('utf-16le') }},
|
187
|
-
{relative_id: 501, name: { buffer_length: 10, maximum_length: 10, buffer: "Guest".encode('utf-16le') }},
|
188
|
-
{relative_id: 1001, name: { buffer_length: 30, maximum_length: 30, buffer: "WIN-DP0M1BC768$".encode('utf-16le') }}
|
189
|
-
]
|
190
|
-
}
|
191
|
-
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
1
|
RSpec.describe RubySMB::Dcerpc::Samr::SamrEnumerateUsersInDomainResponse do
|
196
2
|
subject(:packet) { described_class.new }
|
197
3
|
|
@@ -262,4 +68,3 @@ RSpec.describe RubySMB::Dcerpc::Samr::SamrEnumerateUsersInDomainResponse do
|
|
262
68
|
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
263
69
|
end
|
264
70
|
end
|
265
|
-
|
@@ -0,0 +1,62 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Samr::SamrLookupNamesInDomainRequest do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :domain_handle }
|
5
|
+
it { is_expected.to respond_to :names_count }
|
6
|
+
it { is_expected.to respond_to :names }
|
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
|
+
|
13
|
+
it 'is a BinData::Record' do
|
14
|
+
expect(packet).to be_a(BinData::Record)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#domain_handle' do
|
18
|
+
it 'is a SamprHandle structure' do
|
19
|
+
expect(packet.domain_handle).to be_a RubySMB::Dcerpc::Samr::SamprHandle
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#names_count' do
|
24
|
+
it 'is a NdrUint32 structure' do
|
25
|
+
expect(packet.names_count).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#names' do
|
30
|
+
it 'is a RpcUnicodeStringConfVarArray structure' do
|
31
|
+
expect(packet.names).to be_a RubySMB::Dcerpc::RpcUnicodeStringConfVarArray
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#initialize_instance' do
|
36
|
+
it 'sets #opnum to SAMR_LOOKUP_NAMES_IN_DOMAIN constant' do
|
37
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Samr::SAMR_LOOKUP_NAMES_IN_DOMAIN)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'reads itself' do
|
42
|
+
new_packet = described_class.new({
|
43
|
+
domain_handle: {
|
44
|
+
context_handle_attributes: 0,
|
45
|
+
context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
|
46
|
+
},
|
47
|
+
names_count: 1,
|
48
|
+
names: [ 'TEST' ]
|
49
|
+
})
|
50
|
+
expected_output = {
|
51
|
+
domain_handle: {
|
52
|
+
context_handle_attributes: 0,
|
53
|
+
context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
|
54
|
+
},
|
55
|
+
names_count: 1,
|
56
|
+
names: [
|
57
|
+
{ buffer_length: 8, maximum_length: 8, buffer: "TEST".encode('utf-16le') }
|
58
|
+
]
|
59
|
+
}
|
60
|
+
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Samr::SamrLookupNamesInDomainResponse do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :relative_ids }
|
5
|
+
it { is_expected.to respond_to :use }
|
6
|
+
it { is_expected.to respond_to :error_status }
|
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
|
+
|
13
|
+
it 'is a BinData::Record' do
|
14
|
+
expect(packet).to be_a(BinData::Record)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#relative_ids' do
|
18
|
+
it 'is a SamprHandle structure' do
|
19
|
+
expect(packet.relative_ids).to be_a RubySMB::Dcerpc::Samr::SamprUlongArray
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#use' do
|
24
|
+
it 'is a SamprHandle structure' do
|
25
|
+
expect(packet.use).to be_a RubySMB::Dcerpc::Samr::SamprUlongArray
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#error_status' do
|
30
|
+
it 'is a NdrUint32 structure' do
|
31
|
+
expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#initialize_instance' do
|
36
|
+
it 'sets #opnum to SAMR_LOOKUP_NAMES_IN_DOMAIN constant' do
|
37
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Samr::SAMR_LOOKUP_NAMES_IN_DOMAIN)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'reads itself' do
|
42
|
+
new_packet = described_class.new({
|
43
|
+
relative_ids: { element_count: 2, elements: [ 500, 501 ] },
|
44
|
+
use: { element_count: 2, elements: [ 1, 2 ] },
|
45
|
+
error_status: 0x11223344
|
46
|
+
})
|
47
|
+
expected_output = {
|
48
|
+
relative_ids: { element_count: 2, elements: [ 500, 501 ] },
|
49
|
+
use: { element_count: 2, elements: [ 1, 2 ] },
|
50
|
+
error_status: 0x11223344
|
51
|
+
}
|
52
|
+
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
53
|
+
end
|
54
|
+
end
|