ruby_smb 0.0.18 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.md +247 -7
- data/examples/anonymous_auth.rb +6 -3
- data/examples/append_file.rb +40 -0
- data/examples/authenticate.rb +12 -7
- data/examples/delete_file.rb +40 -0
- data/examples/list_directory.rb +45 -0
- data/examples/negotiate.rb +0 -1
- data/examples/negotiate_with_netbios_service.rb +36 -0
- data/examples/net_share_enum_all.rb +30 -0
- data/examples/read_file.rb +39 -0
- data/examples/rename_file.rb +41 -0
- data/examples/tree_connect.rb +2 -4
- data/examples/write_file.rb +40 -0
- data/lib/ruby_smb.rb +5 -0
- data/lib/ruby_smb/client.rb +196 -43
- data/lib/ruby_smb/client/authentication.rb +89 -48
- data/lib/ruby_smb/client/echo.rb +1 -4
- data/lib/ruby_smb/client/negotiation.rb +46 -45
- data/lib/ruby_smb/client/signing.rb +9 -16
- data/lib/ruby_smb/client/tree_connect.rb +8 -13
- data/lib/ruby_smb/client/utils.rb +79 -0
- data/lib/ruby_smb/dcerpc.rb +30 -0
- data/lib/ruby_smb/dcerpc/bind.rb +60 -0
- data/lib/ruby_smb/dcerpc/handle.rb +60 -0
- data/lib/ruby_smb/dcerpc/ndr.rb +41 -0
- data/lib/ruby_smb/dcerpc/request.rb +43 -0
- data/lib/ruby_smb/dcerpc/response.rb +46 -0
- data/lib/ruby_smb/dcerpc/srvsvc.rb +17 -0
- data/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all.rb +93 -0
- data/lib/ruby_smb/dcerpc/uuid.rb +28 -0
- data/lib/ruby_smb/dispatcher.rb +7 -3
- data/lib/ruby_smb/dispatcher/base.rb +23 -14
- data/lib/ruby_smb/dispatcher/socket.rb +71 -51
- data/lib/ruby_smb/dispositions.rb +32 -0
- data/lib/ruby_smb/error.rb +24 -18
- data/lib/ruby_smb/field.rb +5 -2
- data/lib/ruby_smb/field/extended_attribute_flag.rb +1 -1
- data/lib/ruby_smb/field/file_time.rb +3 -1
- data/lib/ruby_smb/field/security_descriptor.rb +6 -6
- data/lib/ruby_smb/field/smb2_fileid.rb +11 -0
- data/lib/ruby_smb/field/smb_fea.rb +3 -3
- data/lib/ruby_smb/field/smb_fea_list.rb +3 -3
- data/lib/ruby_smb/field/smb_gea.rb +12 -0
- data/lib/ruby_smb/field/smb_gea_list.rb +13 -0
- data/lib/ruby_smb/field/string16.rb +14 -0
- data/lib/ruby_smb/field/stringz16.rb +3 -7
- data/lib/ruby_smb/field/utime.rb +11 -10
- data/lib/ruby_smb/fscc.rb +12 -0
- data/lib/ruby_smb/fscc/control_codes.rb +26 -0
- data/lib/ruby_smb/{field → fscc}/ea_info_array.rb +12 -14
- data/lib/ruby_smb/fscc/file_attributes.rb +29 -0
- data/lib/ruby_smb/{field → fscc}/file_full_ea_info.rb +5 -5
- data/lib/ruby_smb/fscc/file_information.rb +60 -0
- data/lib/ruby_smb/fscc/file_information/file_both_directory_information.rb +29 -0
- data/lib/ruby_smb/fscc/file_information/file_directory_information.rb +25 -0
- data/lib/ruby_smb/fscc/file_information/file_disposition_information.rb +15 -0
- data/lib/ruby_smb/fscc/file_information/file_full_directory_information.rb +26 -0
- data/lib/ruby_smb/fscc/file_information/file_id_both_directory_information.rb +31 -0
- data/lib/ruby_smb/fscc/file_information/file_id_full_directory_information.rb +28 -0
- data/lib/ruby_smb/fscc/file_information/file_names_information.rb +18 -0
- data/lib/ruby_smb/fscc/file_information/file_rename_information.rb +44 -0
- data/lib/ruby_smb/generic_packet.rb +40 -18
- data/lib/ruby_smb/gss.rb +49 -56
- data/lib/ruby_smb/impersonation_levels.rb +7 -2
- data/lib/ruby_smb/nbss.rb +16 -0
- data/lib/ruby_smb/nbss/negative_session_response.rb +30 -0
- data/lib/ruby_smb/nbss/session_header.rb +13 -0
- data/lib/ruby_smb/nbss/session_request.rb +13 -0
- data/lib/ruby_smb/smb1.rb +20 -17
- data/lib/ruby_smb/smb1/bit_field.rb +3 -0
- data/lib/ruby_smb/smb1/bit_field/create_options.rb +5 -5
- data/lib/ruby_smb/smb1/bit_field/file_status_flags.rb +18 -0
- data/lib/ruby_smb/smb1/bit_field/open2_access_mode.rb +11 -11
- data/lib/ruby_smb/smb1/bit_field/open2_open_mode.rb +1 -1
- data/lib/ruby_smb/smb1/bit_field/optional_support.rb +0 -1
- data/lib/ruby_smb/smb1/bit_field/security_flags.rb +15 -0
- data/lib/ruby_smb/smb1/bit_field/share_access.rb +2 -3
- data/lib/ruby_smb/smb1/bit_field/smb_ext_file_attributes.rb +21 -24
- data/lib/ruby_smb/smb1/bit_field/smb_file_attributes.rb +1 -1
- data/lib/ruby_smb/smb1/commands.rb +5 -0
- data/lib/ruby_smb/smb1/create_actions.rb +3 -5
- data/lib/ruby_smb/smb1/file.rb +289 -0
- data/lib/ruby_smb/smb1/oplock_levels.rb +2 -4
- data/lib/ruby_smb/smb1/packet.rb +10 -0
- data/lib/ruby_smb/smb1/packet/close_request.rb +31 -0
- data/lib/ruby_smb/smb1/packet/close_response.rb +28 -0
- data/lib/ruby_smb/smb1/packet/echo_request.rb +5 -7
- data/lib/ruby_smb/smb1/packet/echo_response.rb +5 -7
- data/lib/ruby_smb/smb1/packet/empty_packet.rb +1 -2
- data/lib/ruby_smb/smb1/packet/logoff_request.rb +1 -4
- data/lib/ruby_smb/smb1/packet/logoff_response.rb +1 -4
- data/lib/ruby_smb/smb1/packet/negotiate_response.rb +22 -0
- data/lib/ruby_smb/smb1/packet/negotiate_response_extended.rb +22 -0
- data/lib/ruby_smb/smb1/packet/nt_create_andx_request.rb +62 -0
- data/lib/ruby_smb/smb1/packet/nt_create_andx_response.rb +66 -0
- data/lib/ruby_smb/smb1/packet/nt_trans.rb +1 -2
- data/lib/ruby_smb/smb1/packet/nt_trans/create_request.rb +19 -13
- data/lib/ruby_smb/smb1/packet/nt_trans/create_response.rb +8 -10
- data/lib/ruby_smb/smb1/packet/nt_trans/request.rb +11 -11
- data/lib/ruby_smb/smb1/packet/nt_trans/response.rb +10 -10
- data/lib/ruby_smb/smb1/packet/nt_trans/subcommands.rb +8 -1
- data/lib/ruby_smb/smb1/packet/read_andx_request.rb +84 -0
- data/lib/ruby_smb/smb1/packet/read_andx_response.rb +47 -0
- data/lib/ruby_smb/smb1/packet/session_setup_legacy_request.rb +2 -6
- data/lib/ruby_smb/smb1/packet/session_setup_legacy_response.rb +1 -4
- data/lib/ruby_smb/smb1/packet/session_setup_request.rb +1 -6
- data/lib/ruby_smb/smb1/packet/session_setup_response.rb +2 -4
- data/lib/ruby_smb/smb1/packet/trans2.rb +8 -2
- data/lib/ruby_smb/smb1/packet/trans2/data_block.rb +6 -7
- data/lib/ruby_smb/smb1/packet/trans2/find_first2_request.rb +77 -0
- data/lib/ruby_smb/smb1/packet/trans2/find_first2_response.rb +87 -0
- data/lib/ruby_smb/smb1/packet/trans2/find_information_level.rb +32 -0
- data/lib/ruby_smb/smb1/packet/trans2/find_information_level/find_file_full_directory_info.rb +45 -0
- data/lib/ruby_smb/smb1/packet/trans2/find_next2_request.rb +77 -0
- data/lib/ruby_smb/smb1/packet/trans2/find_next2_response.rb +86 -0
- data/lib/ruby_smb/smb1/packet/trans2/open2_request.rb +10 -10
- data/lib/ruby_smb/smb1/packet/trans2/open2_response.rb +10 -12
- data/lib/ruby_smb/smb1/packet/trans2/request.rb +15 -17
- data/lib/ruby_smb/smb1/packet/trans2/request_secondary.rb +8 -10
- data/lib/ruby_smb/smb1/packet/trans2/response.rb +11 -13
- data/lib/ruby_smb/smb1/packet/trans2/set_file_information_request.rb +66 -0
- data/lib/ruby_smb/smb1/packet/trans2/set_file_information_response.rb +57 -0
- data/lib/ruby_smb/smb1/packet/trans2/subcommands.rb +5 -2
- data/lib/ruby_smb/smb1/packet/tree_connect_request.rb +4 -6
- data/lib/ruby_smb/smb1/packet/tree_connect_response.rb +5 -7
- data/lib/ruby_smb/smb1/packet/tree_disconnect_request.rb +2 -4
- data/lib/ruby_smb/smb1/packet/tree_disconnect_response.rb +2 -4
- data/lib/ruby_smb/smb1/packet/write_andx_request.rb +68 -0
- data/lib/ruby_smb/smb1/packet/write_andx_response.rb +35 -0
- data/lib/ruby_smb/smb1/resource_type.rb +18 -0
- data/lib/ruby_smb/smb1/tree.rb +188 -5
- data/lib/ruby_smb/smb2.rb +16 -11
- data/lib/ruby_smb/smb2/bit_field.rb +1 -0
- data/lib/ruby_smb/smb2/bit_field/file_access_mask.rb +1 -1
- data/lib/ruby_smb/smb2/bit_field/session_flags.rb +1 -2
- data/lib/ruby_smb/smb2/bit_field/share_flags.rb +4 -6
- data/lib/ruby_smb/smb2/create_context.rb +29 -0
- data/lib/ruby_smb/smb2/file.rb +251 -0
- data/lib/ruby_smb/smb2/info_type.rb +21 -0
- data/lib/ruby_smb/smb2/packet.rb +16 -0
- data/lib/ruby_smb/smb2/packet/close_request.rb +22 -0
- data/lib/ruby_smb/smb2/packet/close_response.rb +29 -0
- data/lib/ruby_smb/smb2/packet/create_request.rb +54 -0
- data/lib/ruby_smb/smb2/packet/create_response.rb +35 -0
- data/lib/ruby_smb/smb2/packet/echo_request.rb +1 -3
- data/lib/ruby_smb/smb2/packet/echo_response.rb +1 -3
- data/lib/ruby_smb/smb2/packet/error_packet.rb +1 -3
- data/lib/ruby_smb/smb2/packet/ioctl_request.rb +54 -0
- data/lib/ruby_smb/smb2/packet/ioctl_response.rb +39 -0
- data/lib/ruby_smb/smb2/packet/logoff_request.rb +1 -4
- data/lib/ruby_smb/smb2/packet/logoff_response.rb +1 -4
- data/lib/ruby_smb/smb2/packet/negotiate_request.rb +1 -1
- data/lib/ruby_smb/smb2/packet/negotiate_response.rb +1 -1
- data/lib/ruby_smb/smb2/packet/query_directory_request.rb +35 -0
- data/lib/ruby_smb/smb2/packet/query_directory_response.rb +45 -0
- data/lib/ruby_smb/smb2/packet/read_request.rb +30 -0
- data/lib/ruby_smb/smb2/packet/read_response.rb +26 -0
- data/lib/ruby_smb/smb2/packet/session_setup_request.rb +2 -5
- data/lib/ruby_smb/smb2/packet/session_setup_response.rb +4 -7
- data/lib/ruby_smb/smb2/packet/set_info_request.rb +58 -0
- data/lib/ruby_smb/smb2/packet/set_info_response.rb +20 -0
- data/lib/ruby_smb/smb2/packet/tree_connect_request.rb +3 -4
- data/lib/ruby_smb/smb2/packet/tree_connect_response.rb +5 -9
- data/lib/ruby_smb/smb2/packet/tree_disconnect_request.rb +1 -4
- data/lib/ruby_smb/smb2/packet/tree_disconnect_response.rb +1 -4
- data/lib/ruby_smb/smb2/packet/write_request.rb +29 -0
- data/lib/ruby_smb/smb2/packet/write_response.rb +26 -0
- data/lib/ruby_smb/smb2/tree.rb +163 -7
- data/lib/ruby_smb/version.rb +1 -1
- data/spec/lib/ruby_smb/client_spec.rb +459 -120
- data/spec/lib/ruby_smb/dcerpc/bind_spec.rb +14 -0
- data/spec/lib/ruby_smb/dcerpc/handle_spec.rb +31 -0
- data/spec/lib/ruby_smb/dcerpc/request_spec.rb +21 -0
- data/spec/lib/ruby_smb/dcerpc/response_spec.rb +15 -0
- data/spec/lib/ruby_smb/dcerpc/srvsvc_spec.rb +13 -0
- data/spec/lib/ruby_smb/dcerpc/uuid_spec.rb +12 -0
- data/spec/lib/ruby_smb/dispatcher/base_spec.rb +26 -0
- data/spec/lib/ruby_smb/dispatcher/socket_spec.rb +118 -18
- data/spec/lib/ruby_smb/field/extended_attribute_flag_spec.rb +0 -3
- data/spec/lib/ruby_smb/field/file_time_spec.rb +4 -2
- data/spec/lib/ruby_smb/field/security_descriptor.rb +0 -1
- data/spec/lib/ruby_smb/field/smb2_fileid_spec.rb +10 -0
- data/spec/lib/ruby_smb/field/smb_fea_list_spec.rb +3 -5
- data/spec/lib/ruby_smb/field/smb_gea_list_spec.rb +37 -0
- data/spec/lib/ruby_smb/field/smb_gea_spec.rb +22 -0
- data/spec/lib/ruby_smb/field/stringz16_spec.rb +7 -9
- data/spec/lib/ruby_smb/field/utime_spec.rb +4 -2
- data/spec/lib/ruby_smb/{field → fscc}/ea_info_array_spec.rb +7 -9
- data/spec/lib/ruby_smb/{field → fscc}/file_full_ea_info_spec.rb +2 -3
- data/spec/lib/ruby_smb/fscc/file_information/file_both_directory_information_spec.rb +71 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_directory_information_spec.rb +68 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_disposition_information_spec.rb +26 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_full_directory_information_spec.rb +69 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_id_both_directory_information_spec.rb +72 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_id_full_directory_information_spec.rb +70 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_names_information_spec.rb +41 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_rename_information_spec.rb +133 -0
- data/spec/lib/ruby_smb/fscc/fscc_file_attributes_spec.rb +143 -0
- data/spec/lib/ruby_smb/generic_packet_spec.rb +46 -21
- data/spec/lib/ruby_smb/nbss/negative_session_response_spec.rb +29 -0
- data/spec/lib/ruby_smb/nbss/session_header_spec.rb +30 -0
- data/spec/lib/ruby_smb/nbss/session_request_spec.rb +30 -0
- data/spec/lib/ruby_smb/smb1/bit_field/create_options_spec.rb +9 -1
- data/spec/lib/ruby_smb/smb1/bit_field/directory_access_mask_spec.rb +0 -2
- data/spec/lib/ruby_smb/smb1/bit_field/file_access_mask_spec.rb +0 -2
- data/spec/lib/ruby_smb/smb1/bit_field/file_status_flags_spec.rb +35 -0
- data/spec/lib/ruby_smb/smb1/bit_field/open2_access_mode_spec.rb +1 -3
- data/spec/lib/ruby_smb/smb1/bit_field/open2_flags_spec.rb +0 -2
- data/spec/lib/ruby_smb/smb1/bit_field/open2_open_mode_spec.rb +0 -1
- data/spec/lib/ruby_smb/smb1/bit_field/optional_support_spec.rb +0 -1
- data/spec/lib/ruby_smb/smb1/bit_field/security_flags_spec.rb +26 -0
- data/spec/lib/ruby_smb/smb1/bit_field/share_access_spec.rb +0 -3
- data/spec/lib/ruby_smb/smb1/bit_field/smb_ext_file_attributes_spec.rb +20 -39
- data/spec/lib/ruby_smb/smb1/bit_field/smb_file_attributes_spec.rb +0 -6
- data/spec/lib/ruby_smb/smb1/bit_field/smb_nmpipe_status_spec.rb +0 -2
- data/spec/lib/ruby_smb/smb1/bit_field/trans2_flags_spec.rb +0 -2
- data/spec/lib/ruby_smb/smb1/bit_field/tree_connect_flags_spec.rb +0 -2
- data/spec/lib/ruby_smb/smb1/file_spec.rb +469 -0
- data/spec/lib/ruby_smb/smb1/packet/close_request_spec.rb +54 -0
- data/spec/lib/ruby_smb/smb1/packet/close_response_spec.rb +45 -0
- data/spec/lib/ruby_smb/smb1/packet/echo_request_spec.rb +1 -4
- data/spec/lib/ruby_smb/smb1/packet/echo_response_spec.rb +1 -4
- data/spec/lib/ruby_smb/smb1/packet/error_packet_spec.rb +1 -3
- data/spec/lib/ruby_smb/smb1/packet/logoff_request_spec.rb +1 -4
- data/spec/lib/ruby_smb/smb1/packet/logoff_response_spec.rb +1 -4
- data/spec/lib/ruby_smb/smb1/packet/negotiate_request_spec.rb +1 -1
- data/spec/lib/ruby_smb/smb1/packet/negotiate_response_extended_spec.rb +37 -0
- data/spec/lib/ruby_smb/smb1/packet/negotiate_response_spec.rb +37 -0
- data/spec/lib/ruby_smb/smb1/packet/nt_create_andx_request_spec.rb +151 -0
- data/spec/lib/ruby_smb/smb1/packet/nt_create_andx_response_spec.rb +157 -0
- data/spec/lib/ruby_smb/smb1/packet/nt_trans/create_request_spec.rb +13 -6
- data/spec/lib/ruby_smb/smb1/packet/nt_trans/create_response_spec.rb +1 -7
- data/spec/lib/ruby_smb/smb1/packet/nt_trans/request_spec.rb +1 -6
- data/spec/lib/ruby_smb/smb1/packet/nt_trans/response_spec.rb +1 -5
- data/spec/lib/ruby_smb/smb1/packet/read_andx_request_spec.rb +149 -0
- data/spec/lib/ruby_smb/smb1/packet/read_andx_response_spec.rb +93 -0
- data/spec/lib/ruby_smb/smb1/packet/session_setup_legacy_request_spec.rb +1 -5
- data/spec/lib/ruby_smb/smb1/packet/session_setup_legacy_response_spec.rb +1 -5
- data/spec/lib/ruby_smb/smb1/packet/session_setup_request_spec.rb +3 -8
- data/spec/lib/ruby_smb/smb1/packet/session_setup_response_spec.rb +2 -4
- data/spec/lib/ruby_smb/smb1/packet/trans2/find_first2_request_spec.rb +180 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/find_first2_response_spec.rb +104 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/find_information_level/find_file_full_directory_info_spec.rb +128 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/find_next2_request_spec.rb +174 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/find_next2_response_spec.rb +102 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/open2_request_spec.rb +1 -6
- data/spec/lib/ruby_smb/smb1/packet/trans2/open2_response_spec.rb +2 -7
- data/spec/lib/ruby_smb/smb1/packet/trans2/request_secondary_spec.rb +1 -5
- data/spec/lib/ruby_smb/smb1/packet/trans2/request_spec.rb +1 -5
- data/spec/lib/ruby_smb/smb1/packet/trans2/response_spec.rb +1 -4
- data/spec/lib/ruby_smb/smb1/packet/trans2/set_file_information_request_spec.rb +98 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/set_file_information_response_spec.rb +56 -0
- data/spec/lib/ruby_smb/smb1/packet/tree_connect_request_spec.rb +1 -5
- data/spec/lib/ruby_smb/smb1/packet/tree_connect_response_spec.rb +1 -6
- data/spec/lib/ruby_smb/smb1/packet/tree_disconnect_request_spec.rb +1 -4
- data/spec/lib/ruby_smb/smb1/packet/tree_disconnect_response_spec.rb +1 -4
- data/spec/lib/ruby_smb/smb1/packet/write_andx_request_spec.rb +148 -0
- data/spec/lib/ruby_smb/smb1/packet/write_andx_response_spec.rb +54 -0
- data/spec/lib/ruby_smb/smb1/tree_spec.rb +409 -7
- data/spec/lib/ruby_smb/smb2/bit_field/directory_access_mask_spec.rb +0 -2
- data/spec/lib/ruby_smb/smb2/bit_field/file_access_mask_spec.rb +0 -2
- data/spec/lib/ruby_smb/smb2/bit_field/session_flags_spec.rb +1 -1
- data/spec/lib/ruby_smb/smb2/bit_field/share_capabilities_spec.rb +0 -1
- data/spec/lib/ruby_smb/smb2/bit_field/share_flags_spec.rb +0 -2
- data/spec/lib/ruby_smb/smb2/create_context_spec.rb +42 -0
- data/spec/lib/ruby_smb/smb2/file_spec.rb +233 -0
- data/spec/lib/ruby_smb/smb2/packet/close_request_spec.rb +40 -0
- data/spec/lib/ruby_smb/smb2/packet/close_response_spec.rb +40 -0
- data/spec/lib/ruby_smb/smb2/packet/create_request_spec.rb +101 -0
- data/spec/lib/ruby_smb/smb2/packet/create_response_spec.rb +64 -0
- data/spec/lib/ruby_smb/smb2/packet/echo_request_spec.rb +1 -3
- data/spec/lib/ruby_smb/smb2/packet/echo_response_spec.rb +1 -3
- data/spec/lib/ruby_smb/smb2/packet/ioctl_request_spec.rb +48 -0
- data/spec/lib/ruby_smb/smb2/packet/logoff_request_spec.rb +1 -3
- data/spec/lib/ruby_smb/smb2/packet/logoff_response_spec.rb +1 -3
- data/spec/lib/ruby_smb/smb2/packet/query_directory_request_spec.rb +80 -0
- data/spec/lib/ruby_smb/smb2/packet/query_directory_response_spec.rb +64 -0
- data/spec/lib/ruby_smb/smb2/packet/read_request_spec.rb +43 -0
- data/spec/lib/ruby_smb/smb2/packet/read_response_spec.rb +50 -0
- data/spec/lib/ruby_smb/smb2/packet/session_setup_request_spec.rb +3 -4
- data/spec/lib/ruby_smb/smb2/packet/session_setup_response_spec.rb +2 -3
- data/spec/lib/ruby_smb/smb2/packet/set_info_request_spec.rb +205 -0
- data/spec/lib/ruby_smb/smb2/packet/set_info_response_spec.rb +32 -0
- data/spec/lib/ruby_smb/smb2/packet/tree_connect_request_spec.rb +3 -5
- data/spec/lib/ruby_smb/smb2/packet/tree_connect_response_spec.rb +1 -2
- data/spec/lib/ruby_smb/smb2/packet/tree_disconnect_request_spec.rb +1 -3
- data/spec/lib/ruby_smb/smb2/packet/tree_disconnect_response_spec.rb +1 -3
- data/spec/lib/ruby_smb/smb2/packet/write_request_spec.rb +51 -0
- data/spec/lib/ruby_smb/smb2/packet/write_response_spec.rb +38 -0
- data/spec/lib/ruby_smb/smb2/tree_spec.rb +191 -5
- data/spec/spec_helper.rb +1 -1
- metadata +195 -12
- metadata.gz.sig +0 -0
- data/lib/ruby_smb/smb1/dispositions.rb +0 -36
- data/spec/lib/ruby_smb/dispatcher/dispatcher_base_spec.rb +0 -22
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::SMB2::Packet::CreateResponse do
|
4
|
+
subject(:packet) { described_class.new }
|
5
|
+
|
6
|
+
it { is_expected.to respond_to :smb2_header }
|
7
|
+
it { is_expected.to respond_to :structure_size }
|
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 '#smb2_header' do
|
14
|
+
subject(:header) { packet.smb2_header }
|
15
|
+
|
16
|
+
it 'is a standard SMB Header' do
|
17
|
+
expect(header).to be_a RubySMB::SMB2::SMB2Header
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should have the command set to SMB_COM_NEGOTIATE' do
|
21
|
+
expect(header.command).to eq RubySMB::SMB2::Commands::CREATE
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should have the response flag set' do
|
25
|
+
expect(header.flags.reply).to eq 1
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should have a structure size of 89' do
|
30
|
+
expect(packet.structure_size).to eq 89
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'tracks the creation time in a Filetime field' do
|
34
|
+
expect(packet.create_time).to be_a RubySMB::Field::FileTime
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'tracks the last access time in a Filetime field' do
|
38
|
+
expect(packet.last_access).to be_a RubySMB::Field::FileTime
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'tracks the last write time in a Filetime field' do
|
42
|
+
expect(packet.last_write).to be_a RubySMB::Field::FileTime
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'tracks the last modified time in a Filetime field' do
|
46
|
+
expect(packet.last_change).to be_a RubySMB::Field::FileTime
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'contains the file attributes of the file' do
|
50
|
+
expect(packet.file_attributes).to be_a RubySMB::Fscc::FileAttributes
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'has the handles to the file in an SMB2_FILEID' do
|
54
|
+
expect(packet.file_id).to be_a RubySMB::Field::Smb2Fileid
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'tracks the offset to #context in #context_offset' do
|
58
|
+
expect(packet.context_offset).to eq packet.context.abs_offset
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'tracks the length of #context in #context_length' do
|
62
|
+
expect(packet.context_length).to eq packet.context.do_num_bytes
|
63
|
+
end
|
64
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe RubySMB::SMB2::Packet::EchoRequest do
|
4
|
-
|
5
4
|
subject(:packet) { described_class.new }
|
6
5
|
|
7
6
|
it { is_expected.to respond_to :smb2_header }
|
@@ -26,5 +25,4 @@ RSpec.describe RubySMB::SMB2::Packet::EchoRequest do
|
|
26
25
|
expect(header.flags.reply).to eq 0
|
27
26
|
end
|
28
27
|
end
|
29
|
-
|
30
|
-
end
|
28
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe RubySMB::SMB2::Packet::EchoResponse do
|
4
|
-
|
5
4
|
subject(:packet) { described_class.new }
|
6
5
|
|
7
6
|
it { is_expected.to respond_to :smb2_header }
|
@@ -26,5 +25,4 @@ RSpec.describe RubySMB::SMB2::Packet::EchoResponse do
|
|
26
25
|
expect(header.flags.reply).to eq 1
|
27
26
|
end
|
28
27
|
end
|
29
|
-
|
30
|
-
end
|
28
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::SMB2::Packet::IoctlResponse do
|
4
|
+
subject(:packet) { described_class.new }
|
5
|
+
|
6
|
+
it { is_expected.to respond_to :smb2_header }
|
7
|
+
it { is_expected.to respond_to :structure_size }
|
8
|
+
it { is_expected.to respond_to :ctl_code }
|
9
|
+
it { is_expected.to respond_to :file_id }
|
10
|
+
it { is_expected.to respond_to :input_offset }
|
11
|
+
it { is_expected.to respond_to :input_count }
|
12
|
+
it { is_expected.to respond_to :output_offset }
|
13
|
+
it { is_expected.to respond_to :output_count }
|
14
|
+
it { is_expected.to respond_to :flags }
|
15
|
+
it { is_expected.to respond_to :buffer }
|
16
|
+
|
17
|
+
it 'is little endian' do
|
18
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#smb2_header' do
|
22
|
+
subject(:header) { packet.smb2_header }
|
23
|
+
|
24
|
+
it 'is a standard SMB Header' do
|
25
|
+
expect(header).to be_a RubySMB::SMB2::SMB2Header
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should have the command set to SMB_COM_IOCTL' do
|
29
|
+
expect(header.command).to eq RubySMB::SMB2::Commands::IOCTL
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should have the response flag set' do
|
33
|
+
expect(header.flags.reply).to eq 1
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should have a structure size of 49' do
|
38
|
+
expect(packet.structure_size).to eq 49
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#file_id' do
|
42
|
+
it 'should be an SMB FileID field' do
|
43
|
+
expect(packet.file_id).to be_a RubySMB::Field::Smb2Fileid
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe RubySMB::SMB2::Packet::LogoffRequest do
|
4
|
-
|
5
4
|
subject(:packet) { described_class.new }
|
6
5
|
|
7
6
|
it { is_expected.to respond_to :smb2_header }
|
@@ -26,5 +25,4 @@ RSpec.describe RubySMB::SMB2::Packet::LogoffRequest do
|
|
26
25
|
expect(header.flags.reply).to eq 0
|
27
26
|
end
|
28
27
|
end
|
29
|
-
|
30
|
-
end
|
28
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe RubySMB::SMB2::Packet::LogoffResponse do
|
4
|
-
|
5
4
|
subject(:packet) { described_class.new }
|
6
5
|
|
7
6
|
it { is_expected.to respond_to :smb2_header }
|
@@ -26,5 +25,4 @@ RSpec.describe RubySMB::SMB2::Packet::LogoffResponse do
|
|
26
25
|
expect(header.flags.reply).to eq 1
|
27
26
|
end
|
28
27
|
end
|
29
|
-
|
30
|
-
end
|
28
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::SMB2::Packet::QueryDirectoryRequest do
|
4
|
+
subject(:packet) { described_class.new }
|
5
|
+
|
6
|
+
it { is_expected.to respond_to :smb2_header }
|
7
|
+
it { is_expected.to respond_to :structure_size }
|
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 '#smb2_header' do
|
14
|
+
subject(:header) { packet.smb2_header }
|
15
|
+
|
16
|
+
it 'is a standard SMB Header' do
|
17
|
+
expect(header).to be_a RubySMB::SMB2::SMB2Header
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should have the command set to SMB_COM_QUERY_DIRECTORY' do
|
21
|
+
expect(header.command).to eq RubySMB::SMB2::Commands::QUERY_DIRECTORY
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should not have the response flag set' do
|
25
|
+
expect(header.flags.reply).to eq 0
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should have a structure size of 33' do
|
30
|
+
expect(packet.structure_size).to eq 33
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#flags' do
|
34
|
+
subject(:flags) { packet.flags }
|
35
|
+
|
36
|
+
describe '#restart_scans' do
|
37
|
+
it 'should be a 1-bit field per the SMB spec' do
|
38
|
+
expect(flags.restart_scans).to be_a BinData::Bit1
|
39
|
+
end
|
40
|
+
|
41
|
+
it_behaves_like 'bit field with one flag set', :restart_scans, 'C', 0x01
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#return_single' do
|
45
|
+
it 'should be a 1-bit field per the SMB spec' do
|
46
|
+
expect(flags.return_single).to be_a BinData::Bit1
|
47
|
+
end
|
48
|
+
|
49
|
+
it_behaves_like 'bit field with one flag set', :return_single, 'C', 0x02
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#index_specified' do
|
53
|
+
it 'should be a 1-bit field per the SMB spec' do
|
54
|
+
expect(flags.index_specified).to be_a BinData::Bit1
|
55
|
+
end
|
56
|
+
|
57
|
+
it_behaves_like 'bit field with one flag set', :index_specified, 'C', 0x04
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#reopen' do
|
61
|
+
it 'should be a 1-bit field per the SMB spec' do
|
62
|
+
expect(flags.reopen).to be_a BinData::Bit1
|
63
|
+
end
|
64
|
+
|
65
|
+
it_behaves_like 'bit field with one flag set', :reopen, 'C', 0x10
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'has an SMB2 FILEID field' do
|
70
|
+
expect(packet.file_id).to be_a RubySMB::Field::Smb2Fileid
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'has an offset pointer to the name field' do
|
74
|
+
expect(packet.name_offset).to eq packet.name.abs_offset
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'has a length value for the name field' do
|
78
|
+
expect(packet.name_length).to eq packet.name.do_num_bytes
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::SMB2::Packet::QueryDirectoryResponse do
|
4
|
+
subject(:packet) { described_class.new }
|
5
|
+
|
6
|
+
it { is_expected.to respond_to :smb2_header }
|
7
|
+
it { is_expected.to respond_to :structure_size }
|
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 '#smb2_header' do
|
14
|
+
subject(:header) { packet.smb2_header }
|
15
|
+
|
16
|
+
it 'is a standard SMB Header' do
|
17
|
+
expect(header).to be_a RubySMB::SMB2::SMB2Header
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should have the command set to SMB_COM_QUERY_DIRECTORY' do
|
21
|
+
expect(header.command).to eq RubySMB::SMB2::Commands::QUERY_DIRECTORY
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should have the response flag set' do
|
25
|
+
expect(header.flags.reply).to eq 1
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should have a structure size of 33' do
|
30
|
+
expect(packet.structure_size).to eq 9
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'has an offset pointer to the buffer field' do
|
34
|
+
expect(packet.buffer_offset).to eq packet.buffer.abs_offset
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'has a length value for the buffer field' do
|
38
|
+
expect(packet.buffer_length).to eq packet.buffer.do_num_bytes
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#results' do
|
42
|
+
let(:names1) {
|
43
|
+
names = RubySMB::Fscc::FileInformation::FileNamesInformation.new
|
44
|
+
names.file_name = 'test.txt'
|
45
|
+
names.next_offset = names.do_num_bytes
|
46
|
+
names
|
47
|
+
}
|
48
|
+
|
49
|
+
let(:names2) {
|
50
|
+
names = RubySMB::Fscc::FileInformation::FileNamesInformation.new
|
51
|
+
names.file_name = '..'
|
52
|
+
names
|
53
|
+
}
|
54
|
+
|
55
|
+
let(:names_array) { [names1, names2] }
|
56
|
+
|
57
|
+
let(:names_blob) { names_array.collect(&:to_binary_s).join('') }
|
58
|
+
|
59
|
+
it 'returns an array of parsed Fileinformation structs' do
|
60
|
+
packet.buffer = names_blob
|
61
|
+
expect(packet.results(RubySMB::Fscc::FileInformation::FileNamesInformation)).to eq names_array
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::SMB2::Packet::ReadRequest do
|
4
|
+
subject(:packet) { described_class.new }
|
5
|
+
|
6
|
+
it { is_expected.to respond_to :smb2_header }
|
7
|
+
it { is_expected.to respond_to :structure_size }
|
8
|
+
it { is_expected.to respond_to :padding }
|
9
|
+
it { is_expected.to respond_to :flags }
|
10
|
+
it { is_expected.to respond_to :read_length }
|
11
|
+
it { is_expected.to respond_to :offset }
|
12
|
+
it { is_expected.to respond_to :file_id }
|
13
|
+
it { is_expected.to respond_to :min_bytes }
|
14
|
+
it { is_expected.to respond_to :channel }
|
15
|
+
it { is_expected.to respond_to :remaining_bytes }
|
16
|
+
it { is_expected.to respond_to :channel_offset }
|
17
|
+
it { is_expected.to respond_to :channel_length }
|
18
|
+
it { is_expected.to respond_to :buffer }
|
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 '#smb2_header' do
|
25
|
+
subject(:header) { packet.smb2_header }
|
26
|
+
|
27
|
+
it 'is a standard SMB Header' do
|
28
|
+
expect(header).to be_a RubySMB::SMB2::SMB2Header
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should have the command set to SMB_COM_NEGOTIATE' do
|
32
|
+
expect(header.command).to eq RubySMB::SMB2::Commands::READ
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should not have the response flag set' do
|
36
|
+
expect(header.flags.reply).to eq 0
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should have a structure size of 49' do
|
41
|
+
expect(packet.structure_size).to eq 49
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::SMB2::Packet::ReadResponse do
|
4
|
+
subject(:packet) { described_class.new }
|
5
|
+
|
6
|
+
it { is_expected.to respond_to :smb2_header }
|
7
|
+
it { is_expected.to respond_to :structure_size }
|
8
|
+
it { is_expected.to respond_to :data_offset }
|
9
|
+
it { is_expected.to respond_to :data_length }
|
10
|
+
it { is_expected.to respond_to :data_remaining }
|
11
|
+
it { is_expected.to respond_to :buffer }
|
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 '#smb2_header' do
|
18
|
+
subject(:header) { packet.smb2_header }
|
19
|
+
|
20
|
+
it 'is a standard SMB Header' do
|
21
|
+
expect(header).to be_a RubySMB::SMB2::SMB2Header
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should have the command set to SMB_COM_NEGOTIATE' do
|
25
|
+
expect(header.command).to eq RubySMB::SMB2::Commands::READ
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should have the response flag set' do
|
29
|
+
expect(header.flags.reply).to eq 1
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should have a structure size of 17' do
|
34
|
+
expect(packet.structure_size).to eq 17
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'stores the offset to the data buffer' do
|
38
|
+
expect(packet.data_offset).to eq packet.buffer.abs_offset
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#data_length' do
|
42
|
+
it 'sets the length of the actual buffer' do
|
43
|
+
packet.data_length = 12
|
44
|
+
packet.buffer = 'hello world!'
|
45
|
+
expect(packet.buffer.length).to eq 12
|
46
|
+
packet.data_length = 5
|
47
|
+
expect(packet.buffer).to eq 'hello'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe RubySMB::SMB2::Packet::SessionSetupRequest do
|
4
|
-
|
5
4
|
subject(:packet) { described_class.new }
|
6
5
|
|
7
6
|
it { is_expected.to respond_to :smb2_header }
|
@@ -36,7 +35,7 @@ RSpec.describe RubySMB::SMB2::Packet::SessionSetupRequest do
|
|
36
35
|
end
|
37
36
|
|
38
37
|
describe '#set_type1_blob' do
|
39
|
-
let(:fake_message) {
|
38
|
+
let(:fake_message) { 'foo' }
|
40
39
|
|
41
40
|
it 'calls the #gss_type1 method to create a blob' do
|
42
41
|
expect(RubySMB::Gss).to receive(:gss_type1).with(fake_message).and_return(fake_message)
|
@@ -57,7 +56,7 @@ RSpec.describe RubySMB::SMB2::Packet::SessionSetupRequest do
|
|
57
56
|
end
|
58
57
|
|
59
58
|
describe '#set_type3_blob' do
|
60
|
-
let(:fake_message) {
|
59
|
+
let(:fake_message) { 'foo' }
|
61
60
|
|
62
61
|
it 'calls the #gss_type3 method to create a blob' do
|
63
62
|
expect(RubySMB::Gss).to receive(:gss_type3).with(fake_message).and_return(fake_message)
|
@@ -76,4 +75,4 @@ RSpec.describe RubySMB::SMB2::Packet::SessionSetupRequest do
|
|
76
75
|
expect(packet.security_buffer_length).to eq fake_message.length
|
77
76
|
end
|
78
77
|
end
|
79
|
-
end
|
78
|
+
end
|