ruby_smb 2.0.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.github/workflows/verify.yml +46 -0
- data/README.md +0 -1
- data/examples/anonymous_auth.rb +3 -3
- data/examples/append_file.rb +10 -8
- data/examples/auth_capture.rb +71 -0
- data/examples/authenticate.rb +9 -5
- data/examples/delete_file.rb +8 -6
- data/examples/dump_secrets_from_sid.rb +207 -0
- data/examples/enum_domain_users.rb +75 -0
- data/examples/enum_registry_key.rb +5 -4
- data/examples/enum_registry_values.rb +5 -4
- data/examples/get_computer_info.rb +42 -0
- data/examples/list_directory.rb +8 -6
- data/examples/negotiate_with_netbios_service.rb +9 -5
- data/examples/net_share_enum_all.rb +6 -4
- data/examples/pipes.rb +11 -12
- data/examples/query_service_status.rb +102 -0
- data/examples/read_file.rb +8 -6
- data/examples/read_registry_key_value.rb +6 -5
- 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/client/authentication.rb +5 -10
- data/lib/ruby_smb/client/echo.rb +2 -4
- data/lib/ruby_smb/client/negotiation.rb +13 -16
- data/lib/ruby_smb/client/tree_connect.rb +2 -4
- data/lib/ruby_smb/client/utils.rb +16 -10
- data/lib/ruby_smb/client/winreg.rb +1 -1
- data/lib/ruby_smb/client.rb +102 -75
- data/lib/ruby_smb/compression/lznt1.rb +164 -0
- data/lib/ruby_smb/compression.rb +7 -0
- 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 +20 -0
- data/lib/ruby_smb/dcerpc/ndr.rb +1204 -80
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_request.rb +27 -0
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_response.rb +26 -0
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_request.rb +27 -0
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_response.rb +23 -0
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_request.rb +24 -0
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_response.rb +24 -0
- data/lib/ruby_smb/dcerpc/netlogon.rb +102 -0
- 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 +85 -19
- 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 +34 -0
- 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 +36 -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 +25 -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 +23 -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 +45 -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 +26 -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/svcctl.rb +477 -0
- 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 +62 -0
- data/lib/ruby_smb/dcerpc/winreg/create_key_response.rb +36 -0
- data/lib/ruby_smb/dcerpc/winreg/enum_key_request.rb +2 -19
- 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 +6 -7
- data/lib/ruby_smb/dcerpc/winreg/open_root_key_response.rb +2 -2
- data/lib/ruby_smb/dcerpc/winreg/query_info_key_request.rb +1 -1
- data/lib/ruby_smb/dcerpc/winreg/query_info_key_response.rb +9 -18
- data/lib/ruby_smb/dcerpc/winreg/query_value_request.rb +4 -13
- 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 +28 -0
- data/lib/ruby_smb/dcerpc/winreg/save_key_response.rb +23 -0
- data/lib/ruby_smb/dcerpc/winreg.rb +99 -22
- 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 +45 -11
- data/lib/ruby_smb/dialect.rb +45 -0
- data/lib/ruby_smb/dispatcher/base.rb +1 -1
- data/lib/ruby_smb/dispatcher/socket.rb +2 -2
- data/lib/ruby_smb/error.rb +21 -5
- data/lib/ruby_smb/field/file_time.rb +1 -1
- data/lib/ruby_smb/field/string16.rb +5 -1
- data/lib/ruby_smb/field/stringz16.rb +17 -1
- data/lib/ruby_smb/generic_packet.rb +11 -1
- data/lib/ruby_smb/gss/provider/authenticator.rb +42 -0
- data/lib/ruby_smb/gss/provider/ntlm.rb +303 -0
- data/lib/ruby_smb/gss/provider.rb +35 -0
- data/lib/ruby_smb/gss.rb +56 -63
- data/lib/ruby_smb/nbss/session_header.rb +4 -4
- data/lib/ruby_smb/ntlm.rb +61 -0
- data/lib/ruby_smb/server/server_client/negotiation.rb +156 -0
- data/lib/ruby_smb/server/server_client/session_setup.rb +82 -0
- data/lib/ruby_smb/server/server_client.rb +162 -0
- data/lib/ruby_smb/server.rb +54 -0
- data/lib/ruby_smb/signing.rb +59 -0
- data/lib/ruby_smb/smb1/file.rb +10 -25
- data/lib/ruby_smb/smb1/packet/negotiate_response.rb +11 -11
- data/lib/ruby_smb/smb1/packet/negotiate_response_extended.rb +1 -1
- data/lib/ruby_smb/smb1/packet/session_setup_request.rb +1 -1
- data/lib/ruby_smb/smb1/packet/trans2/find_first2_response.rb +0 -1
- data/lib/ruby_smb/smb1/packet/trans2/find_next2_response.rb +0 -1
- data/lib/ruby_smb/smb1/packet/trans2/open2_response.rb +1 -2
- data/lib/ruby_smb/smb1/packet/trans2/set_file_information_response.rb +1 -13
- data/lib/ruby_smb/smb1/pipe.rb +12 -6
- data/lib/ruby_smb/smb1/tree.rb +13 -9
- data/lib/ruby_smb/smb2/file.rb +33 -33
- data/lib/ruby_smb/smb2/negotiate_context.rb +18 -2
- data/lib/ruby_smb/smb2/packet/compression_transform_header.rb +4 -0
- data/lib/ruby_smb/smb2/packet/negotiate_request.rb +9 -0
- data/lib/ruby_smb/smb2/packet/negotiate_response.rb +0 -1
- data/lib/ruby_smb/smb2/packet/session_setup_response.rb +2 -2
- data/lib/ruby_smb/smb2/packet/tree_connect_request.rb +1 -1
- data/lib/ruby_smb/smb2/pipe.rb +13 -6
- data/lib/ruby_smb/smb2/tree.rb +21 -11
- data/lib/ruby_smb/smb2.rb +3 -1
- data/lib/ruby_smb/version.rb +1 -1
- data/lib/ruby_smb.rb +5 -3
- data/spec/lib/ruby_smb/client_spec.rb +199 -86
- data/spec/lib/ruby_smb/compression/lznt1_spec.rb +32 -0
- 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 +3977 -239
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_request_spec.rb +69 -0
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_response_spec.rb +53 -0
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_request_spec.rb +69 -0
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_response_spec.rb +37 -0
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_request_spec.rb +45 -0
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_response_spec.rb +37 -0
- 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 +162 -0
- 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 +168 -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 +68 -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 +53 -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 +76 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/start_service_w_request_spec.rb +47 -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 +508 -0
- 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 +73 -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 +4 -56
- 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 -20
- 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_request_spec.rb +0 -4
- 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 +18 -42
- data/spec/lib/ruby_smb/dcerpc/winreg/regsam_spec.rb +4 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/save_key_request_spec.rb +45 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/save_key_response_spec.rb +22 -0
- data/spec/lib/ruby_smb/dcerpc/winreg_spec.rb +219 -62
- 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/dispatcher/socket_spec.rb +10 -10
- data/spec/lib/ruby_smb/error_spec.rb +34 -5
- data/spec/lib/ruby_smb/field/string16_spec.rb +22 -0
- data/spec/lib/ruby_smb/field/stringz16_spec.rb +12 -0
- data/spec/lib/ruby_smb/generic_packet_spec.rb +7 -0
- data/spec/lib/ruby_smb/gss/provider/ntlm/account_spec.rb +32 -0
- data/spec/lib/ruby_smb/gss/provider/ntlm/authenticator_spec.rb +101 -0
- data/spec/lib/ruby_smb/gss/provider/ntlm/os_version_spec.rb +32 -0
- data/spec/lib/ruby_smb/gss/provider/ntlm_spec.rb +113 -0
- data/spec/lib/ruby_smb/nbss/session_header_spec.rb +4 -11
- data/spec/lib/ruby_smb/server/server_client_spec.rb +156 -0
- data/spec/lib/ruby_smb/server_spec.rb +32 -0
- data/spec/lib/ruby_smb/smb1/file_spec.rb +2 -4
- data/spec/lib/ruby_smb/smb1/packet/trans2/find_first2_response_spec.rb +0 -1
- data/spec/lib/ruby_smb/smb1/packet/trans2/find_next2_response_spec.rb +0 -1
- data/spec/lib/ruby_smb/smb1/packet/trans2/open2_response_spec.rb +0 -5
- data/spec/lib/ruby_smb/smb1/packet/trans2/set_file_information_response_spec.rb +0 -6
- data/spec/lib/ruby_smb/smb1/pipe_spec.rb +20 -14
- data/spec/lib/ruby_smb/smb1/tree_spec.rb +22 -0
- data/spec/lib/ruby_smb/smb2/file_spec.rb +61 -9
- data/spec/lib/ruby_smb/smb2/negotiate_context_spec.rb +2 -2
- data/spec/lib/ruby_smb/smb2/pipe_spec.rb +20 -14
- data/spec/lib/ruby_smb/smb2/tree_spec.rb +58 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/bin_helper.rb +9 -0
- data.tar.gz.sig +0 -0
- metadata +229 -23
- metadata.gz.sig +0 -0
- data/.travis.yml +0 -6
- data/lib/ruby_smb/client/signing.rb +0 -64
- data/lib/ruby_smb/dcerpc/rrp_unicode_string.rb +0 -35
- data/spec/lib/ruby_smb/dcerpc/rrp_unicode_string_spec.rb +0 -98
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Netlogon::NetrServerAuthenticate3Request do
|
|
2
|
+
subject(:packet) { described_class.new }
|
|
3
|
+
|
|
4
|
+
it { is_expected.to respond_to :primary_name }
|
|
5
|
+
it { is_expected.to respond_to :account_name }
|
|
6
|
+
it { is_expected.to respond_to :secure_channel_type }
|
|
7
|
+
it { is_expected.to respond_to :computer_name }
|
|
8
|
+
it { is_expected.to respond_to :client_credential }
|
|
9
|
+
it { is_expected.to respond_to :flags }
|
|
10
|
+
|
|
11
|
+
it 'is little endian' do
|
|
12
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe '#primary_name' do
|
|
16
|
+
it 'is a LogonsrvHandle structure' do
|
|
17
|
+
expect(packet.primary_name).to be_a RubySMB::Dcerpc::Netlogon::LogonsrvHandle
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe '#account_name' do
|
|
22
|
+
it 'is a NdrConfVarWideStringz structure' do
|
|
23
|
+
expect(packet.account_name).to be_a RubySMB::Dcerpc::Ndr::NdrConfVarWideStringz
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe '#secure_channel_type' do
|
|
28
|
+
it 'is a NetlogonSecureChannelType enum' do
|
|
29
|
+
expect(packet.secure_channel_type).to be_a RubySMB::Dcerpc::Netlogon::NetlogonSecureChannelType
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe '#computer_name' do
|
|
34
|
+
it 'is a NdrConfVarWideStringz structure' do
|
|
35
|
+
expect(packet.computer_name).to be_a RubySMB::Dcerpc::Ndr::NdrConfVarWideStringz
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe '#client_credential' do
|
|
40
|
+
it 'is a NetlogonCredential structure' do
|
|
41
|
+
expect(packet.client_credential).to be_a RubySMB::Dcerpc::Netlogon::NetlogonCredential
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe '#flags' do
|
|
46
|
+
it 'is a 32-bit unsigned integer' do
|
|
47
|
+
expect(packet.flags).to be_a BinData::Uint32le
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
describe '#initialize_instance' do
|
|
52
|
+
it 'sets #opnum to NETR_SERVER_AUTHENTICATE3 constant' do
|
|
53
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Netlogon::NETR_SERVER_AUTHENTICATE3)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'reads its own binary representation and outputs the same packet' do
|
|
58
|
+
packet = described_class.new(
|
|
59
|
+
primary_name: 'primary_name',
|
|
60
|
+
account_name: 'account_name',
|
|
61
|
+
secure_channel_type: 0,
|
|
62
|
+
computer_name: 'computer_name',
|
|
63
|
+
client_credential: "\x00" * 8,
|
|
64
|
+
flags: rand(0xffffffff)
|
|
65
|
+
)
|
|
66
|
+
binary = packet.to_binary_s
|
|
67
|
+
expect(described_class.read(binary)).to eq(packet)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Netlogon::NetrServerAuthenticate3Response do
|
|
2
|
+
subject(:packet) { described_class.new }
|
|
3
|
+
|
|
4
|
+
it { is_expected.to respond_to :server_credential }
|
|
5
|
+
it { is_expected.to respond_to :negotiate_flags }
|
|
6
|
+
it { is_expected.to respond_to :account_rid }
|
|
7
|
+
it { is_expected.to respond_to :error_status }
|
|
8
|
+
|
|
9
|
+
it 'is little endian' do
|
|
10
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe '#server_credential' do
|
|
14
|
+
it 'is a NetlogonCredential structure' do
|
|
15
|
+
expect(packet.server_credential).to be_a RubySMB::Dcerpc::Netlogon::NetlogonCredential
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe '#negotiate_flags' do
|
|
20
|
+
it 'is a 32-bit unsigned integer' do
|
|
21
|
+
expect(packet.negotiate_flags).to be_a BinData::Uint32le
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe '#account_rid' do
|
|
26
|
+
it 'is a 32-bit unsigned integer' do
|
|
27
|
+
expect(packet.account_rid).to be_a BinData::Uint32le
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe '#error_status' do
|
|
32
|
+
it 'is a 32-bit unsigned integer' do
|
|
33
|
+
expect(packet.error_status).to be_a BinData::Uint32le
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe '#initialize_instance' do
|
|
38
|
+
it 'sets #opnum to NETR_SERVER_AUTHENTICATE3 constant' do
|
|
39
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Netlogon::NETR_SERVER_AUTHENTICATE3)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'reads its own binary representation and outputs the same packet' do
|
|
44
|
+
packet = described_class.new(
|
|
45
|
+
server_credential: "\x00" * 8,
|
|
46
|
+
negotiate_flags: rand(0xffffffff),
|
|
47
|
+
account_rid: rand(0xffffffff),
|
|
48
|
+
error_status: rand(0xffffffff)
|
|
49
|
+
)
|
|
50
|
+
binary = packet.to_binary_s
|
|
51
|
+
expect(described_class.read(binary)).to eq(packet)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Netlogon::NetrServerPasswordSet2Request do
|
|
2
|
+
subject(:packet) { described_class.new }
|
|
3
|
+
|
|
4
|
+
it { is_expected.to respond_to :primary_name }
|
|
5
|
+
it { is_expected.to respond_to :account_name }
|
|
6
|
+
it { is_expected.to respond_to :secure_channel_type }
|
|
7
|
+
it { is_expected.to respond_to :computer_name }
|
|
8
|
+
it { is_expected.to respond_to :authenticator }
|
|
9
|
+
it { is_expected.to respond_to :clear_new_password }
|
|
10
|
+
|
|
11
|
+
it 'is little endian' do
|
|
12
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe '#primary_name' do
|
|
16
|
+
it 'is a LogonsrvHandle structure' do
|
|
17
|
+
expect(packet.primary_name).to be_a RubySMB::Dcerpc::Netlogon::LogonsrvHandle
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe '#account_name' do
|
|
22
|
+
it 'is a NdrConfVarWideStringz structure' do
|
|
23
|
+
expect(packet.account_name).to be_a RubySMB::Dcerpc::Ndr::NdrConfVarWideStringz
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe '#secure_channel_type' do
|
|
28
|
+
it 'is a NetlogonSecureChannelType enum' do
|
|
29
|
+
expect(packet.secure_channel_type).to be_a RubySMB::Dcerpc::Netlogon::NetlogonSecureChannelType
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe '#computer_name' do
|
|
34
|
+
it 'is a NdrConfVarWideStringz structure' do
|
|
35
|
+
expect(packet.computer_name).to be_a RubySMB::Dcerpc::Ndr::NdrConfVarWideStringz
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe '#authenticator' do
|
|
40
|
+
it 'is a NetlogonAuthenticator structure' do
|
|
41
|
+
expect(packet.authenticator).to be_a RubySMB::Dcerpc::Netlogon::NetlogonAuthenticator
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe '#clear_new_password' do
|
|
46
|
+
it 'is a NdrFixedByteArray structure' do
|
|
47
|
+
expect(packet.clear_new_password).to be_a RubySMB::Dcerpc::Ndr::NdrFixedByteArray
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
describe '#initialize_instance' do
|
|
52
|
+
it 'sets #opnum to NETR_SERVER_PASSWORD_SET2 constant' do
|
|
53
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Netlogon::NETR_SERVER_PASSWORD_SET2)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'reads its own binary representation and outputs the same packet' do
|
|
58
|
+
packet = described_class.new(
|
|
59
|
+
primary_name: 'primary_name',
|
|
60
|
+
account_name: 'account_name',
|
|
61
|
+
secure_channel_type: 0,
|
|
62
|
+
computer_name: 'computer_name',
|
|
63
|
+
authenticator: RubySMB::Dcerpc::Netlogon::NetlogonAuthenticator.new,
|
|
64
|
+
clear_new_password: "\x00" * 516
|
|
65
|
+
)
|
|
66
|
+
binary = packet.to_binary_s
|
|
67
|
+
expect(described_class.read(binary)).to eq(packet)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Netlogon::NetrServerPasswordSet2Response do
|
|
2
|
+
subject(:packet) { described_class.new }
|
|
3
|
+
|
|
4
|
+
it { is_expected.to respond_to :return_authenticator }
|
|
5
|
+
it { is_expected.to respond_to :error_status }
|
|
6
|
+
|
|
7
|
+
it 'is little endian' do
|
|
8
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe '#return_authenticator' do
|
|
12
|
+
it 'is a NetlogonAuthenticator structure' do
|
|
13
|
+
expect(packet.return_authenticator).to be_a RubySMB::Dcerpc::Netlogon::NetlogonAuthenticator
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe '#error_status' do
|
|
18
|
+
it 'is a 32-bit unsigned integer' do
|
|
19
|
+
expect(packet.error_status).to be_a BinData::Uint32le
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe '#initialize_instance' do
|
|
24
|
+
it 'sets #opnum to NETR_SERVER_PASSWORD_SET2 constant' do
|
|
25
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Netlogon::NETR_SERVER_PASSWORD_SET2)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'reads its own binary representation and outputs the same packet' do
|
|
30
|
+
packet = described_class.new(
|
|
31
|
+
return_authenticator: RubySMB::Dcerpc::Netlogon::NetlogonAuthenticator.new,
|
|
32
|
+
error_status: rand(0xffffffff)
|
|
33
|
+
)
|
|
34
|
+
binary = packet.to_binary_s
|
|
35
|
+
expect(described_class.read(binary)).to eq(packet)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Netlogon::NetrServerReqChallengeRequest do
|
|
2
|
+
subject(:packet) { described_class.new }
|
|
3
|
+
|
|
4
|
+
it { is_expected.to respond_to :primary_name }
|
|
5
|
+
it { is_expected.to respond_to :computer_name }
|
|
6
|
+
it { is_expected.to respond_to :client_challenge }
|
|
7
|
+
|
|
8
|
+
it 'is little endian' do
|
|
9
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe '#primary_name' do
|
|
13
|
+
it 'is a LogonsrvHandle structure' do
|
|
14
|
+
expect(packet.primary_name).to be_a RubySMB::Dcerpc::Netlogon::LogonsrvHandle
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe '#computer_name' do
|
|
19
|
+
it 'is a NdrConfVarWideStringz structure' do
|
|
20
|
+
expect(packet.computer_name).to be_a RubySMB::Dcerpc::Ndr::NdrConfVarWideStringz
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe '#client_challenge' do
|
|
25
|
+
it 'is a NetlogonCredential structure' do
|
|
26
|
+
expect(packet.client_challenge).to be_a RubySMB::Dcerpc::Netlogon::NetlogonCredential
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe '#initialize_instance' do
|
|
31
|
+
it 'sets #opnum to NETR_SERVER_REQ_CHALLENGE constant' do
|
|
32
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Netlogon::NETR_SERVER_REQ_CHALLENGE)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'reads its own binary representation and outputs the same packet' do
|
|
37
|
+
packet = described_class.new(
|
|
38
|
+
primary_name: 'primary_name',
|
|
39
|
+
computer_name: 'computer_name',
|
|
40
|
+
client_challenge: "\x00" * 8,
|
|
41
|
+
)
|
|
42
|
+
binary = packet.to_binary_s
|
|
43
|
+
expect(described_class.read(binary)).to eq(packet)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Netlogon::NetrServerReqChallengeResponse do
|
|
2
|
+
subject(:packet) { described_class.new }
|
|
3
|
+
|
|
4
|
+
it { is_expected.to respond_to :server_challenge }
|
|
5
|
+
it { is_expected.to respond_to :error_status }
|
|
6
|
+
|
|
7
|
+
it 'is little endian' do
|
|
8
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe '#server_challenge' do
|
|
12
|
+
it 'is a NetlogonCredential structure' do
|
|
13
|
+
expect(packet.server_challenge).to be_a RubySMB::Dcerpc::Netlogon::NetlogonCredential
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe '#error_status' do
|
|
18
|
+
it 'is a NDR 32-bit unsigned integer' do
|
|
19
|
+
expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe '#initialize_instance' do
|
|
24
|
+
it 'sets #opnum to NETR_SERVER_REQ_CHALLENGE constant' do
|
|
25
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Netlogon::NETR_SERVER_REQ_CHALLENGE)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'reads its own binary representation and outputs the same packet' do
|
|
30
|
+
packet = described_class.new(
|
|
31
|
+
server_challenge: "\x00" * 8,
|
|
32
|
+
error_status: rand(0xffffffff)
|
|
33
|
+
)
|
|
34
|
+
binary = packet.to_binary_s
|
|
35
|
+
expect(described_class.read(binary)).to eq(packet)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -9,6 +9,10 @@ RSpec.describe RubySMB::Dcerpc::PSyntaxIdT do
|
|
|
9
9
|
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
+
it 'has :byte_align parameter set to the expected value' do
|
|
13
|
+
expect(described_class.default_parameters[:byte_align]).to eq(4)
|
|
14
|
+
end
|
|
15
|
+
|
|
12
16
|
describe '#if_uuid' do
|
|
13
17
|
it 'is a Uuid' do
|
|
14
18
|
expect(packet.if_uuid).to be_a RubySMB::Dcerpc::Uuid
|
|
@@ -16,16 +20,26 @@ RSpec.describe RubySMB::Dcerpc::PSyntaxIdT do
|
|
|
16
20
|
end
|
|
17
21
|
|
|
18
22
|
describe '#if_ver_major' do
|
|
19
|
-
it 'should be a
|
|
20
|
-
expect(packet.if_ver_major).to be_a
|
|
23
|
+
it 'should be a NdrUint16' do
|
|
24
|
+
expect(packet.if_ver_major).to be_a RubySMB::Dcerpc::Ndr::NdrUint16
|
|
21
25
|
end
|
|
22
26
|
end
|
|
23
27
|
|
|
24
28
|
describe '#if_ver_minor' do
|
|
25
|
-
it 'should be a
|
|
26
|
-
expect(packet.if_ver_minor).to be_a
|
|
29
|
+
it 'should be a NdrUint16' do
|
|
30
|
+
expect(packet.if_ver_minor).to be_a RubySMB::Dcerpc::Ndr::NdrUint16
|
|
27
31
|
end
|
|
28
32
|
end
|
|
29
33
|
|
|
34
|
+
it 'reads its own binary representation and output the same packet' do
|
|
35
|
+
packet = described_class.new(
|
|
36
|
+
if_uuid: '22fd0d58-357a-472d-9d03-5f19e09b3a92',
|
|
37
|
+
if_ver_major: rand(0xFF),
|
|
38
|
+
if_ver_minor: rand(0xFF)
|
|
39
|
+
)
|
|
40
|
+
binary = packet.to_binary_s
|
|
41
|
+
expect(described_class.read(binary)).to eq(packet)
|
|
42
|
+
end
|
|
43
|
+
|
|
30
44
|
end
|
|
31
45
|
|
|
@@ -37,9 +37,20 @@ RSpec.describe RubySMB::Dcerpc::PDUHeader do
|
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
describe '#pfc_flags' do
|
|
40
|
+
subject(:pfc_flags) { packet.pfc_flags }
|
|
41
|
+
|
|
40
42
|
it 'should be a custom structure' do
|
|
41
|
-
expect(
|
|
43
|
+
expect(pfc_flags).to be_a BinData::Struct
|
|
42
44
|
end
|
|
45
|
+
|
|
46
|
+
it { is_expected.to respond_to :object_uuid }
|
|
47
|
+
it { is_expected.to respond_to :maybe }
|
|
48
|
+
it { is_expected.to respond_to :did_not_execute }
|
|
49
|
+
it { is_expected.to respond_to :conc_mpx }
|
|
50
|
+
it { is_expected.to respond_to :reserved_1 }
|
|
51
|
+
it { is_expected.to respond_to :support_header_sign }
|
|
52
|
+
it { is_expected.to respond_to :last_frag }
|
|
53
|
+
it { is_expected.to respond_to :first_frag }
|
|
43
54
|
end
|
|
44
55
|
|
|
45
56
|
describe '#packed_drep' do
|
|
@@ -79,6 +90,21 @@ RSpec.describe RubySMB::Dcerpc::PDUHeader do
|
|
|
79
90
|
end
|
|
80
91
|
end
|
|
81
92
|
|
|
93
|
+
it 'reads its own binary representation and output the same packet' do
|
|
94
|
+
packet = described_class.new(
|
|
95
|
+
rpc_vers: rand(0xFF),
|
|
96
|
+
rpc_vers_minor: rand(0xFF),
|
|
97
|
+
ptype: rand(0xFF),
|
|
98
|
+
pfc_flags: { support_header_sign: 1},
|
|
99
|
+
packed_drep: rand(0xFF),
|
|
100
|
+
frag_length: rand(0xFF),
|
|
101
|
+
auth_length: rand(0xFF),
|
|
102
|
+
call_id: rand(0xFF)
|
|
103
|
+
)
|
|
104
|
+
binary = packet.to_binary_s
|
|
105
|
+
expect(described_class.read(binary)).to eq(packet)
|
|
106
|
+
end
|
|
107
|
+
|
|
82
108
|
end
|
|
83
109
|
|
|
84
110
|
|
|
@@ -7,7 +7,9 @@ RSpec.describe RubySMB::Dcerpc::Request do
|
|
|
7
7
|
it { is_expected.to respond_to :opnum }
|
|
8
8
|
it { is_expected.to respond_to :object }
|
|
9
9
|
it { is_expected.to respond_to :stub }
|
|
10
|
-
it { is_expected.to respond_to :
|
|
10
|
+
it { is_expected.to respond_to :auth_pad }
|
|
11
|
+
it { is_expected.to respond_to :sec_trailer }
|
|
12
|
+
it { is_expected.to respond_to :auth_value }
|
|
11
13
|
|
|
12
14
|
it 'is little endian' do
|
|
13
15
|
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
|
@@ -83,7 +85,7 @@ RSpec.describe RubySMB::Dcerpc::Request do
|
|
|
83
85
|
end
|
|
84
86
|
|
|
85
87
|
it 'selects the expected packet structure' do
|
|
86
|
-
expect(packet.stub).to eq(RubySMB::Dcerpc::Srvsvc::
|
|
88
|
+
expect(packet.stub).to eq(RubySMB::Dcerpc::Srvsvc::NetShareEnumAllRequest.new)
|
|
87
89
|
end
|
|
88
90
|
end
|
|
89
91
|
|
|
@@ -118,37 +120,100 @@ RSpec.describe RubySMB::Dcerpc::Request do
|
|
|
118
120
|
end
|
|
119
121
|
end
|
|
120
122
|
|
|
121
|
-
describe '#
|
|
123
|
+
describe '#auth_pad' do
|
|
122
124
|
it 'should be a string' do
|
|
123
|
-
expect(packet.
|
|
125
|
+
expect(packet.auth_pad).to be_a BinData::String
|
|
124
126
|
end
|
|
125
127
|
|
|
126
128
|
it 'should not exist if the #auth_length PDU header field is 0' do
|
|
127
129
|
packet.pdu_header.auth_length = 0
|
|
128
|
-
expect(packet.
|
|
130
|
+
expect(packet.auth_pad?).to be false
|
|
129
131
|
end
|
|
130
132
|
|
|
131
133
|
it 'should exist only if the #auth_length PDU header field is greater than 0' do
|
|
132
134
|
packet.pdu_header.auth_length = 10
|
|
133
|
-
expect(packet.
|
|
135
|
+
expect(packet.auth_pad?).to be true
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
it 'makes sure #sec_trailer is 16-bytes aligned with the begining of the PDU body (stub)' do
|
|
139
|
+
packet.pdu_header.auth_length = 6
|
|
140
|
+
packet.stub = 'A' * rand(0xFF)
|
|
141
|
+
expect((packet.sec_trailer.abs_offset - packet.stub.abs_offset) % 16).to eq(0)
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
describe '#sec_trailer' do
|
|
146
|
+
it 'is a SecTrailer structre' do
|
|
147
|
+
expect(packet.sec_trailer).to be_a RubySMB::Dcerpc::SecTrailer
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
it 'should not exist if the #auth_length PDU header field is 0' do
|
|
151
|
+
packet.pdu_header.auth_length = 0
|
|
152
|
+
expect(packet.sec_trailer?).to be false
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
it 'should exist only if the #auth_length PDU header field is greater than 0' do
|
|
156
|
+
packet.pdu_header.auth_length = 10
|
|
157
|
+
expect(packet.sec_trailer?).to be true
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
describe '#auth_value' do
|
|
162
|
+
it 'should be a string' do
|
|
163
|
+
expect(packet.auth_value).to be_a BinData::String
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
it 'should not exist if the #auth_length PDU header field is 0' do
|
|
167
|
+
packet.pdu_header.auth_length = 0
|
|
168
|
+
expect(packet.auth_value?).to be false
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
it 'should exist only if the #auth_length PDU header field is greater than 0' do
|
|
172
|
+
packet.pdu_header.auth_length = 10
|
|
173
|
+
expect(packet.auth_value?).to be true
|
|
134
174
|
end
|
|
135
175
|
|
|
136
176
|
it 'reads #auth_length bytes' do
|
|
137
|
-
|
|
177
|
+
auth_value = '12345678'
|
|
138
178
|
packet.pdu_header.auth_length = 6
|
|
139
|
-
packet.
|
|
140
|
-
expect(packet.
|
|
179
|
+
packet.auth_value.read(auth_value)
|
|
180
|
+
expect(packet.auth_value).to eq(auth_value[0,6])
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
describe '#enable_encrypted_stub' do
|
|
185
|
+
it 'sets the stub type to BinData::String' do
|
|
186
|
+
# Set a new packet with a Winreg stub
|
|
187
|
+
packet = described_class.new(
|
|
188
|
+
{ opnum: RubySMB::Dcerpc::Winreg::OPEN_HKPD },
|
|
189
|
+
{ endpoint: 'Winreg' }
|
|
190
|
+
)
|
|
191
|
+
# Enabling encryption will switch the stub to a string
|
|
192
|
+
packet.enable_encrypted_stub
|
|
193
|
+
expect(packet.stub.send(:current_choice)).to be_a BinData::String
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
describe '#has_auth_verifier?' do
|
|
198
|
+
it 'returns true if PDU header #auth_length is greater than 0' do
|
|
199
|
+
packet.pdu_header.auth_length = 5
|
|
200
|
+
expect(packet.has_auth_verifier?).to be true
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
it 'returns false if PDU header #auth_length is 0' do
|
|
204
|
+
packet.pdu_header.auth_length = 0
|
|
205
|
+
expect(packet.has_auth_verifier?).to be false
|
|
141
206
|
end
|
|
142
207
|
end
|
|
143
208
|
|
|
144
209
|
it 'reads its own binary representation and output the same packet' do
|
|
145
210
|
packet = described_class.new(
|
|
146
211
|
{ :opnum => RubySMB::Dcerpc::Srvsvc::NET_SHARE_ENUM_ALL },
|
|
147
|
-
{ :endpoint => 'Srvsvc'
|
|
212
|
+
{ :endpoint => 'Srvsvc' }
|
|
148
213
|
)
|
|
149
214
|
packet.pdu_header.pfc_flags.object_uuid = 1
|
|
150
215
|
packet.object = '8a885d04-1ceb-11c9-9fe8-08002b104860'
|
|
151
|
-
packet.
|
|
216
|
+
packet.auth_value = '123456'
|
|
152
217
|
packet.pdu_header.auth_length = 6
|
|
153
218
|
binary = packet.to_binary_s
|
|
154
219
|
packet2 = described_class.new( { :endpoint => 'Srvsvc' } )
|
|
@@ -6,7 +6,9 @@ RSpec.describe RubySMB::Dcerpc::Response do
|
|
|
6
6
|
it { is_expected.to respond_to :p_cont_id }
|
|
7
7
|
it { is_expected.to respond_to :cancel_count }
|
|
8
8
|
it { is_expected.to respond_to :stub }
|
|
9
|
-
it { is_expected.to respond_to :
|
|
9
|
+
it { is_expected.to respond_to :auth_pad }
|
|
10
|
+
it { is_expected.to respond_to :sec_trailer }
|
|
11
|
+
it { is_expected.to respond_to :auth_value }
|
|
10
12
|
|
|
11
13
|
it 'is little endian' do
|
|
12
14
|
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
|
@@ -61,32 +63,120 @@ RSpec.describe RubySMB::Dcerpc::Response do
|
|
|
61
63
|
end
|
|
62
64
|
end
|
|
63
65
|
|
|
64
|
-
describe '#
|
|
66
|
+
describe '#auth_pad' do
|
|
65
67
|
it 'should be a string' do
|
|
66
|
-
expect(packet.
|
|
68
|
+
expect(packet.auth_pad).to be_a BinData::String
|
|
67
69
|
end
|
|
68
70
|
|
|
69
71
|
it 'should not exist if the #auth_length PDU header field is 0' do
|
|
70
72
|
packet.pdu_header.auth_length = 0
|
|
71
|
-
expect(packet.
|
|
73
|
+
expect(packet.auth_pad?).to be false
|
|
72
74
|
end
|
|
73
75
|
|
|
74
76
|
it 'should exist only if the #auth_length PDU header field is greater than 0' do
|
|
75
77
|
packet.pdu_header.auth_length = 10
|
|
76
|
-
expect(packet.
|
|
78
|
+
expect(packet.auth_pad?).to be true
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'makes sure #sec_trailer is 16-bytes aligned with the begining of the PDU body (stub)' do
|
|
82
|
+
packet.pdu_header.auth_length = 6
|
|
83
|
+
packet.stub = 'A' * rand(0xFF)
|
|
84
|
+
expect((packet.sec_trailer.abs_offset - packet.stub.abs_offset) % 16).to eq(0)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
describe '#sec_trailer' do
|
|
89
|
+
it 'is a SecTrailer structre' do
|
|
90
|
+
expect(packet.sec_trailer).to be_a RubySMB::Dcerpc::SecTrailer
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it 'should not exist if the #auth_length PDU header field is 0' do
|
|
94
|
+
packet.pdu_header.auth_length = 0
|
|
95
|
+
expect(packet.sec_trailer?).to be false
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it 'should exist only if the #auth_length PDU header field is greater than 0' do
|
|
99
|
+
packet.pdu_header.auth_length = 10
|
|
100
|
+
expect(packet.sec_trailer?).to be true
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
describe '#auth_value' do
|
|
105
|
+
it 'should be a string' do
|
|
106
|
+
expect(packet.auth_value).to be_a BinData::String
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it 'should not exist if the #auth_length PDU header field is 0' do
|
|
110
|
+
packet.pdu_header.auth_length = 0
|
|
111
|
+
expect(packet.auth_value?).to be false
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it 'should exist only if the #auth_length PDU header field is greater than 0' do
|
|
115
|
+
packet.pdu_header.auth_length = 10
|
|
116
|
+
expect(packet.auth_value?).to be true
|
|
77
117
|
end
|
|
78
118
|
|
|
79
119
|
it 'reads #auth_length bytes' do
|
|
80
|
-
|
|
120
|
+
auth_value = '12345678'
|
|
81
121
|
packet.pdu_header.auth_length = 6
|
|
82
|
-
packet.
|
|
83
|
-
expect(packet.
|
|
122
|
+
packet.auth_value.read(auth_value)
|
|
123
|
+
expect(packet.auth_value).to eq(auth_value[0,6])
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
describe '#has_auth_verifier?' do
|
|
128
|
+
it 'returns true if PDU header #auth_length is greater than 0' do
|
|
129
|
+
packet.pdu_header.auth_length = 5
|
|
130
|
+
expect(packet.has_auth_verifier?).to be true
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
it 'returns false if PDU header #auth_length is 0' do
|
|
134
|
+
packet.pdu_header.auth_length = 0
|
|
135
|
+
expect(packet.has_auth_verifier?).to be false
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
describe '#stub_length' do
|
|
140
|
+
let(:stub_length) { rand(0xFF) }
|
|
141
|
+
before :example do
|
|
142
|
+
packet.stub = 'A' * stub_length
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
it 'returns the correct stub length' do
|
|
146
|
+
expect(packet.stub_length).to eq(stub_length)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
context 'with auth verifier' do
|
|
150
|
+
it 'returns the correct stub length' do
|
|
151
|
+
auth_size = rand(0xFF)
|
|
152
|
+
packet.pdu_header.auth_length = auth_size
|
|
153
|
+
packet.auth_value = 'B' * auth_size
|
|
154
|
+
expect(packet.stub_length).to eq(stub_length + packet.auth_pad.num_bytes)
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
describe '#read' do
|
|
160
|
+
let(:response) { described_class.new }
|
|
161
|
+
let(:auth_size) { rand(0xFF) }
|
|
162
|
+
let(:stub_size) { rand(0xFF) }
|
|
163
|
+
before :example do
|
|
164
|
+
response.pdu_header.auth_length = auth_size
|
|
165
|
+
response.stub = 'A' * stub_size
|
|
166
|
+
response.auth_value = 'B' * auth_size
|
|
167
|
+
response.auth_pad = 'C' * response.auth_pad.size
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
it 'sets #stub and #auth_pad to the correct values' do
|
|
171
|
+
packet.read(response.to_binary_s)
|
|
172
|
+
expect(packet.stub).to eq(response.stub)
|
|
173
|
+
expect(packet.auth_pad).to eq(response.auth_pad)
|
|
84
174
|
end
|
|
85
175
|
end
|
|
86
176
|
|
|
87
177
|
it 'reads its own binary representation and output the same packet' do
|
|
88
178
|
packet.stub = 'ABCD'
|
|
89
|
-
packet.
|
|
179
|
+
packet.auth_value = '123456'
|
|
90
180
|
packet.pdu_header.auth_length = 6
|
|
91
181
|
binary = packet.to_binary_s
|
|
92
182
|
expect(described_class.read(binary)).to eq(packet)
|