ruby_smb 3.3.7 → 3.3.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.md +14 -0
  4. data/lib/ruby_smb/dcerpc/error.rb +3 -0
  5. data/lib/ruby_smb/dcerpc/lsarpc/lsar_close_handle_request.rb +22 -0
  6. data/lib/ruby_smb/dcerpc/lsarpc/lsar_close_handle_response.rb +23 -0
  7. data/lib/ruby_smb/dcerpc/lsarpc/lsar_lookup_sids_request.rb +26 -0
  8. data/lib/ruby_smb/dcerpc/lsarpc/lsar_lookup_sids_response.rb +25 -0
  9. data/lib/ruby_smb/dcerpc/lsarpc/lsar_open_policy2_request.rb +24 -0
  10. data/lib/ruby_smb/dcerpc/lsarpc/lsar_open_policy2_response.rb +23 -0
  11. data/lib/ruby_smb/dcerpc/lsarpc/lsar_open_policy_request.rb +24 -0
  12. data/lib/ruby_smb/dcerpc/lsarpc/lsar_open_policy_response.rb +23 -0
  13. data/lib/ruby_smb/dcerpc/lsarpc/lsar_query_information_policy2_request.rb +23 -0
  14. data/lib/ruby_smb/dcerpc/lsarpc/lsar_query_information_policy2_response.rb +23 -0
  15. data/lib/ruby_smb/dcerpc/lsarpc/lsar_query_information_policy_request.rb +23 -0
  16. data/lib/ruby_smb/dcerpc/lsarpc/lsar_query_information_policy_response.rb +23 -0
  17. data/lib/ruby_smb/dcerpc/lsarpc.rb +634 -2
  18. data/lib/ruby_smb/dcerpc/request.rb +8 -0
  19. data/lib/ruby_smb/dcerpc/samr/rpc_sid.rb +1 -1
  20. data/lib/ruby_smb/version.rb +1 -1
  21. data/spec/lib/ruby_smb/dcerpc/lsarpc/lsar_close_handle_request_spec.rb +40 -0
  22. data/spec/lib/ruby_smb/dcerpc/lsarpc/lsar_close_handle_response_spec.rb +46 -0
  23. data/spec/lib/ruby_smb/dcerpc/lsarpc/lsar_lookup_sids_request_spec.rb +69 -0
  24. data/spec/lib/ruby_smb/dcerpc/lsarpc/lsar_lookup_sids_response_spec.rb +56 -0
  25. data/spec/lib/ruby_smb/dcerpc/lsarpc/lsar_open_policy2_request_spec.rb +68 -0
  26. data/spec/lib/ruby_smb/dcerpc/lsarpc/lsar_open_policy2_response_spec.rb +46 -0
  27. data/spec/lib/ruby_smb/dcerpc/lsarpc/lsar_open_policy_request_spec.rb +68 -0
  28. data/spec/lib/ruby_smb/dcerpc/lsarpc/lsar_open_policy_response_spec.rb +45 -0
  29. data/spec/lib/ruby_smb/dcerpc/lsarpc/lsar_query_information_policy2_request_spec.rb +47 -0
  30. data/spec/lib/ruby_smb/dcerpc/lsarpc/lsar_query_information_policy2_response_spec.rb +54 -0
  31. data/spec/lib/ruby_smb/dcerpc/lsarpc/lsar_query_information_policy_request_spec.rb +46 -0
  32. data/spec/lib/ruby_smb/dcerpc/lsarpc/lsar_query_information_policy_response_spec.rb +53 -0
  33. data.tar.gz.sig +0 -0
  34. metadata +39 -3
  35. metadata.gz.sig +0 -0
