ruby_smb 2.0.12 → 2.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.github/workflows/verify.yml +1 -1
- data/examples/dump_secrets_from_sid.rb +207 -0
- data/examples/enum_domain_users.rb +75 -0
- data/examples/get_computer_info.rb +42 -0
- data/examples/query_service_status.rb +42 -4
- data/lib/ruby_smb/client.rb +3 -14
- data/lib/ruby_smb/dcerpc/bind.rb +28 -20
- data/lib/ruby_smb/dcerpc/bind_ack.rb +29 -28
- data/lib/ruby_smb/dcerpc/client.rb +542 -0
- data/lib/ruby_smb/dcerpc/drsr/drs_bind_request.rb +24 -0
- data/lib/ruby_smb/dcerpc/drsr/drs_bind_response.rb +26 -0
- data/lib/ruby_smb/dcerpc/drsr/drs_crack_names_request.rb +57 -0
- data/lib/ruby_smb/dcerpc/drsr/drs_crack_names_response.rb +76 -0
- data/lib/ruby_smb/dcerpc/drsr/drs_domain_controller_info_request.rb +46 -0
- data/lib/ruby_smb/dcerpc/drsr/drs_domain_controller_info_response.rb +168 -0
- data/lib/ruby_smb/dcerpc/drsr/drs_extensions.rb +56 -0
- data/lib/ruby_smb/dcerpc/drsr/drs_get_nc_changes_request.rb +121 -0
- data/lib/ruby_smb/dcerpc/drsr/drs_get_nc_changes_response.rb +118 -0
- data/lib/ruby_smb/dcerpc/drsr/drs_unbind_request.rb +24 -0
- data/lib/ruby_smb/dcerpc/drsr/drs_unbind_response.rb +26 -0
- data/lib/ruby_smb/dcerpc/drsr.rb +909 -0
- data/lib/ruby_smb/dcerpc/epm/epm_ept_map_request.rb +26 -0
- data/lib/ruby_smb/dcerpc/epm/epm_ept_map_response.rb +25 -0
- data/lib/ruby_smb/dcerpc/epm/epm_twrt.rb +211 -0
- data/lib/ruby_smb/dcerpc/epm.rb +75 -0
- data/lib/ruby_smb/dcerpc/error.rb +17 -0
- data/lib/ruby_smb/dcerpc/ndr.rb +1159 -297
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_request.rb +3 -13
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_response.rb +3 -3
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_request.rb +3 -13
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_response.rb +1 -1
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_request.rb +3 -11
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_response.rb +1 -1
- data/lib/ruby_smb/dcerpc/netlogon.rb +5 -4
- data/lib/ruby_smb/dcerpc/p_syntax_id_t.rb +4 -3
- data/lib/ruby_smb/dcerpc/pdu_header.rb +7 -7
- data/lib/ruby_smb/dcerpc/ptypes.rb +1 -0
- data/lib/ruby_smb/dcerpc/request.rb +79 -32
- data/lib/ruby_smb/dcerpc/response.rb +45 -10
- data/lib/ruby_smb/dcerpc/rpc_auth3.rb +28 -0
- data/lib/ruby_smb/dcerpc/rpc_security_attributes.rb +11 -11
- data/lib/ruby_smb/dcerpc/rrp_rpc_unicode_string.rb +118 -0
- data/lib/ruby_smb/dcerpc/samr/rpc_sid.rb +150 -0
- data/lib/ruby_smb/dcerpc/samr/samr_close_handle_request.rb +23 -0
- data/lib/ruby_smb/dcerpc/samr/samr_close_handle_response.rb +24 -0
- data/lib/ruby_smb/dcerpc/samr/samr_connect_request.rb +32 -0
- data/lib/ruby_smb/dcerpc/samr/samr_connect_response.rb +23 -0
- data/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_request.rb +26 -0
- data/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_response.rb +55 -0
- data/lib/ruby_smb/dcerpc/samr/samr_get_alias_membership_request.rb +48 -0
- data/lib/ruby_smb/dcerpc/samr/samr_get_alias_membership_response.rb +38 -0
- data/lib/ruby_smb/dcerpc/samr/samr_get_groups_for_user_request.rb +23 -0
- data/lib/ruby_smb/dcerpc/samr/samr_get_groups_for_user_response.rb +48 -0
- data/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_request.rb +24 -0
- data/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_response.rb +25 -0
- data/lib/ruby_smb/dcerpc/samr/samr_open_domain_request.rb +27 -0
- data/lib/ruby_smb/dcerpc/samr/samr_open_domain_response.rb +24 -0
- data/lib/ruby_smb/dcerpc/samr/samr_open_user_request.rb +26 -0
- data/lib/ruby_smb/dcerpc/samr/samr_open_user_response.rb +24 -0
- data/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_request.rb +23 -0
- data/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_response.rb +23 -0
- data/lib/ruby_smb/dcerpc/samr.rb +613 -0
- data/lib/ruby_smb/dcerpc/sec_trailer.rb +26 -0
- data/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all.rb +56 -79
- data/lib/ruby_smb/dcerpc/srvsvc.rb +27 -4
- data/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_request.rb +13 -25
- data/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_response.rb +2 -2
- data/lib/ruby_smb/dcerpc/svcctl/close_service_handle_response.rb +1 -1
- data/lib/ruby_smb/dcerpc/svcctl/control_service_request.rb +1 -1
- data/lib/ruby_smb/dcerpc/svcctl/control_service_response.rb +1 -1
- data/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_request.rb +4 -14
- data/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_response.rb +1 -1
- data/lib/ruby_smb/dcerpc/svcctl/open_service_w_request.rb +3 -11
- data/lib/ruby_smb/dcerpc/svcctl/open_service_w_response.rb +1 -1
- data/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_request.rb +1 -1
- data/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_response.rb +12 -11
- data/lib/ruby_smb/dcerpc/svcctl/query_service_status_response.rb +1 -1
- data/lib/ruby_smb/dcerpc/svcctl/service_status.rb +9 -8
- data/lib/ruby_smb/dcerpc/svcctl/start_service_w_request.rb +3 -3
- data/lib/ruby_smb/dcerpc/svcctl/start_service_w_response.rb +1 -1
- data/lib/ruby_smb/dcerpc/svcctl.rb +1 -3
- data/lib/ruby_smb/dcerpc/uuid.rb +3 -0
- data/lib/ruby_smb/dcerpc/winreg/close_key_response.rb +2 -2
- data/lib/ruby_smb/dcerpc/winreg/create_key_request.rb +2 -13
- data/lib/ruby_smb/dcerpc/winreg/create_key_response.rb +3 -3
- data/lib/ruby_smb/dcerpc/winreg/enum_key_request.rb +3 -20
- data/lib/ruby_smb/dcerpc/winreg/enum_key_response.rb +3 -20
- data/lib/ruby_smb/dcerpc/winreg/enum_value_request.rb +5 -14
- data/lib/ruby_smb/dcerpc/winreg/enum_value_response.rb +5 -14
- data/lib/ruby_smb/dcerpc/winreg/open_key_request.rb +1 -9
- data/lib/ruby_smb/dcerpc/winreg/open_key_response.rb +4 -3
- data/lib/ruby_smb/dcerpc/winreg/open_root_key_request.rb +5 -6
- data/lib/ruby_smb/dcerpc/winreg/open_root_key_response.rb +2 -2
- data/lib/ruby_smb/dcerpc/winreg/query_info_key_response.rb +9 -18
- data/lib/ruby_smb/dcerpc/winreg/query_value_request.rb +4 -14
- data/lib/ruby_smb/dcerpc/winreg/query_value_response.rb +7 -15
- data/lib/ruby_smb/dcerpc/winreg/regsam.rb +3 -1
- data/lib/ruby_smb/dcerpc/winreg/save_key_request.rb +0 -9
- data/lib/ruby_smb/dcerpc/winreg/save_key_response.rb +1 -1
- data/lib/ruby_smb/dcerpc/winreg.rb +10 -14
- data/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_request.rb +26 -0
- data/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_response.rb +88 -0
- data/lib/ruby_smb/dcerpc/wkssvc.rb +65 -0
- data/lib/ruby_smb/dcerpc.rb +41 -11
- data/lib/ruby_smb/field/file_time.rb +1 -1
- data/lib/ruby_smb/field/string16.rb +5 -1
- data/lib/ruby_smb/ntlm.rb +18 -2
- data/lib/ruby_smb/smb1/pipe.rb +4 -0
- data/lib/ruby_smb/smb2/pipe.rb +4 -0
- data/lib/ruby_smb/version.rb +1 -1
- data/spec/lib/ruby_smb/client_spec.rb +1 -2
- data/spec/lib/ruby_smb/dcerpc/bind_ack_spec.rb +69 -41
- data/spec/lib/ruby_smb/dcerpc/bind_spec.rb +75 -21
- data/spec/lib/ruby_smb/dcerpc/client_spec.rb +714 -0
- data/spec/lib/ruby_smb/dcerpc/drsr_spec.rb +2169 -0
- data/spec/lib/ruby_smb/dcerpc/ndr_spec.rb +3792 -1373
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_request_spec.rb +4 -4
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_request_spec.rb +4 -4
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_request_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/p_syntax_id_t_spec.rb +18 -4
- data/spec/lib/ruby_smb/dcerpc/pdu_header_spec.rb +27 -1
- data/spec/lib/ruby_smb/dcerpc/request_spec.rb +76 -11
- data/spec/lib/ruby_smb/dcerpc/response_spec.rb +99 -9
- data/spec/lib/ruby_smb/dcerpc/rpc_auth3_spec.rb +75 -0
- data/spec/lib/ruby_smb/dcerpc/rpc_security_attributes_spec.rb +29 -28
- data/spec/lib/ruby_smb/dcerpc/rrp_rpc_unicode_string_spec.rb +340 -0
- data/spec/lib/ruby_smb/dcerpc/samr/rpc_sid_spec.rb +116 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_close_handle_request_spec.rb +40 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_close_handle_response_spec.rb +48 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_connect_request_spec.rb +56 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_connect_response_spec.rb +47 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_request_spec.rb +63 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_response_spec.rb +265 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_request_spec.rb +52 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_response_spec.rb +36 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_open_domain_request_spec.rb +56 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_open_domain_response_spec.rb +48 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_request_spec.rb +48 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_response_spec.rb +42 -0
- data/spec/lib/ruby_smb/dcerpc/samr_spec.rb +420 -0
- data/spec/lib/ruby_smb/dcerpc/sec_trailer_spec.rb +92 -0
- data/spec/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all_spec.rb +149 -110
- data/spec/lib/ruby_smb/dcerpc/srvsvc_spec.rb +21 -17
- data/spec/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_request_spec.rb +56 -79
- data/spec/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_response_spec.rb +4 -4
- data/spec/lib/ruby_smb/dcerpc/svcctl/close_service_handle_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/svcctl/control_service_request_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/svcctl/control_service_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_request_spec.rb +19 -29
- data/spec/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/svcctl/open_service_w_request_spec.rb +9 -15
- data/spec/lib/ruby_smb/dcerpc/svcctl/open_service_w_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_request_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_response_spec.rb +22 -22
- data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_status_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/svcctl/service_status_spec.rb +18 -14
- data/spec/lib/ruby_smb/dcerpc/svcctl/start_service_w_request_spec.rb +5 -4
- data/spec/lib/ruby_smb/dcerpc/svcctl/start_service_w_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/svcctl_spec.rb +1 -5
- data/spec/lib/ruby_smb/dcerpc/uuid_spec.rb +15 -23
- data/spec/lib/ruby_smb/dcerpc/winreg/close_key_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/winreg/create_key_request_spec.rb +4 -41
- data/spec/lib/ruby_smb/dcerpc/winreg/create_key_response_spec.rb +4 -4
- data/spec/lib/ruby_smb/dcerpc/winreg/enum_key_request_spec.rb +4 -52
- data/spec/lib/ruby_smb/dcerpc/winreg/enum_key_response_spec.rb +4 -56
- data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_request_spec.rb +10 -34
- data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_response_spec.rb +10 -34
- data/spec/lib/ruby_smb/dcerpc/winreg/open_key_request_spec.rb +2 -26
- data/spec/lib/ruby_smb/dcerpc/winreg/open_key_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_request_spec.rb +17 -25
- data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/winreg/query_info_key_response_spec.rb +20 -44
- data/spec/lib/ruby_smb/dcerpc/winreg/query_value_request_spec.rb +8 -32
- data/spec/lib/ruby_smb/dcerpc/winreg/query_value_response_spec.rb +10 -22
- data/spec/lib/ruby_smb/dcerpc/winreg/regsam_spec.rb +4 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/save_key_request_spec.rb +0 -12
- data/spec/lib/ruby_smb/dcerpc/winreg/save_key_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/winreg_spec.rb +18 -47
- data/spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_request_spec.rb +43 -0
- data/spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_response_spec.rb +410 -0
- data/spec/lib/ruby_smb/dcerpc/wkssvc_spec.rb +70 -0
- data/spec/lib/ruby_smb/field/string16_spec.rb +22 -0
- data/spec/lib/ruby_smb/gss/provider/ntlm/os_version_spec.rb +1 -1
- data/spec/lib/ruby_smb/smb1/pipe_spec.rb +18 -37
- data/spec/lib/ruby_smb/smb2/pipe_spec.rb +18 -16
- data/spec/support/bin_helper.rb +9 -0
- data.tar.gz.sig +0 -0
- metadata +96 -5
- metadata.gz.sig +0 -0
- data/lib/ruby_smb/dcerpc/rrp_unicode_string.rb +0 -38
- data/spec/lib/ruby_smb/dcerpc/rrp_unicode_string_spec.rb +0 -135
@@ -3,7 +3,6 @@ RSpec.describe RubySMB::Dcerpc::Winreg::QueryValueResponse do
|
|
3
3
|
|
4
4
|
it { is_expected.to respond_to :lp_type }
|
5
5
|
it { is_expected.to respond_to :lp_data }
|
6
|
-
it { is_expected.to respond_to :pad }
|
7
6
|
it { is_expected.to respond_to :lpcb_data }
|
8
7
|
it { is_expected.to respond_to :lpcb_len }
|
9
8
|
it { is_expected.to respond_to :error_status }
|
@@ -14,43 +13,32 @@ RSpec.describe RubySMB::Dcerpc::Winreg::QueryValueResponse do
|
|
14
13
|
end
|
15
14
|
|
16
15
|
describe '#lp_type' do
|
17
|
-
it 'is a
|
18
|
-
expect(packet.lp_type).to be_a RubySMB::Dcerpc::Ndr::
|
16
|
+
it 'is a Ndr::NdrUint32Ptr structure' do
|
17
|
+
expect(packet.lp_type).to be_a RubySMB::Dcerpc::Ndr::NdrUint32Ptr
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
22
21
|
describe '#lp_data' do
|
23
|
-
it 'is a
|
24
|
-
expect(packet.lp_data).to be_a RubySMB::Dcerpc::Ndr::
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#pad' do
|
29
|
-
it 'is a string' do
|
30
|
-
expect(packet.pad).to be_a BinData::String
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should keep #lpcb_data 4-byte aligned' do
|
34
|
-
packet.lp_data = 'spec_test'.bytes
|
35
|
-
expect(packet.lpcb_data.abs_offset % 4).to eq 0
|
22
|
+
it 'is a NdrNdrByteArrayPtr structure' do
|
23
|
+
expect(packet.lp_data).to be_a RubySMB::Dcerpc::Ndr::NdrByteArrayPtr
|
36
24
|
end
|
37
25
|
end
|
38
26
|
|
39
27
|
describe '#lpcb_data' do
|
40
|
-
it 'is a
|
41
|
-
expect(packet.lpcb_data).to be_a RubySMB::Dcerpc::Ndr::
|
28
|
+
it 'is a Ndr::NdrUint32Ptr structure' do
|
29
|
+
expect(packet.lpcb_data).to be_a RubySMB::Dcerpc::Ndr::NdrUint32Ptr
|
42
30
|
end
|
43
31
|
end
|
44
32
|
|
45
33
|
describe '#lpcb_len' do
|
46
|
-
it 'is a
|
47
|
-
expect(packet.lpcb_len).to be_a RubySMB::Dcerpc::Ndr::
|
34
|
+
it 'is a Ndr::NdrUint32Ptr structure' do
|
35
|
+
expect(packet.lpcb_len).to be_a RubySMB::Dcerpc::Ndr::NdrUint32Ptr
|
48
36
|
end
|
49
37
|
end
|
50
38
|
|
51
39
|
describe '#error_status' do
|
52
|
-
it 'is a
|
53
|
-
expect(packet.error_status).to be_a
|
40
|
+
it 'is a NdrUint32' do
|
41
|
+
expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
54
42
|
end
|
55
43
|
end
|
56
44
|
|
@@ -29,4 +29,8 @@ RSpec.describe RubySMB::Dcerpc::Winreg::Regsam do
|
|
29
29
|
it 'is little endian' do
|
30
30
|
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
31
31
|
end
|
32
|
+
|
33
|
+
it 'it is a Ndr::NdrStruct' do
|
34
|
+
expect(described_class).to be < RubySMB::Dcerpc::Ndr::NdrStruct
|
35
|
+
end
|
32
36
|
end
|
@@ -16,7 +16,6 @@ RSpec.describe RubySMB::Dcerpc::Winreg::SaveKeyRequest do
|
|
16
16
|
|
17
17
|
it { is_expected.to respond_to :hkey }
|
18
18
|
it { is_expected.to respond_to :lp_file }
|
19
|
-
it { is_expected.to respond_to :pad }
|
20
19
|
it { is_expected.to respond_to :lp_security_attributes }
|
21
20
|
|
22
21
|
describe '#hkey' do
|
@@ -31,17 +30,6 @@ RSpec.describe RubySMB::Dcerpc::Winreg::SaveKeyRequest do
|
|
31
30
|
end
|
32
31
|
end
|
33
32
|
|
34
|
-
describe '#pad' do
|
35
|
-
it 'is a string' do
|
36
|
-
expect(packet.pad).to be_a BinData::String
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should keep #lp_security_attributes 4-byte aligned' do
|
40
|
-
packet.lp_file = "test"
|
41
|
-
expect(packet.lp_security_attributes.abs_offset % 4).to eq 0
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
33
|
describe '#lp_security_attributes' do
|
46
34
|
it 'is a PrpcSecurityAttributes structure' do
|
47
35
|
expect(packet.lp_security_attributes).to be_a RubySMB::Dcerpc::PrpcSecurityAttributes
|
@@ -8,8 +8,8 @@ RSpec.describe RubySMB::Dcerpc::Winreg::SaveKeyResponse do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
describe '#error_status' do
|
11
|
-
it 'is a
|
12
|
-
expect(packet.error_status).to be_a
|
11
|
+
it 'is a NdrUint32' do
|
12
|
+
expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -133,16 +133,14 @@ RSpec.describe RubySMB::Dcerpc::Winreg do
|
|
133
133
|
let(:handle) { double('Handle') }
|
134
134
|
let(:value_name) { double('Value Name') }
|
135
135
|
let(:query_value_request_packet) { double('Query Value Request Packet #1') }
|
136
|
-
let(:
|
137
|
-
let(:lp_data2) { double('LpData #2') }
|
136
|
+
let(:lp_data) { double('LpData #2') }
|
138
137
|
let(:response1) { double('Response #1') }
|
139
138
|
let(:response2) { double('Response #2') }
|
140
139
|
let(:query_value_response1) { double('Query Value Response #1') }
|
141
140
|
let(:query_value_response2) { double('Query Value Response #2') }
|
142
141
|
let(:data) { double('Data') }
|
143
142
|
let(:lpcb_data) { double('LpcbData') }
|
144
|
-
let(:
|
145
|
-
let(:lp_data2_referent) { double('LpData Referent') }
|
143
|
+
let(:max_count) { 5 }
|
146
144
|
before :example do
|
147
145
|
allow(described_class::QueryValueRequest).to receive(:new).and_return(query_value_request_packet)
|
148
146
|
allow(query_value_request_packet).to receive_messages(
|
@@ -150,10 +148,9 @@ RSpec.describe RubySMB::Dcerpc::Winreg do
|
|
150
148
|
:lpcb_data= => nil,
|
151
149
|
:lpcb_len= => nil,
|
152
150
|
:lp_data= => nil,
|
153
|
-
:lp_data =>
|
151
|
+
:lp_data => lp_data,
|
154
152
|
)
|
155
|
-
allow(
|
156
|
-
allow(lp_data2_referent).to receive(:max_count=)
|
153
|
+
allow(lp_data).to receive(:max_count=)
|
157
154
|
first_request = true
|
158
155
|
allow(winreg).to receive(:dcerpc_request) do |arg|
|
159
156
|
if first_request
|
@@ -171,7 +168,7 @@ RSpec.describe RubySMB::Dcerpc::Winreg do
|
|
171
168
|
:data => data
|
172
169
|
)
|
173
170
|
allow(query_value_response1).to receive(:lpcb_data).and_return(lpcb_data)
|
174
|
-
allow(lpcb_data).to receive(:
|
171
|
+
allow(lpcb_data).to receive(:to_i).and_return(max_count)
|
175
172
|
end
|
176
173
|
|
177
174
|
it 'create the expected QueryValueRequest packets' do
|
@@ -186,7 +183,7 @@ RSpec.describe RubySMB::Dcerpc::Winreg do
|
|
186
183
|
expect(query_value_request_packet).to have_received(:lpcb_len=).with(0)
|
187
184
|
expect(query_value_request_packet).to have_received(:lpcb_data=).with(lpcb_data)
|
188
185
|
expect(query_value_request_packet).to have_received(:lp_data=).with([])
|
189
|
-
expect(
|
186
|
+
expect(lp_data).to have_received(:max_count=).with(max_count)
|
190
187
|
end
|
191
188
|
|
192
189
|
it 'sends the expected dcerpc requests' do
|
@@ -293,19 +290,13 @@ RSpec.describe RubySMB::Dcerpc::Winreg do
|
|
293
290
|
let(:response) { double('Response') }
|
294
291
|
let(:query_info_key_response) { double('CloseKey Response') }
|
295
292
|
let(:lp_class) { double('LpClass') }
|
296
|
-
let(:lp_class_referent) { double('LpClass referent') }
|
297
|
-
let(:lp_class_buf_ref) { double('LpClass buffer referent') }
|
298
293
|
before :example do
|
299
294
|
allow(described_class::QueryInfoKeyRequest).to receive(:new).and_return(query_info_key_request_packet)
|
300
295
|
allow(query_info_key_request_packet).to receive_messages(
|
301
296
|
:lp_class= => nil,
|
302
297
|
:lp_class => lp_class,
|
303
298
|
)
|
304
|
-
allow(lp_class).to receive(:
|
305
|
-
allow(lp_class_referent).to receive(:actual_count=)
|
306
|
-
allow(lp_class).to receive(:maximum_length=)
|
307
|
-
allow(lp_class).to receive_message_chain(:buffer, :referent => lp_class_buf_ref)
|
308
|
-
allow(lp_class_buf_ref).to receive(:max_count=)
|
299
|
+
allow(lp_class).to receive(:set_max_buffer_size)
|
309
300
|
allow(winreg).to receive(:dcerpc_request).and_return(response)
|
310
301
|
allow(described_class::QueryInfoKeyResponse).to receive(:read).and_return(query_info_key_response)
|
311
302
|
allow(query_info_key_response).to receive(:error_status).and_return(WindowsError::Win32::ERROR_SUCCESS)
|
@@ -323,10 +314,7 @@ RSpec.describe RubySMB::Dcerpc::Winreg do
|
|
323
314
|
|
324
315
|
it 'sets the expected fields on the request packet' do
|
325
316
|
winreg.query_info_key(handle)
|
326
|
-
expect(
|
327
|
-
expect(lp_class_referent).to have_received(:actual_count=).with(0)
|
328
|
-
expect(lp_class).to have_received(:maximum_length=).with(1024)
|
329
|
-
expect(lp_class_buf_ref).to have_received(:max_count=).with(1024 / 2)
|
317
|
+
expect(lp_class).to have_received(:set_max_buffer_size).with(RubySMB::Dcerpc::Winreg::BUFFER_SIZE)
|
330
318
|
end
|
331
319
|
|
332
320
|
it 'creates a QueryInfoKeyResponse structure from the expected dcerpc response' do
|
@@ -358,31 +346,22 @@ RSpec.describe RubySMB::Dcerpc::Winreg do
|
|
358
346
|
let(:index) { double('Index') }
|
359
347
|
let(:enum_key_request_packet) { double('enum_key Request Packet') }
|
360
348
|
let(:lp_name) { double('Lp Name') }
|
361
|
-
let(:buffer) { double('Buffer') }
|
362
|
-
let(:lp_name_buffer_referent) { double('Lp Name buffer referent') }
|
363
349
|
let(:response) { double('Response') }
|
364
350
|
let(:enum_key_response) { double('enum_key Response') }
|
365
|
-
let(:result_str) {
|
351
|
+
let(:result_str) { { buffer: 'reg key' } }
|
366
352
|
let(:lp_class) { double('Lp Class') }
|
367
|
-
let(:lp_class_buffer_referent) { double('Lp Class buffer referent') }
|
368
353
|
before :example do
|
369
354
|
allow(described_class::EnumKeyRequest).to receive(:new).and_return(enum_key_request_packet)
|
370
355
|
allow(enum_key_request_packet).to receive_messages(
|
371
|
-
:lpft_last_write_time= => nil,
|
372
|
-
:lp_class= => nil,
|
373
356
|
:lp_name => lp_name,
|
374
357
|
:lp_class => lp_class
|
375
358
|
)
|
376
|
-
allow(lp_class).to receive(:
|
377
|
-
allow(
|
378
|
-
allow(lp_name).to receive(:buffer).and_return(buffer)
|
379
|
-
allow(lp_name).to receive(:buffer=)
|
380
|
-
allow(buffer).to receive(:referent).and_return(lp_name_buffer_referent)
|
381
|
-
allow(lp_name_buffer_referent).to receive(:max_count=)
|
359
|
+
allow(lp_class).to receive(:instantiate_referent)
|
360
|
+
allow(lp_name).to receive(:set_max_buffer_size)
|
382
361
|
allow(winreg).to receive(:dcerpc_request).and_return(response)
|
383
362
|
allow(described_class::EnumKeyResponse).to receive(:read).and_return(enum_key_response)
|
384
363
|
allow(enum_key_response).to receive(:error_status).and_return(WindowsError::Win32::ERROR_SUCCESS)
|
385
|
-
allow(enum_key_response).to receive_message_chain(:lp_name, :
|
364
|
+
allow(enum_key_response).to receive_message_chain(:lp_name, :[] => result_str)
|
386
365
|
end
|
387
366
|
|
388
367
|
it 'create the expected EnumKeyRequest packet' do
|
@@ -392,11 +371,8 @@ RSpec.describe RubySMB::Dcerpc::Winreg do
|
|
392
371
|
|
393
372
|
it 'sets the expected parameters on the request packet' do
|
394
373
|
winreg.enum_key(handle, index)
|
395
|
-
expect(
|
396
|
-
expect(
|
397
|
-
expect(lp_class_buffer_referent).to have_received(:buffer=).with(:null)
|
398
|
-
expect(lp_name).to have_received(:buffer=).with('')
|
399
|
-
expect(lp_name_buffer_referent).to have_received(:max_count=).with(256)
|
374
|
+
expect(lp_class).to have_received(:instantiate_referent)
|
375
|
+
expect(lp_name).to have_received(:set_max_buffer_size).with(RubySMB::Dcerpc::Winreg::BUFFER_SIZE)
|
400
376
|
end
|
401
377
|
|
402
378
|
it 'sends the expected dcerpc request' do
|
@@ -433,22 +409,18 @@ RSpec.describe RubySMB::Dcerpc::Winreg do
|
|
433
409
|
let(:index) { double('Index') }
|
434
410
|
let(:enum_value_request_packet) { double('EnumValue Request Packet') }
|
435
411
|
let(:lp_value_name) { double('Lp Value Name') }
|
436
|
-
let(:buffer) { double('Buffer') }
|
437
412
|
let(:referent) { double('Referent') }
|
438
413
|
let(:response) { double('Response') }
|
439
414
|
let(:enum_value_response) { double('EnumValue Response') }
|
440
|
-
let(:result_str) {
|
415
|
+
let(:result_str) { {buffer: 'reg value'} }
|
441
416
|
before :example do
|
442
417
|
allow(described_class::EnumValueRequest).to receive(:new).and_return(enum_value_request_packet)
|
443
418
|
allow(enum_value_request_packet).to receive(:lp_value_name).and_return(lp_value_name)
|
444
|
-
allow(lp_value_name).to receive(:
|
445
|
-
allow(lp_value_name).to receive(:buffer=)
|
446
|
-
allow(buffer).to receive(:referent).and_return(referent)
|
447
|
-
allow(referent).to receive(:max_count=)
|
419
|
+
allow(lp_value_name).to receive(:set_max_buffer_size)
|
448
420
|
allow(winreg).to receive(:dcerpc_request).and_return(response)
|
449
421
|
allow(described_class::EnumValueResponse).to receive(:read).and_return(enum_value_response)
|
450
422
|
allow(enum_value_response).to receive(:error_status).and_return(WindowsError::Win32::ERROR_SUCCESS)
|
451
|
-
allow(enum_value_response).to receive_message_chain(:lp_value_name, :
|
423
|
+
allow(enum_value_response).to receive_message_chain(:lp_value_name, :[] => result_str)
|
452
424
|
end
|
453
425
|
|
454
426
|
it 'create the expected EnumValueRequest packet' do
|
@@ -458,8 +430,7 @@ RSpec.describe RubySMB::Dcerpc::Winreg do
|
|
458
430
|
|
459
431
|
it 'sets the expected buffer on the request packet' do
|
460
432
|
winreg.enum_value(handle, index)
|
461
|
-
expect(
|
462
|
-
expect(lp_value_name).to have_received(:buffer=).with('')
|
433
|
+
expect(lp_value_name).to have_received(:set_max_buffer_size).with(RubySMB::Dcerpc::Winreg::BUFFER_SIZE)
|
463
434
|
end
|
464
435
|
|
465
436
|
it 'sends the expected dcerpc request' do
|
@@ -0,0 +1,43 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Wkssvc::WkssvcIdentifyHandle do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it 'is a Ndr::NdrWideStringPtr' do
|
5
|
+
expect(packet).to be_a(RubySMB::Dcerpc::Ndr::NdrWideStringPtr)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
RSpec.describe RubySMB::Dcerpc::Wkssvc::NetrWkstaGetInfoRequest do
|
10
|
+
subject(:packet) { described_class.new }
|
11
|
+
|
12
|
+
it { is_expected.to respond_to :server_name }
|
13
|
+
it { is_expected.to respond_to :level }
|
14
|
+
it { is_expected.to respond_to :opnum }
|
15
|
+
|
16
|
+
it 'is little endian' do
|
17
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
18
|
+
end
|
19
|
+
it 'is a BinData::Record' do
|
20
|
+
expect(packet).to be_a(BinData::Record)
|
21
|
+
end
|
22
|
+
describe '#server_name' do
|
23
|
+
it 'is a WkssvcIdentifyHandle structure' do
|
24
|
+
expect(packet.server_name).to be_a RubySMB::Dcerpc::Wkssvc::WkssvcIdentifyHandle
|
25
|
+
end
|
26
|
+
end
|
27
|
+
describe '#level' do
|
28
|
+
it 'is a NdrUint32 structure' do
|
29
|
+
expect(packet.level).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
30
|
+
end
|
31
|
+
end
|
32
|
+
describe '#initialize_instance' do
|
33
|
+
it 'sets #opnum to NETR_WKSTA_GET_INFO constant' do
|
34
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Wkssvc::NETR_WKSTA_GET_INFO)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
it 'reads itself' do
|
38
|
+
new_class = described_class.new(server_name: 'TestServer', level: 4)
|
39
|
+
expect(packet.read(new_class.to_binary_s)).to eq(
|
40
|
+
{server_name: 'TestServer'.encode('utf-16le'), level: 4}
|
41
|
+
)
|
42
|
+
end
|
43
|
+
end
|