ruby_smb 1.0.5 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.travis.yml +3 -2
- data/Gemfile +6 -2
- data/README.md +35 -47
- data/examples/anonymous_auth.rb +3 -3
- data/examples/append_file.rb +10 -8
- data/examples/authenticate.rb +9 -5
- data/examples/delete_file.rb +8 -6
- data/examples/enum_registry_key.rb +29 -0
- data/examples/enum_registry_values.rb +31 -0
- data/examples/list_directory.rb +8 -6
- data/examples/negotiate.rb +51 -8
- data/examples/negotiate_with_netbios_service.rb +9 -5
- data/examples/net_share_enum_all.rb +6 -4
- data/examples/pipes.rb +13 -13
- data/examples/query_service_status.rb +64 -0
- data/examples/read_file.rb +8 -6
- data/examples/read_file_encryption.rb +56 -0
- data/examples/read_registry_key_value.rb +33 -0
- data/examples/rename_file.rb +9 -7
- data/examples/tree_connect.rb +7 -5
- data/examples/write_file.rb +9 -7
- data/lib/ruby_smb.rb +4 -1
- data/lib/ruby_smb/client.rb +239 -21
- data/lib/ruby_smb/client/authentication.rb +27 -8
- data/lib/ruby_smb/client/encryption.rb +62 -0
- data/lib/ruby_smb/client/negotiation.rb +154 -12
- data/lib/ruby_smb/client/signing.rb +19 -0
- data/lib/ruby_smb/client/tree_connect.rb +4 -4
- data/lib/ruby_smb/client/utils.rb +8 -7
- data/lib/ruby_smb/client/winreg.rb +46 -0
- data/lib/ruby_smb/crypto.rb +30 -0
- data/lib/ruby_smb/dcerpc.rb +40 -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 +6 -0
- data/lib/ruby_smb/dcerpc/ndr.rb +260 -16
- data/lib/ruby_smb/dcerpc/pdu_header.rb +1 -1
- data/lib/ruby_smb/dcerpc/request.rb +41 -9
- data/lib/ruby_smb/dcerpc/rpc_security_attributes.rb +34 -0
- data/lib/ruby_smb/dcerpc/rrp_unicode_string.rb +38 -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/svcctl.rb +479 -0
- data/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_request.rb +48 -0
- data/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_response.rb +26 -0
- data/lib/ruby_smb/dcerpc/svcctl/close_service_handle_request.rb +25 -0
- data/lib/ruby_smb/dcerpc/svcctl/close_service_handle_response.rb +26 -0
- data/lib/ruby_smb/dcerpc/svcctl/control_service_request.rb +26 -0
- data/lib/ruby_smb/dcerpc/svcctl/control_service_response.rb +26 -0
- data/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_request.rb +35 -0
- data/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_response.rb +23 -0
- data/lib/ruby_smb/dcerpc/svcctl/open_service_w_request.rb +31 -0
- data/lib/ruby_smb/dcerpc/svcctl/open_service_w_response.rb +23 -0
- data/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_request.rb +25 -0
- data/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_response.rb +44 -0
- data/lib/ruby_smb/dcerpc/svcctl/query_service_status_request.rb +23 -0
- data/lib/ruby_smb/dcerpc/svcctl/query_service_status_response.rb +27 -0
- data/lib/ruby_smb/dcerpc/svcctl/service_status.rb +25 -0
- data/lib/ruby_smb/dcerpc/svcctl/start_service_w_request.rb +27 -0
- data/lib/ruby_smb/dcerpc/svcctl/start_service_w_response.rb +25 -0
- data/lib/ruby_smb/dcerpc/winreg.rb +421 -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/create_key_request.rb +73 -0
- data/lib/ruby_smb/dcerpc/winreg/create_key_response.rb +36 -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 +40 -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/dcerpc/winreg/save_key_request.rb +37 -0
- data/lib/ruby_smb/dcerpc/winreg/save_key_response.rb +23 -0
- data/lib/ruby_smb/dispatcher/base.rb +1 -1
- data/lib/ruby_smb/dispatcher/socket.rb +5 -4
- data/lib/ruby_smb/error.rb +28 -1
- data/lib/ruby_smb/field/stringz16.rb +17 -1
- data/lib/ruby_smb/nbss/session_header.rb +4 -4
- data/lib/ruby_smb/smb1/commands.rb +1 -1
- data/lib/ruby_smb/smb1/file.rb +8 -14
- data/lib/ruby_smb/smb1/packet/session_setup_legacy_request.rb +1 -1
- data/lib/ruby_smb/smb1/packet/session_setup_legacy_response.rb +2 -2
- data/lib/ruby_smb/smb1/packet/session_setup_request.rb +1 -1
- data/lib/ruby_smb/smb1/packet/session_setup_response.rb +2 -2
- data/lib/ruby_smb/smb1/packet/write_andx_request.rb +1 -1
- data/lib/ruby_smb/smb1/pipe.rb +81 -3
- data/lib/ruby_smb/smb1/tree.rb +12 -3
- data/lib/ruby_smb/smb2/bit_field/session_flags.rb +2 -1
- data/lib/ruby_smb/smb2/bit_field/share_flags.rb +6 -4
- data/lib/ruby_smb/smb2/file.rb +51 -61
- data/lib/ruby_smb/smb2/negotiate_context.rb +108 -0
- data/lib/ruby_smb/smb2/packet.rb +2 -0
- data/lib/ruby_smb/smb2/packet/compression_transform_header.rb +41 -0
- data/lib/ruby_smb/smb2/packet/error_packet.rb +2 -4
- data/lib/ruby_smb/smb2/packet/negotiate_request.rb +51 -14
- data/lib/ruby_smb/smb2/packet/negotiate_response.rb +50 -4
- data/lib/ruby_smb/smb2/packet/transform_header.rb +84 -0
- data/lib/ruby_smb/smb2/packet/tree_connect_request.rb +92 -6
- data/lib/ruby_smb/smb2/packet/tree_connect_response.rb +8 -26
- data/lib/ruby_smb/smb2/pipe.rb +80 -3
- data/lib/ruby_smb/smb2/smb2_header.rb +1 -1
- data/lib/ruby_smb/smb2/tree.rb +32 -20
- data/lib/ruby_smb/version.rb +1 -1
- data/ruby_smb.gemspec +5 -3
- data/spec/lib/ruby_smb/client_spec.rb +1583 -102
- data/spec/lib/ruby_smb/crypto_spec.rb +25 -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 +1729 -0
- data/spec/lib/ruby_smb/dcerpc/request_spec.rb +50 -7
- data/spec/lib/ruby_smb/dcerpc/rpc_security_attributes_spec.rb +161 -0
- data/spec/lib/ruby_smb/dcerpc/rrp_unicode_string_spec.rb +135 -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/svcctl/change_service_config_w_request_spec.rb +191 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_response_spec.rb +38 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/close_service_handle_request_spec.rb +30 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/close_service_handle_response_spec.rb +38 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/control_service_request_spec.rb +39 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/control_service_response_spec.rb +38 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_request_spec.rb +78 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_response_spec.rb +38 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/open_service_w_request_spec.rb +59 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/open_service_w_response_spec.rb +38 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_request_spec.rb +38 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_response_spec.rb +152 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_status_request_spec.rb +30 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_status_response_spec.rb +38 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/service_status_spec.rb +72 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/start_service_w_request_spec.rb +46 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/start_service_w_response_spec.rb +30 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl_spec.rb +512 -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/create_key_request_spec.rb +110 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/create_key_response_spec.rb +44 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/enum_key_request_spec.rb +104 -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 +95 -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 +35 -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 +138 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/regsam_spec.rb +32 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/save_key_request_spec.rb +57 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/save_key_response_spec.rb +22 -0
- data/spec/lib/ruby_smb/dcerpc/winreg_spec.rb +884 -0
- data/spec/lib/ruby_smb/dcerpc_spec.rb +81 -0
- data/spec/lib/ruby_smb/dispatcher/socket_spec.rb +12 -12
- data/spec/lib/ruby_smb/error_spec.rb +59 -0
- data/spec/lib/ruby_smb/field/stringz16_spec.rb +12 -0
- data/spec/lib/ruby_smb/nbss/session_header_spec.rb +4 -11
- data/spec/lib/ruby_smb/smb1/file_spec.rb +9 -1
- data/spec/lib/ruby_smb/smb1/packet/session_setup_legacy_request_spec.rb +2 -2
- data/spec/lib/ruby_smb/smb1/packet/session_setup_legacy_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/smb1/packet/session_setup_request_spec.rb +2 -2
- data/spec/lib/ruby_smb/smb1/packet/session_setup_response_spec.rb +1 -1
- data/spec/lib/ruby_smb/smb1/pipe_spec.rb +216 -147
- data/spec/lib/ruby_smb/smb2/bit_field/session_flags_spec.rb +9 -0
- data/spec/lib/ruby_smb/smb2/bit_field/share_flags_spec.rb +27 -0
- data/spec/lib/ruby_smb/smb2/file_spec.rb +146 -68
- data/spec/lib/ruby_smb/smb2/negotiate_context_spec.rb +332 -0
- data/spec/lib/ruby_smb/smb2/packet/compression_transform_header_spec.rb +108 -0
- data/spec/lib/ruby_smb/smb2/packet/error_packet_spec.rb +3 -24
- data/spec/lib/ruby_smb/smb2/packet/negotiate_request_spec.rb +138 -3
- data/spec/lib/ruby_smb/smb2/packet/negotiate_response_spec.rb +120 -2
- data/spec/lib/ruby_smb/smb2/packet/transform_header_spec.rb +220 -0
- data/spec/lib/ruby_smb/smb2/packet/tree_connect_request_spec.rb +339 -9
- data/spec/lib/ruby_smb/smb2/packet/tree_connect_response_spec.rb +3 -30
- data/spec/lib/ruby_smb/smb2/pipe_spec.rb +226 -148
- data/spec/lib/ruby_smb/smb2/smb2_header_spec.rb +2 -2
- data/spec/lib/ruby_smb/smb2/tree_spec.rb +88 -9
- metadata +257 -81
- 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,28 @@
|
|
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::CloseKeyRequest do
|
8
|
+
subject(:packet) { described_class.new }
|
9
|
+
|
10
|
+
it { is_expected.to respond_to :hkey }
|
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 '#hkey' do
|
18
|
+
it 'is a RpcHkey structure' do
|
19
|
+
expect(packet.hkey).to be_a RubySMB::Dcerpc::Winreg::RpcHkey
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#initialize_instance' do
|
24
|
+
it 'sets #opnum to REG_CLOSE_KEY constant' do
|
25
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Winreg::REG_CLOSE_KEY)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,36 @@
|
|
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::CloseKeyResponse do
|
8
|
+
subject(:packet) { described_class.new }
|
9
|
+
|
10
|
+
it { is_expected.to respond_to :hkey }
|
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 '#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 '#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_CLOSE_KEY constant' do
|
32
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Winreg::REG_CLOSE_KEY)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
@@ -0,0 +1,110 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Winreg::RpcHkey do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it 'is NdrContextHandle subclass' do
|
5
|
+
expect(described_class).to be < RubySMB::Dcerpc::Ndr::NdrContextHandle
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
RSpec.describe RubySMB::Dcerpc::Winreg::CreateKeyRequest do
|
10
|
+
subject(:packet) { described_class.new }
|
11
|
+
|
12
|
+
|
13
|
+
it 'is little endian' do
|
14
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
15
|
+
end
|
16
|
+
|
17
|
+
it { is_expected.to respond_to :hkey }
|
18
|
+
it { is_expected.to respond_to :lp_sub_key }
|
19
|
+
it { is_expected.to respond_to :pad1 }
|
20
|
+
it { is_expected.to respond_to :lp_class }
|
21
|
+
it { is_expected.to respond_to :pad2 }
|
22
|
+
it { is_expected.to respond_to :dw_options }
|
23
|
+
it { is_expected.to respond_to :sam_desired }
|
24
|
+
it { is_expected.to respond_to :lp_security_attributes }
|
25
|
+
it { is_expected.to respond_to :pad3 }
|
26
|
+
it { is_expected.to respond_to :lpdw_disposition }
|
27
|
+
|
28
|
+
describe '#hkey' do
|
29
|
+
it 'is a RpcHkey structure' do
|
30
|
+
expect(packet.hkey).to be_a RubySMB::Dcerpc::Winreg::RpcHkey
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#lp_sub_key' do
|
35
|
+
it 'is a RrpUnicodeString structure' do
|
36
|
+
expect(packet.lp_sub_key).to be_a RubySMB::Dcerpc::RrpUnicodeString
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#pad1' do
|
41
|
+
it 'is a string' do
|
42
|
+
expect(packet.pad1).to be_a BinData::String
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should keep #lp_class 4-byte aligned' do
|
46
|
+
packet.lp_sub_key = "test"
|
47
|
+
expect(packet.lp_class.abs_offset % 4).to eq 0
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#lp_class' do
|
52
|
+
it 'is a RrpUnicodeString structure' do
|
53
|
+
expect(packet.lp_class).to be_a RubySMB::Dcerpc::RrpUnicodeString
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#pad2' do
|
58
|
+
it 'is a string' do
|
59
|
+
expect(packet.pad1).to be_a BinData::String
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should keep #dw_options 4-byte aligned' do
|
63
|
+
packet.lp_class = "test"
|
64
|
+
expect(packet.dw_options.abs_offset % 4).to eq 0
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '#dw_options' do
|
69
|
+
it 'is a 32-bit unsigned integer' do
|
70
|
+
expect(packet.dw_options).to be_a BinData::Uint32le
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '#sam_desired' do
|
75
|
+
it 'is a Regsam structure' do
|
76
|
+
expect(packet.sam_desired).to be_a RubySMB::Dcerpc::Winreg::Regsam
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '#lp_security_attributes' do
|
81
|
+
it 'is a PrpcSecurityAttributes structure' do
|
82
|
+
expect(packet.lp_security_attributes).to be_a RubySMB::Dcerpc::PrpcSecurityAttributes
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '#pad3' do
|
87
|
+
it 'is a string' do
|
88
|
+
expect(packet.pad1).to be_a BinData::String
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'should keep #lpdw_disposition 4-byte aligned' do
|
92
|
+
sc = RubySMB::Dcerpc::RpcSecurityDescriptor.new(lp_security_descriptor: [1,2,3,4])
|
93
|
+
packet.lp_security_attributes = RubySMB::Dcerpc::RpcSecurityAttributes.new(rpc_security_descriptor: sc)
|
94
|
+
expect(packet.lpdw_disposition.abs_offset % 4).to eq 0
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe '#lpdw_disposition' do
|
99
|
+
it 'is a NdrLpDword structure' do
|
100
|
+
expect(packet.lpdw_disposition).to be_a RubySMB::Dcerpc::Ndr::NdrLpDword
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe '#initialize_instance' do
|
105
|
+
it 'sets #opnum to REG_CREATE_KEY constant' do
|
106
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Winreg::REG_CREATE_KEY)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Winreg::PrpcHkey do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it 'is NdrContextHandle subclass' do
|
5
|
+
expect(described_class).to be < RubySMB::Dcerpc::Ndr::NdrContextHandle
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
RSpec.describe RubySMB::Dcerpc::Winreg::CreateKeyResponse do
|
10
|
+
subject(:packet) { described_class.new }
|
11
|
+
|
12
|
+
it { is_expected.to respond_to :hkey }
|
13
|
+
it { is_expected.to respond_to :lpdw_disposition }
|
14
|
+
it { is_expected.to respond_to :error_status }
|
15
|
+
|
16
|
+
it 'is little endian' do
|
17
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#hkey' do
|
21
|
+
it 'is a PrpcHkey structure' do
|
22
|
+
expect(packet.hkey).to be_a RubySMB::Dcerpc::Winreg::PrpcHkey
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#lpdw_disposition' do
|
27
|
+
it 'is a NdrLpDword structure' do
|
28
|
+
expect(packet.lpdw_disposition).to be_a RubySMB::Dcerpc::Ndr::NdrLpDword
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#error_status' do
|
33
|
+
it 'is a 32-bit unsigned integer' do
|
34
|
+
expect(packet.error_status).to be_a BinData::Uint32le
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#initialize_instance' do
|
39
|
+
it 'sets #opnum to REG_CREATE_KEY constant' do
|
40
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Winreg::REG_CREATE_KEY)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
@@ -0,0 +1,104 @@
|
|
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::EnumKeyRequest 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_name }
|
13
|
+
it { is_expected.to respond_to :pad1 }
|
14
|
+
it { is_expected.to respond_to :lp_class }
|
15
|
+
it { is_expected.to respond_to :pad2 }
|
16
|
+
it { is_expected.to respond_to :lpft_last_write_time }
|
17
|
+
it { is_expected.to respond_to :opnum }
|
18
|
+
|
19
|
+
it 'is little endian' do
|
20
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#hkey' do
|
24
|
+
it 'is a RpcHkey structure' do
|
25
|
+
expect(packet.hkey).to be_a RubySMB::Dcerpc::Winreg::RpcHkey
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#dw_index' do
|
30
|
+
it 'is a 32-bit unsigned integer' do
|
31
|
+
expect(packet.dw_index).to be_a BinData::Uint32le
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#lp_name' do
|
36
|
+
it 'is a RrpUnicodeString structure' do
|
37
|
+
expect(packet.lp_name).to be_a RubySMB::Dcerpc::RrpUnicodeString
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#pad1' do
|
42
|
+
it 'is a string' do
|
43
|
+
expect(packet.pad1).to be_a BinData::String
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should keep #lp_class 4-byte aligned' do
|
47
|
+
packet.lp_name = "test"
|
48
|
+
expect(packet.lp_class.abs_offset % 4).to eq 0
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#lp_class' do
|
53
|
+
it 'is a PrrpUnicodeString structure' do
|
54
|
+
expect(packet.lp_class).to be_a RubySMB::Dcerpc::PrrpUnicodeString
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#pad2' do
|
59
|
+
it 'is a string' do
|
60
|
+
expect(packet.pad2).to be_a BinData::String
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should keep #lpft_last_write_time 4-byte aligned' do
|
64
|
+
packet.lp_class = "test"
|
65
|
+
expect(packet.lpft_last_write_time.abs_offset % 4).to eq 0
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#lpft_last_write_time' do
|
70
|
+
it 'is a NdrLpFileTime structure' do
|
71
|
+
expect(packet.lpft_last_write_time).to be_a RubySMB::Dcerpc::Ndr::NdrLpFileTime
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#initialize_instance' do
|
76
|
+
it 'sets #opnum to REG_ENUM_KEY constant' do
|
77
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Winreg::REG_ENUM_KEY)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#pad_length1' do
|
82
|
+
it 'returns 0 when #lp_class is already 4-byte aligned' do
|
83
|
+
packet.lp_name = 'align'
|
84
|
+
expect(packet.pad_length1).to eq 0
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'returns 2 when #lp_class is only 2-byte aligned' do
|
88
|
+
packet.lp_name = 'align' + 'A'
|
89
|
+
expect(packet.pad_length1).to eq 2
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe '#pad_length2' do
|
94
|
+
it 'returns 0 when #lpft_last_write_time is already 4-byte aligned' do
|
95
|
+
packet.lp_class = 'align'
|
96
|
+
expect(packet.pad_length2).to eq 0
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'returns 2 when #lpft_last_write_time is only 2-byte aligned' do
|
100
|
+
packet.lp_class = 'align' + 'A'
|
101
|
+
expect(packet.pad_length2).to eq 2
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Winreg::EnumKeyResponse do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :lp_name }
|
5
|
+
it { is_expected.to respond_to :pad1 }
|
6
|
+
it { is_expected.to respond_to :lp_class }
|
7
|
+
it { is_expected.to respond_to :pad2 }
|
8
|
+
it { is_expected.to respond_to :lpft_last_write_time }
|
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
|
+
|
16
|
+
|
17
|
+
describe '#lp_name' do
|
18
|
+
it 'is a RrpUnicodeString structure' do
|
19
|
+
expect(packet.lp_name).to be_a RubySMB::Dcerpc::RrpUnicodeString
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#pad1' do
|
24
|
+
it 'is a string' do
|
25
|
+
expect(packet.pad1).to be_a BinData::String
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should keep #lp_class 4-byte aligned' do
|
29
|
+
packet.lp_name = "test"
|
30
|
+
expect(packet.lp_class.abs_offset % 4).to eq 0
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#lp_class' do
|
35
|
+
it 'is a PrrpUnicodeString structure' do
|
36
|
+
expect(packet.lp_class).to be_a RubySMB::Dcerpc::PrrpUnicodeString
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'has a initial value of 0' do
|
40
|
+
expect(packet.lp_class).to eq(0)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#pad2' do
|
45
|
+
it 'is a string' do
|
46
|
+
expect(packet.pad2).to be_a BinData::String
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should keep #lpft_last_write_time 4-byte aligned' do
|
50
|
+
packet.lp_class = "test"
|
51
|
+
expect(packet.lpft_last_write_time.abs_offset % 4).to eq 0
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#lpft_last_write_time' do
|
56
|
+
it 'is a NdrLpFileTime structure' do
|
57
|
+
expect(packet.lpft_last_write_time).to be_a RubySMB::Dcerpc::Ndr::NdrLpFileTime
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#error_status' do
|
62
|
+
it 'is a 32-bit unsigned integer' do
|
63
|
+
expect(packet.error_status).to be_a BinData::Uint32le
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#initialize_instance' do
|
68
|
+
it 'sets #opnum to REG_ENUM_KEY constant' do
|
69
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Winreg::REG_ENUM_KEY)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '#pad_length1' do
|
74
|
+
it 'returns 0 when #lp_class is already 4-byte aligned' do
|
75
|
+
packet.lp_name = 'align'
|
76
|
+
expect(packet.pad_length1).to eq 0
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'returns 2 when #lp_class is only 2-byte aligned' do
|
80
|
+
packet.lp_name = 'align' + 'A'
|
81
|
+
expect(packet.pad_length1).to eq 2
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '#pad_length2' do
|
86
|
+
it 'returns 0 when #lpft_last_write_time is already 4-byte aligned' do
|
87
|
+
packet.lp_class = 'align'
|
88
|
+
expect(packet.pad_length2).to eq 0
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'returns 2 when #lpft_last_write_time is only 2-byte aligned' do
|
92
|
+
packet.lp_class = 'align' + 'A'
|
93
|
+
expect(packet.pad_length2).to eq 2
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
@@ -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 NdrLpByteArray structure' do
|
61
|
+
expect(packet.lp_data).to be_a RubySMB::Dcerpc::Ndr::NdrLpByteArray
|
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
|