@@ -0,0 +1,40 @@
1
+ RSpec.describe RubySMB::Dcerpc::Lsarpc::LsarCloseHandleRequest do
2
+ subject(:packet) { described_class.new }
3
+
4
+ it { is_expected.to respond_to :policy_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
+ it 'is a BinData::Record' do
11
+ expect(packet).to be_a(BinData::Record)
12
+ end
13
+ describe '#policy_handle' do
14
+ it 'is an LsaprHandle structure' do
15
+ expect(packet.policy_handle).to be_a RubySMB::Dcerpc::Lsarpc::LsaprHandle
16
+ end
17
+ end
18
+ describe '#initialize_instance' do
19
+ it 'sets #opnum to LSAR_CLOSE_HANDLE constant' do
20
+ expect(packet.opnum).to eq(RubySMB::Dcerpc::Lsarpc::LSAR_CLOSE_HANDLE)
21
+ end
22
+ end
23
+ it 'reads itself' do
24
+ new_packet = described_class.new(
25
+ policy_handle: {
26
+ context_handle_attributes: 0,
27
+ context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
28
+ }
29
+ )
30
+ expected_output = {
31
+ policy_handle: {
32
+ context_handle_attributes: 0,
33
+ context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
34
+ }
35
+ }
36
+ expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
37
+ end
38
+ end
39
+
40
+
@@ -0,0 +1,46 @@
1
+ RSpec.describe RubySMB::Dcerpc::Lsarpc::LsarCloseHandleResponse do
2
+ subject(:packet) { described_class.new }
3
+
4
+ it { is_expected.to respond_to :policy_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
+ it 'is a BinData::Record' do
12
+ expect(packet).to be_a(BinData::Record)
13
+ end
14
+ describe '#policy_handle' do
15
+ it 'is a LsaprHandle structure' do
16
+ expect(packet.policy_handle).to be_a RubySMB::Dcerpc::Lsarpc::LsaprHandle
17
+ end
18
+ end
19
+ describe '#error_status' do
20
+ it 'is a NdrUint32 structure' do
21
+ expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
22
+ end
23
+ end
24
+ describe '#initialize_instance' do
25
+ it 'sets #opnum to LSAR_CLOSE_HANDLE constant' do
26
+ expect(packet.opnum).to eq(RubySMB::Dcerpc::Lsarpc::LSAR_CLOSE_HANDLE)
27
+ end
28
+ end
29
+ it 'reads itself' do
30
+ new_class = described_class.new(
31
+ policy_handle: {
32
+ context_handle_attributes: 0,
33
+ context_handle_uuid: '2ef54a87-e29e-4d24-90e9-9da49b94449e'
34
+ },
35
+ error_status: 0
36
+ )
37
+ expect(packet.read(new_class.to_binary_s)).to eq(
38
+ {
39
+ policy_handle: {
40
+ context_handle_attributes: 0,
41
+ context_handle_uuid: '2ef54a87-e29e-4d24-90e9-9da49b94449e'
42
+ },
43
+ error_status: 0
44
+ })
45
+ end
46
+ end
@@ -0,0 +1,69 @@
1
+ require 'ruby_smb/dcerpc/ndr'
2
+
3
+ RSpec.describe RubySMB::Dcerpc::Lsarpc::LsarLookupSidsRequest do
4
+ subject(:packet) { described_class.new }
5
+
6
+ it { is_expected.to respond_to :policy_handle }
7
+ it { is_expected.to respond_to :sid_enum_buffer }
8
+ it { is_expected.to respond_to :translated_names }
9
+ it { is_expected.to respond_to :lookup_level }
10
+ it { is_expected.to respond_to :mapped_count }
11
+ it { is_expected.to respond_to :opnum }
12
+
13
+ it 'is little endian' do
14
+ expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
15
+ end
16
+ it 'is a BinData::Record' do
17
+ expect(packet).to be_a(BinData::Record)
18
+ end
19
+ describe '#policy_handle' do
20
+ it 'is an LsaprHandle structure' do
21
+ expect(packet.policy_handle).to be_a RubySMB::Dcerpc::Lsarpc::LsaprHandle
22
+ end
23
+ end
24
+ describe '#sid_enum_buffer' do
25
+ it 'is an LsaprSidEnumBuffer structure' do
26
+ expect(packet.sid_enum_buffer).to be_a RubySMB::Dcerpc::Lsarpc::LsaprSidEnumBuffer
27
+ end
28
+ end
29
+ describe '#translated_names' do
30
+ it 'is an LsaprTranslatedNames structure' do
31
+ expect(packet.translated_names).to be_a RubySMB::Dcerpc::Lsarpc::LsaprTranslatedNames
32
+ end
33
+ end
34
+ describe '#lookup_level' do
35
+ it 'is an NdrUint16' do
36
+ expect(packet.lookup_level).to be_a RubySMB::Dcerpc::Ndr::NdrUint16
37
+ end
38
+ end
39
+ describe '#mapped_count' do
40
+ it 'is an NdrUint32' do
41
+ expect(packet.mapped_count).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
42
+ end
43
+ end
44
+ describe '#initialize_instance' do
45
+ it 'sets #opnum to LSAR_LOOKUP_SIDS constant' do
46
+ expect(packet.opnum).to eq(RubySMB::Dcerpc::Lsarpc::LSAR_LOOKUP_SIDS)
47
+ end
48
+ end
49
+ it 'reads itself' do
50
+ new_class = described_class.new(
51
+ policy_handle: {
52
+ context_handle_attributes: 0,
53
+ context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
54
+ },
55
+ sid_enum_buffer: { num_entries: 1, sid_info: [ { sid: 'S-1-5-21-2181772609-2124839192-2039643012-500' } ] },
56
+ lookup_level: 0,
57
+ )
58
+ expect(packet.read(new_class.to_binary_s)).to eq(
59
+ policy_handle: {
60
+ context_handle_attributes: 0,
61
+ context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
62
+ },
63
+ sid_enum_buffer: { num_entries: 1, sid_info: [ { sid: 'S-1-5-21-2181772609-2124839192-2039643012-500' } ] },
64
+ translated_names: { num_entries: 0, names: :null },
65
+ lookup_level: 0,
66
+ mapped_count: 0
67
+ )
68
+ end
69
+ end
@@ -0,0 +1,56 @@
1
+ require 'ruby_smb/dcerpc/ndr'
2
+
3
+ RSpec.describe RubySMB::Dcerpc::Lsarpc::LsarLookupSidsResponse do
4
+ subject(:packet) { described_class.new }
5
+
6
+ it { is_expected.to respond_to :referenced_domains }
7
+ it { is_expected.to respond_to :translated_names }
8
+ it { is_expected.to respond_to :mapped_count }
9
+ it { is_expected.to respond_to :error_status }
10
+ it { is_expected.to respond_to :opnum }
11
+
12
+ it 'is little endian' do
13
+ expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
14
+ end
15
+ it 'is a BinData::Record' do
16
+ expect(packet).to be_a(BinData::Record)
17
+ end
18
+ describe '#referenced_domains' do
19
+ it 'is an LsaprReferencedDomainListPtr structure' do
20
+ expect(packet.referenced_domains).to be_a RubySMB::Dcerpc::Lsarpc::LsaprReferencedDomainListPtr
21
+ end
22
+ end
23
+ describe '#translated_names' do
24
+ it 'is an LsaprTranslatedNames structure' do
25
+ expect(packet.translated_names).to be_a RubySMB::Dcerpc::Lsarpc::LsaprTranslatedNames
26
+ end
27
+ end
28
+ describe '#mapped_count' do
29
+ it 'is an NdrUint32 structure' do
30
+ expect(packet.mapped_count).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
31
+ end
32
+ end
33
+ describe '#error_status' do
34
+ it 'is an NdrUint32' do
35
+ expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
36
+ end
37
+ end
38
+ describe '#initialize_instance' do
39
+ it 'sets #opnum to LSAR_LOOKUP_SIDS constant' do
40
+ expect(packet.opnum).to eq(RubySMB::Dcerpc::Lsarpc::LSAR_LOOKUP_SIDS)
41
+ end
42
+ end
43
+ it 'reads itself' do
44
+ new_class = described_class.new(
45
+ translated_names: { num_entries: 1, names: [ { use: 0, name: 'Administrator', domain_index: 0 }] },
46
+ mapped_count: 1,
47
+ error_status: 0
48
+ )
49
+ expect(packet.read(new_class.to_binary_s)).to eq(
50
+ referenced_domains: :null,
51
+ translated_names: { num_entries: 1, names: [ { use: 0, name: { buffer_length: 26, maximum_length: 26, buffer: 'Administrator'.encode('UTF-16LE') }, domain_index: 0 } ] },
52
+ mapped_count: 1,
53
+ error_status: 0
54
+ )
55
+ end
56
+ end
@@ -0,0 +1,68 @@
1
+ require 'ruby_smb/dcerpc/ndr'
2
+
3
+ RSpec.describe RubySMB::Dcerpc::Lsarpc::LsarOpenPolicy2Request do
4
+ subject(:packet) { described_class.new }
5
+
6
+ it { is_expected.to respond_to :system_name }
7
+ it { is_expected.to respond_to :object_attributes }
8
+ it { is_expected.to respond_to :access_mask }
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 '#system_name' do
18
+ it 'is an NdrWideStringzPtr structure' do
19
+ expect(packet.system_name).to be_a RubySMB::Dcerpc::Ndr::NdrWideStringzPtr
20
+ end
21
+ end
22
+ describe '#object_attributes' do
23
+ it 'is an LsaprObjectAttributes structure' do
24
+ expect(packet.object_attributes).to be_a RubySMB::Dcerpc::Lsarpc::LsaprObjectAttributes
25
+ end
26
+ end
27
+ describe '#access_mask' do
28
+ it 'is an NdrUint32 structure' do
29
+ expect(packet.access_mask).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
30
+ end
31
+ end
32
+ describe '#initialize_instance' do
33
+ it 'sets #opnum to LSAR_OPEN_POLICY2 constant' do
34
+ expect(packet.opnum).to eq(RubySMB::Dcerpc::Lsarpc::LSAR_OPEN_POLICY2)
35
+ end
36
+ end
37
+ it 'reads itself' do
38
+ new_class = described_class.new(
39
+ system_name: 'Example_System',
40
+ object_attributes: {
41
+ security_quality_of_service: {
42
+ impersonation_level: 0,
43
+ security_context_tracking_mode: 0
44
+ }
45
+ },
46
+ access_mask: 0
47
+ )
48
+ expect(packet.read(new_class.to_binary_s)).to eq(
49
+ {
50
+ system_name: 'Example_System'.encode('UTF-16LE'),
51
+ object_attributes: {
52
+ len: 24,
53
+ root_directory: :null,
54
+ object_name: :null,
55
+ attributes: 0,
56
+ security_descriptor: :null,
57
+ security_quality_of_service: {
58
+ len: 12,
59
+ impersonation_level: 0,
60
+ security_context_tracking_mode: 0,
61
+ effective_only: 0
62
+ }
63
+ },
64
+ access_mask: 0
65
+ }
66
+ )
67
+ end
68
+ end
@@ -0,0 +1,46 @@
1
+
2
+ RSpec.describe RubySMB::Dcerpc::Lsarpc::LsarOpenPolicy2Response do
3
+ subject(:packet) { described_class.new }
4
+
5
+ it { is_expected.to respond_to :policy_handle }
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
+ it 'is a BinData::Record' do
13
+ expect(packet).to be_a(BinData::Record)
14
+ end
15
+ describe '#policy_handle' do
16
+ it 'is an LsaprHandle structure' do
17
+ expect(packet.policy_handle).to be_a RubySMB::Dcerpc::Lsarpc::LsaprHandle
18
+ end
19
+ end
20
+ describe '#error_status' do
21
+ it 'is a NdrUint32' do
22
+ expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
23
+ end
24
+ end
25
+ describe '#initialize_instance' do
26
+ it 'sets #opnum to LSAR_OPEN_POLICY2 constant' do
27
+ expect(packet.opnum).to eq(RubySMB::Dcerpc::Lsarpc::LSAR_OPEN_POLICY2)
28
+ end
29
+ end
30
+ it 'reads itself' do
31
+ new_class = described_class.new(
32
+ policy_handle: {
33
+ context_handle_attributes: 0,
34
+ context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
35
+ },
36
+ error_status: 0
37
+ )
38
+ expect(packet.read(new_class.to_binary_s)).to eq(
39
+ policy_handle: {
40
+ context_handle_attributes: 0,
41
+ context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
42
+ },
43
+ error_status: 0
44
+ )
45
+ end
46
+ end
@@ -0,0 +1,68 @@
1
+ require 'ruby_smb/dcerpc/ndr'
2
+
3
+ RSpec.describe RubySMB::Dcerpc::Lsarpc::LsarOpenPolicyRequest do
4
+ subject(:packet) { described_class.new }
5
+
6
+ it { is_expected.to respond_to :system_name }
7
+ it { is_expected.to respond_to :object_attributes }
8
+ it { is_expected.to respond_to :access_mask }
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 '#system_name' do
18
+ it 'is an NdrWideStringPtr structure' do
19
+ expect(packet.system_name).to be_a RubySMB::Dcerpc::Ndr::NdrWideStringPtr
20
+ end
21
+ end
22
+ describe '#object_attributes' do
23
+ it 'is an LsaprObjectAttributes structure' do
24
+ expect(packet.object_attributes).to be_a RubySMB::Dcerpc::Lsarpc::LsaprObjectAttributes
25
+ end
26
+ end
27
+ describe '#access_mask' do
28
+ it 'is an NdrUint32 structure' do
29
+ expect(packet.access_mask).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
30
+ end
31
+ end
32
+ describe '#initialize_instance' do
33
+ it 'sets #opnum to LSAR_OPEN_POLICY constant' do
34
+ expect(packet.opnum).to eq(RubySMB::Dcerpc::Lsarpc::LSAR_OPEN_POLICY)
35
+ end
36
+ end
37
+ it 'reads itself' do
38
+ new_class = described_class.new(
39
+ system_name: 'Example_System',
40
+ object_attributes: {
41
+ security_quality_of_service: {
42
+ impersonation_level: 0,
43
+ security_context_tracking_mode: 0
44
+ }
45
+ },
46
+ access_mask: 0
47
+ )
48
+ expect(packet.read(new_class.to_binary_s)).to eq(
49
+ {
50
+ system_name: 'Example_System'.encode('UTF-16LE'),
51
+ object_attributes: {
52
+ len: 24,
53
+ root_directory: :null,
54
+ object_name: :null,
55
+ attributes: 0,
56
+ security_descriptor: :null,
57
+ security_quality_of_service: {
58
+ len: 12,
59
+ impersonation_level: 0,
60
+ security_context_tracking_mode: 0,
61
+ effective_only: 0
62
+ }
63
+ },
64
+ access_mask: 0
65
+ }
66
+ )
67
+ end
68
+ end
@@ -0,0 +1,45 @@
1
+
2
+ RSpec.describe RubySMB::Dcerpc::Lsarpc::LsarOpenPolicyResponse do
3
+ subject(:packet) { described_class.new }
4
+
5
+ it { is_expected.to respond_to :policy_handle }
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
+ it 'is a BinData::Record' do
13
+ expect(packet).to be_a(BinData::Record)
14
+ end
15
+ describe '#policy_handle' do
16
+ it 'is an LsaprHandle structure' do
17
+ expect(packet.policy_handle).to be_a RubySMB::Dcerpc::Lsarpc::LsaprHandle
18
+ end
19
+ end
20
+ describe '#error_status' do
21
+ it 'is a NdrUint32' do
22
+ expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
23
+ end
24
+ end
25
+ describe '#initialize_instance' do
26
+ it 'sets #opnum to LSAR_OPEN_POLICY constant' do
27
+ expect(packet.opnum).to eq(RubySMB::Dcerpc::Lsarpc::LSAR_OPEN_POLICY)
28
+ end
29
+ end
30
+ it 'reads itself' do
31
+ new_class = described_class.new(
32
+ policy_handle: {
33
+ context_handle_attributes: 0,
34
+ context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
35
+ }
36
+ )
37
+ expect(packet.read(new_class.to_binary_s)).to eq(
38
+ policy_handle: {
39
+ context_handle_attributes: 0,
40
+ context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
41
+ },
42
+ error_status: 0
43
+ )
44
+ end
45
+ end
@@ -0,0 +1,47 @@
1
+ require 'ruby_smb/dcerpc/ndr'
2
+
3
+ RSpec.describe RubySMB::Dcerpc::Lsarpc::LsarQueryInformationPolicy2Request do
4
+ subject(:packet) { described_class.new }
5
+
6
+ it { is_expected.to respond_to :policy_handle }
7
+ it { is_expected.to respond_to :information_class }
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 '#policy_handle' do
17
+ it 'is an LsaprHandle structure' do
18
+ expect(packet.policy_handle).to be_a RubySMB::Dcerpc::Lsarpc::LsaprHandle
19
+ end
20
+ end
21
+ describe '#information_class' do
22
+ it 'is an NdrUint32 structure' do
23
+ expect(packet.information_class).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
24
+ end
25
+ end
26
+ describe '#initialize_instance' do
27
+ it 'sets #opnum to LSAR_QUERY_INFORMATION_POLICY2 constant' do
28
+ expect(packet.opnum).to eq(RubySMB::Dcerpc::Lsarpc::LSAR_QUERY_INFORMATION_POLICY2)
29
+ end
30
+ end
31
+ it 'reads itself' do
32
+ new_class = described_class.new(
33
+ policy_handle: {
34
+ context_handle_attributes: 0,
35
+ context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
36
+ },
37
+ information_class: 0
38
+ )
39
+ expect(packet.read(new_class.to_binary_s)).to eq(
40
+ policy_handle: {
41
+ context_handle_attributes: 0,
42
+ context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
43
+ },
44
+ information_class: 0
45
+ )
46
+ end
47
+ end
@@ -0,0 +1,54 @@
1
+ require 'ruby_smb/dcerpc/ndr'
2
+ require 'ruby_smb/dcerpc/lsarpc'
3
+
4
+ RSpec.describe RubySMB::Dcerpc::Lsarpc::LsarQueryInformationPolicy2Response do
5
+ subject(:packet) { described_class.new }
6
+
7
+ it { is_expected.to respond_to :policy_information }
8
+ it { is_expected.to respond_to :error_status }
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 '#policy_information' do
18
+ it 'is an LsaprPolicyInformationPtr structure' do
19
+ expect(packet.policy_information).to be_a RubySMB::Dcerpc::Lsarpc::LsaprPolicyInformationPtr
20
+ end
21
+ end
22
+ describe '#error_status' do
23
+ it 'is an NdrUint32 structure' do
24
+ expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
25
+ end
26
+ end
27
+ describe '#initialize_instance' do
28
+ it 'sets #opnum to LSAR_QUERY_INFORMATION_POLICY2 constant' do
29
+ expect(packet.opnum).to eq(RubySMB::Dcerpc::Lsarpc::LSAR_QUERY_INFORMATION_POLICY2)
30
+ end
31
+ end
32
+ it 'reads itself' do
33
+ new_class = described_class.new(
34
+ policy_information: {
35
+ policy_information_class: 1,
36
+ policy_information: {}
37
+ }
38
+ )
39
+ expect(packet.read(new_class.to_binary_s)).to eq(
40
+ policy_information: {
41
+ policy_information_class: 1,
42
+ policy_information: {
43
+ audit_log_percent_full: 0,
44
+ maximum_log_size: 0,
45
+ audit_retention_period: 0,
46
+ audit_log_full_shutdown_in_progress: 0,
47
+ time_to_shutdown: 0,
48
+ next_audit_record_id: 0
49
+ }
50
+ },
51
+ error_status: 0
52
+ )
53
+ end
54
+ end
@@ -0,0 +1,46 @@
1
+ require 'ruby_smb/dcerpc/ndr'
2
+
3
+ RSpec.describe RubySMB::Dcerpc::Lsarpc::LsarQueryInformationPolicyRequest do
4
+ subject(:packet) { described_class.new }
5
+
6
+ it { is_expected.to respond_to :policy_handle }
7
+ it { is_expected.to respond_to :information_class }
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 '#policy_handle' do
17
+ it 'is an LsaprHandle structure' do
18
+ expect(packet.policy_handle).to be_a RubySMB::Dcerpc::Lsarpc::LsaprHandle
19
+ end
20
+ end
21
+ describe '#information_class' do
22
+ it 'is an NdrUint32 structure' do
23
+ expect(packet.information_class).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
24
+ end
25
+ end
26
+ describe '#initialize_instance' do
27
+ it 'sets #opnum to LSAR_QUERY_INFORMATION_POLICY constant' do
28
+ expect(packet.opnum).to eq(RubySMB::Dcerpc::Lsarpc::LSAR_QUERY_INFORMATION_POLICY)
29
+ end
30
+ end
31
+ it 'reads itself' do
32
+ new_class = described_class.new(
33
+ policy_handle: {
34
+ context_handle_attributes: 0,
35
+ context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
36
+ }
37
+ )
38
+ expect(packet.read(new_class.to_binary_s)).to eq(
39
+ policy_handle: {
40
+ context_handle_attributes: 0,
41
+ context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
42
+ },
43
+ information_class: 0
44
+ )
45
+ end
46
+ end
@@ -0,0 +1,53 @@
1
+ require 'ruby_smb/dcerpc/ndr'
2
+
3
+ RSpec.describe RubySMB::Dcerpc::Lsarpc::LsarQueryInformationPolicyResponse do
4
+ subject(:packet) { described_class.new }
5
+
6
+ it { is_expected.to respond_to :policy_information }
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
+ it 'is a BinData::Record' do
14
+ expect(packet).to be_a(BinData::Record)
15
+ end
16
+ describe '#policy_information' do
17
+ it 'is an LsaprPolicyInformationPtr structure' do
18
+ expect(packet.policy_information).to be_a RubySMB::Dcerpc::Lsarpc::LsaprPolicyInformationPtr
19
+ end
20
+ end
21
+ describe '#error_status' do
22
+ it 'is an NdrUint32 structure' do
23
+ expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
24
+ end
25
+ end
26
+ describe '#initialize_instance' do
27
+ it 'sets #opnum to LSAR_QUERY_INFORMATION_POLICY constant' do
28
+ expect(packet.opnum).to eq(RubySMB::Dcerpc::Lsarpc::LSAR_QUERY_INFORMATION_POLICY)
29
+ end
30
+ end
31
+ it 'reads itself' do
32
+ new_class = described_class.new(
33
+ policy_information: {
34
+ policy_information_class: 1,
35
+ policy_information: {}
36
+ }
37
+ )
38
+ expect(packet.read(new_class.to_binary_s)).to eq(
39
+ policy_information: {
40
+ policy_information_class: 1,
41
+ policy_information: {
42
+ audit_log_percent_full: 0,
43
+ maximum_log_size: 0,
44
+ audit_retention_period: 0,
45
+ audit_log_full_shutdown_in_progress: 0,
46
+ time_to_shutdown: 0,
47
+ next_audit_record_id: 0
48
+ }
49
+ },
50
+ error_status: 0
51
+ )
52
+ end
53
+ end
data.tar.gz.sig CHANGED
Binary file