ruby_smb 1.0.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.travis.yml +4 -1
- data/README.md +35 -47
- data/examples/enum_registry_key.rb +28 -0
- data/examples/enum_registry_values.rb +30 -0
- data/examples/pipes.rb +2 -1
- data/examples/read_registry_key_value.rb +32 -0
- data/lib/ruby_smb.rb +0 -1
- data/lib/ruby_smb/client.rb +2 -0
- data/lib/ruby_smb/client/winreg.rb +46 -0
- data/lib/ruby_smb/dcerpc.rb +38 -0
- data/lib/ruby_smb/dcerpc/bind.rb +2 -2
- data/lib/ruby_smb/dcerpc/bind_ack.rb +2 -2
- data/lib/ruby_smb/dcerpc/error.rb +3 -0
- data/lib/ruby_smb/dcerpc/ndr.rb +95 -16
- data/lib/ruby_smb/dcerpc/pdu_header.rb +1 -1
- data/lib/ruby_smb/dcerpc/request.rb +28 -9
- data/lib/ruby_smb/dcerpc/rrp_unicode_string.rb +35 -0
- data/lib/ruby_smb/dcerpc/srvsvc.rb +10 -0
- data/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all.rb +9 -0
- data/lib/ruby_smb/dcerpc/winreg.rb +340 -0
- data/lib/ruby_smb/dcerpc/winreg/close_key_request.rb +24 -0
- data/lib/ruby_smb/dcerpc/winreg/close_key_response.rb +27 -0
- data/lib/ruby_smb/dcerpc/winreg/enum_key_request.rb +45 -0
- data/lib/ruby_smb/dcerpc/winreg/enum_key_response.rb +42 -0
- data/lib/ruby_smb/dcerpc/winreg/enum_value_request.rb +39 -0
- data/lib/ruby_smb/dcerpc/winreg/enum_value_response.rb +36 -0
- data/lib/ruby_smb/dcerpc/winreg/open_key_request.rb +34 -0
- data/lib/ruby_smb/dcerpc/winreg/open_key_response.rb +25 -0
- data/lib/ruby_smb/dcerpc/winreg/open_root_key_request.rb +43 -0
- data/lib/ruby_smb/dcerpc/winreg/open_root_key_response.rb +35 -0
- data/lib/ruby_smb/dcerpc/winreg/query_info_key_request.rb +27 -0
- data/lib/ruby_smb/dcerpc/winreg/query_info_key_response.rb +40 -0
- data/lib/ruby_smb/dcerpc/winreg/query_value_request.rb +39 -0
- data/lib/ruby_smb/dcerpc/winreg/query_value_response.rb +57 -0
- data/lib/ruby_smb/dcerpc/winreg/regsam.rb +40 -0
- data/lib/ruby_smb/smb1/file.rb +2 -0
- data/lib/ruby_smb/smb1/pipe.rb +78 -2
- data/lib/ruby_smb/smb2/packet/error_packet.rb +2 -4
- data/lib/ruby_smb/smb2/pipe.rb +89 -2
- data/lib/ruby_smb/version.rb +1 -1
- data/ruby_smb.gemspec +3 -3
- data/spec/lib/ruby_smb/client_spec.rb +148 -0
- data/spec/lib/ruby_smb/dcerpc/bind_ack_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/bind_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/ndr_spec.rb +410 -0
- data/spec/lib/ruby_smb/dcerpc/request_spec.rb +50 -7
- data/spec/lib/ruby_smb/dcerpc/rrp_unicode_string_spec.rb +98 -0
- data/spec/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all_spec.rb +13 -0
- data/spec/lib/ruby_smb/dcerpc/srvsvc_spec.rb +60 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/close_key_request_spec.rb +28 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/close_key_response_spec.rb +36 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/enum_key_request_spec.rb +108 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/enum_key_response_spec.rb +97 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_request_spec.rb +94 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_response_spec.rb +82 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/open_key_request_spec.rb +74 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/open_key_response_spec.rb +35 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_request_spec.rb +90 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_response_spec.rb +38 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/query_info_key_request_spec.rb +39 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/query_info_key_response_spec.rb +113 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/query_value_request_spec.rb +88 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/query_value_response_spec.rb +150 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/regsam_spec.rb +32 -0
- data/spec/lib/ruby_smb/dcerpc/winreg_spec.rb +710 -0
- data/spec/lib/ruby_smb/dcerpc_spec.rb +81 -0
- data/spec/lib/ruby_smb/smb1/file_spec.rb +9 -1
- data/spec/lib/ruby_smb/smb1/pipe_spec.rb +210 -148
- data/spec/lib/ruby_smb/smb2/packet/error_packet_spec.rb +3 -24
- data/spec/lib/ruby_smb/smb2/pipe_spec.rb +256 -145
- metadata +66 -9
- metadata.gz.sig +0 -0
- data/lib/ruby_smb/smb1/dcerpc.rb +0 -72
- data/lib/ruby_smb/smb2/dcerpc.rb +0 -75
@@ -0,0 +1,94 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Winreg::RpcHkey do
|
2
|
+
it 'is NdrContextHandle subclass' do
|
3
|
+
expect(described_class).to be < RubySMB::Dcerpc::Ndr::NdrContextHandle
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
RSpec.describe RubySMB::Dcerpc::Winreg::EnumValueRequest do
|
8
|
+
subject(:packet) { described_class.new }
|
9
|
+
|
10
|
+
it { is_expected.to respond_to :hkey }
|
11
|
+
it { is_expected.to respond_to :dw_index }
|
12
|
+
it { is_expected.to respond_to :lp_value_name }
|
13
|
+
it { is_expected.to respond_to :pad }
|
14
|
+
it { is_expected.to respond_to :lp_type }
|
15
|
+
it { is_expected.to respond_to :lp_data }
|
16
|
+
it { is_expected.to respond_to :lpcb_data }
|
17
|
+
it { is_expected.to respond_to :lpcb_len }
|
18
|
+
it { is_expected.to respond_to :opnum }
|
19
|
+
|
20
|
+
it 'is little endian' do
|
21
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#hkey' do
|
25
|
+
it 'is a RpcHkey structure' do
|
26
|
+
expect(packet.hkey).to be_a RubySMB::Dcerpc::Winreg::RpcHkey
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#dw_index' do
|
31
|
+
it 'is a 32-bit unsigned integer' do
|
32
|
+
expect(packet.dw_index).to be_a BinData::Uint32le
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#lp_value_name' do
|
37
|
+
it 'is a RrpUnicodeString structure' do
|
38
|
+
expect(packet.lp_value_name).to be_a RubySMB::Dcerpc::RrpUnicodeString
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#pad' do
|
43
|
+
it 'is a string' do
|
44
|
+
expect(packet.pad).to be_a BinData::String
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should keep #lp_type 4-byte aligned' do
|
48
|
+
packet.lp_value_name = "test"
|
49
|
+
expect(packet.lp_type.abs_offset % 4).to eq 0
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#lp_type' do
|
54
|
+
it 'is a NdrLpDword structure' do
|
55
|
+
expect(packet.lp_type).to be_a RubySMB::Dcerpc::Ndr::NdrLpDword
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#lp_data' do
|
60
|
+
it 'is a NdrLpByte structure' do
|
61
|
+
expect(packet.lp_data).to be_a RubySMB::Dcerpc::Ndr::NdrLpByte
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#lpcb_data' do
|
66
|
+
it 'is a NdrLpDword structure' do
|
67
|
+
expect(packet.lpcb_data).to be_a RubySMB::Dcerpc::Ndr::NdrLpDword
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#lpcb_len' do
|
72
|
+
it 'is a NdrLpDword structure' do
|
73
|
+
expect(packet.lpcb_len).to be_a RubySMB::Dcerpc::Ndr::NdrLpDword
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe '#initialize_instance' do
|
78
|
+
it 'sets #opnum to REG_ENUM_VALUE constant' do
|
79
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Winreg::REG_ENUM_VALUE)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '#pad_length' do
|
84
|
+
it 'returns 0 when #lp_class is already 4-byte aligned' do
|
85
|
+
packet.lp_value_name = 'align'
|
86
|
+
expect(packet.pad_length).to eq 0
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'returns 2 when #lp_class is only 2-byte aligned' do
|
90
|
+
packet.lp_value_name = 'align' + 'A'
|
91
|
+
expect(packet.pad_length).to eq 2
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Winreg::EnumValueResponse do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :lp_value_name }
|
5
|
+
it { is_expected.to respond_to :pad }
|
6
|
+
it { is_expected.to respond_to :lp_type }
|
7
|
+
it { is_expected.to respond_to :lp_data }
|
8
|
+
it { is_expected.to respond_to :lpcb_data }
|
9
|
+
it { is_expected.to respond_to :lpcb_len }
|
10
|
+
it { is_expected.to respond_to :error_status }
|
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
|
+
|
17
|
+
describe '#lp_value_name' do
|
18
|
+
it 'is a RrpUnicodeString structure' do
|
19
|
+
expect(packet.lp_value_name).to be_a RubySMB::Dcerpc::RrpUnicodeString
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#pad' do
|
24
|
+
it 'is a string' do
|
25
|
+
expect(packet.pad).to be_a BinData::String
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should keep #lp_type 4-byte aligned' do
|
29
|
+
packet.lp_value_name = "test"
|
30
|
+
expect(packet.lp_type.abs_offset % 4).to eq 0
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#lp_type' do
|
35
|
+
it 'is a NdrLpDword structure' do
|
36
|
+
expect(packet.lp_type).to be_a RubySMB::Dcerpc::Ndr::NdrLpDword
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#lp_data' do
|
41
|
+
it 'is a NdrLpByte structure' do
|
42
|
+
expect(packet.lp_data).to be_a RubySMB::Dcerpc::Ndr::NdrLpByte
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#lpcb_data' do
|
47
|
+
it 'is a NdrLpDword structure' do
|
48
|
+
expect(packet.lpcb_data).to be_a RubySMB::Dcerpc::Ndr::NdrLpDword
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#lpcb_len' do
|
53
|
+
it 'is a NdrLpDword structure' do
|
54
|
+
expect(packet.lpcb_len).to be_a RubySMB::Dcerpc::Ndr::NdrLpDword
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#error_status' do
|
59
|
+
it 'is a 32-bit unsigned integer' do
|
60
|
+
expect(packet.error_status).to be_a BinData::Uint32le
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '#initialize_instance' do
|
65
|
+
it 'sets #opnum to REG_ENUM_VALUE constant' do
|
66
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Winreg::REG_ENUM_VALUE)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '#pad_length' do
|
71
|
+
it 'returns 0 when #lp_class is already 4-byte aligned' do
|
72
|
+
packet.lp_value_name = 'align'
|
73
|
+
expect(packet.pad_length).to eq 0
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'returns 2 when #lp_class is only 2-byte aligned' do
|
77
|
+
packet.lp_value_name = 'align' + 'A'
|
78
|
+
expect(packet.pad_length).to eq 2
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Winreg::RpcHkey do
|
2
|
+
it 'is NdrContextHandle subclass' do
|
3
|
+
expect(described_class).to be < RubySMB::Dcerpc::Ndr::NdrContextHandle
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
RSpec.describe RubySMB::Dcerpc::Winreg::OpenKeyRequest do
|
8
|
+
subject(:packet) { described_class.new }
|
9
|
+
|
10
|
+
it { is_expected.to respond_to :hkey }
|
11
|
+
it { is_expected.to respond_to :lp_sub_key }
|
12
|
+
it { is_expected.to respond_to :pad }
|
13
|
+
it { is_expected.to respond_to :dw_options }
|
14
|
+
it { is_expected.to respond_to :sam_desired }
|
15
|
+
it { is_expected.to respond_to :opnum }
|
16
|
+
|
17
|
+
it 'is little endian' do
|
18
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#hkey' do
|
22
|
+
it 'is a RpcHkey structure' do
|
23
|
+
expect(packet.hkey).to be_a RubySMB::Dcerpc::Winreg::RpcHkey
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#lp_sub_key' do
|
28
|
+
it 'is a RrpUnicodeString structure' do
|
29
|
+
expect(packet.lp_sub_key).to be_a RubySMB::Dcerpc::RrpUnicodeString
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#pad' do
|
34
|
+
it 'is a string' do
|
35
|
+
expect(packet.pad).to be_a BinData::String
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should keep #dw_options 4-byte aligned' do
|
39
|
+
packet.lp_sub_key = "test"
|
40
|
+
expect(packet.dw_options.abs_offset % 4).to eq 0
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#dw_options' do
|
45
|
+
it 'is a 32-bit unsigned integer' do
|
46
|
+
expect(packet.dw_options).to be_a BinData::Uint32le
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#sam_desired' do
|
51
|
+
it 'is a Regsam structure' do
|
52
|
+
expect(packet.sam_desired).to be_a RubySMB::Dcerpc::Winreg::Regsam
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#initialize_instance' do
|
57
|
+
it 'sets #opnum to REG_OPEN_KEY constant' do
|
58
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Winreg::REG_OPEN_KEY)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#pad_length' do
|
63
|
+
it 'returns 0 when #dw_options is already 4-byte aligned' do
|
64
|
+
packet.lp_sub_key = 'align'
|
65
|
+
expect(packet.pad_length).to eq 0
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'returns 2 when #dw_options is only 2-byte aligned' do
|
69
|
+
packet.lp_sub_key = 'align' + 'A'
|
70
|
+
expect(packet.pad_length).to eq 2
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Winreg::PrpcHkey do
|
2
|
+
it 'is NdrContextHandle subclass' do
|
3
|
+
expect(described_class).to be < RubySMB::Dcerpc::Ndr::NdrContextHandle
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
RSpec.describe RubySMB::Dcerpc::Winreg::OpenKeyResponse do
|
8
|
+
subject(:packet) { described_class.new }
|
9
|
+
|
10
|
+
it { is_expected.to respond_to :phk_result }
|
11
|
+
it { is_expected.to respond_to :error_status }
|
12
|
+
it { is_expected.to respond_to :opnum }
|
13
|
+
|
14
|
+
it 'is little endian' do
|
15
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#phk_result' do
|
19
|
+
it 'is a PrpcHkey structure' do
|
20
|
+
expect(packet.phk_result).to be_a RubySMB::Dcerpc::Winreg::PrpcHkey
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#error_status' do
|
25
|
+
it 'is a 32-bit unsigned integer' do
|
26
|
+
expect(packet.error_status).to be_a BinData::Uint32le
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#initialize_instance' do
|
31
|
+
it 'sets #opnum to REG_OPEN_KEY constant' do
|
32
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Winreg::REG_OPEN_KEY)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Winreg::PRegistryServerName do
|
2
|
+
it 'is NdrTopLevelFullPointer subclass' do
|
3
|
+
expect(described_class).to be < RubySMB::Dcerpc::Ndr::NdrTopLevelFullPointer
|
4
|
+
end
|
5
|
+
|
6
|
+
subject(:packet) { described_class.new }
|
7
|
+
|
8
|
+
it { is_expected.to respond_to :referent }
|
9
|
+
|
10
|
+
it 'is little endian' do
|
11
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#referent' do
|
15
|
+
it 'is a string in UTF-16LE' do
|
16
|
+
expect(packet.referent).to be_a RubySMB::Field::String16
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'reads 4-bytes' do
|
20
|
+
str = 'spec_test'.encode('utf-16le')
|
21
|
+
packet.referent.read(str)
|
22
|
+
expect(packet.referent.to_binary_s.bytes).to eq(str.bytes[0,4])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
RSpec.describe RubySMB::Dcerpc::Winreg::OpenRootKeyRequest do
|
28
|
+
subject(:packet) { described_class.new }
|
29
|
+
|
30
|
+
it { is_expected.to respond_to :p_registry_server_name }
|
31
|
+
it { is_expected.to respond_to :sam_desired }
|
32
|
+
it { is_expected.to respond_to :opnum }
|
33
|
+
|
34
|
+
it 'is little endian' do
|
35
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#p_registry_server_name' do
|
39
|
+
it 'is a PRegistryServerName structure' do
|
40
|
+
expect(packet.p_registry_server_name).to be_a RubySMB::Dcerpc::Winreg::PRegistryServerName
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#sam_desired' do
|
45
|
+
it 'is a Regsam structure' do
|
46
|
+
expect(packet.sam_desired).to be_a RubySMB::Dcerpc::Winreg::Regsam
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#initialize_instance' do
|
51
|
+
context 'when an #opnum parameter is provided' do
|
52
|
+
it 'sets #opnum to the parameter\'s value' do
|
53
|
+
packet = described_class.new(opnum: RubySMB::Dcerpc::Winreg::OPEN_HKLM)
|
54
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Winreg::OPEN_HKLM)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'sets #p_registry_server_name.referent to NULL unicode value' do
|
59
|
+
expect(packet.p_registry_server_name.referent).to eq("\0\0".encode('utf-16le'))
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'when #opnum is not OPEN_HKPD, OPEN_HKPT or OPEN_HKPN' do
|
63
|
+
it 'sets the #sam_desired.maximum flag' do
|
64
|
+
packet = described_class.new(opnum: RubySMB::Dcerpc::Winreg::OPEN_HKCR)
|
65
|
+
expect(packet.sam_desired.maximum).to eq(1)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'when #opnum is OPEN_HKPD' do
|
70
|
+
it 'does not set the #sam_desired.maximum flag' do
|
71
|
+
packet = described_class.new(opnum: RubySMB::Dcerpc::Winreg::OPEN_HKPD)
|
72
|
+
expect(packet.sam_desired.maximum).to eq(0)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'when #opnum is OPEN_HKPT' do
|
77
|
+
it 'does not set the #sam_desired.maximum flag' do
|
78
|
+
packet = described_class.new(opnum: RubySMB::Dcerpc::Winreg::OPEN_HKPT)
|
79
|
+
expect(packet.sam_desired.maximum).to eq(0)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'when #opnum is OPEN_HKPN' do
|
84
|
+
it 'does not set the #sam_desired.maximum flag' do
|
85
|
+
packet = described_class.new(opnum: RubySMB::Dcerpc::Winreg::OPEN_HKPN)
|
86
|
+
expect(packet.sam_desired.maximum).to eq(0)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Winreg::PrpcHkey do
|
2
|
+
it 'is NdrContextHandle subclass' do
|
3
|
+
expect(described_class).to be < RubySMB::Dcerpc::Ndr::NdrContextHandle
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
RSpec.describe RubySMB::Dcerpc::Winreg::OpenRootKeyResponse do
|
8
|
+
subject(:packet) { described_class.new }
|
9
|
+
|
10
|
+
it { is_expected.to respond_to :ph_key}
|
11
|
+
it { is_expected.to respond_to :error_status }
|
12
|
+
it { is_expected.to respond_to :opnum }
|
13
|
+
|
14
|
+
it 'is little endian' do
|
15
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#ph_key' do
|
19
|
+
it 'is a PrpcHkey structure' do
|
20
|
+
expect(packet.ph_key).to be_a RubySMB::Dcerpc::Winreg::PrpcHkey
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#error_status' do
|
25
|
+
it 'is a 32-bit unsigned integer' do
|
26
|
+
expect(packet.error_status).to be_a BinData::Uint32le
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#initialize_instance' do
|
31
|
+
context 'when an #opnum parameter is provided' do
|
32
|
+
it 'sets #opnum to the parameter\'s value' do
|
33
|
+
packet = described_class.new(opnum: RubySMB::Dcerpc::Winreg::OPEN_HKLM)
|
34
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Winreg::OPEN_HKLM)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Winreg::RpcHkey do
|
2
|
+
it 'is NdrContextHandle subclass' do
|
3
|
+
expect(described_class).to be < RubySMB::Dcerpc::Ndr::NdrContextHandle
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
RSpec.describe RubySMB::Dcerpc::Winreg::QueryInfoKeyRequest do
|
8
|
+
subject(:packet) { described_class.new }
|
9
|
+
|
10
|
+
it { is_expected.to respond_to :hkey }
|
11
|
+
it { is_expected.to respond_to :lp_class }
|
12
|
+
it { is_expected.to respond_to :opnum }
|
13
|
+
|
14
|
+
it 'is little endian' do
|
15
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#hkey' do
|
19
|
+
it 'is a RpcHkey structure' do
|
20
|
+
expect(packet.hkey).to be_a RubySMB::Dcerpc::Winreg::RpcHkey
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#lp_class' do
|
25
|
+
it 'is a RrpUnicodeString structure' do
|
26
|
+
expect(packet.lp_class).to be_a RubySMB::Dcerpc::RrpUnicodeString
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'has an initial value of 0' do
|
30
|
+
expect(packet.lp_class).to eq(0)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#initialize_instance' do
|
35
|
+
it 'sets #opnum to REG_QUERY_INFO_KEY constant' do
|
36
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Winreg::REG_QUERY_INFO_KEY)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|