ruby_smb 2.0.11 → 3.0.1
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 +5 -16
- data/examples/auth_capture.rb +28 -0
- data/examples/dump_secrets_from_sid.rb +207 -0
- data/examples/enum_domain_users.rb +75 -0
- data/examples/file_server.rb +76 -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/create_actions.rb +21 -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 +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/nt_status.rb +20 -1
- data/lib/ruby_smb/field/string16.rb +5 -1
- data/lib/ruby_smb/fscc/file_information/file_ea_information.rb +14 -0
- data/lib/ruby_smb/fscc/file_information/file_network_open_information.rb +22 -0
- data/lib/ruby_smb/fscc/file_information/file_stream_information.rb +16 -0
- data/lib/ruby_smb/fscc/file_information.rb +29 -0
- data/lib/ruby_smb/fscc/file_system_information/file_fs_attribute_information.rb +46 -0
- data/lib/ruby_smb/fscc/file_system_information/file_fs_volume_information.rb +19 -0
- data/lib/ruby_smb/fscc/file_system_information.rb +22 -0
- data/lib/ruby_smb/fscc.rb +1 -0
- data/lib/ruby_smb/generic_packet.rb +6 -0
- data/lib/ruby_smb/gss/provider/authenticator.rb +4 -0
- data/lib/ruby_smb/gss/provider/ntlm.rb +13 -3
- data/lib/ruby_smb/ntlm.rb +18 -2
- data/lib/ruby_smb/server/server_client/negotiation.rb +1 -2
- data/lib/ruby_smb/server/server_client/session_setup.rb +44 -33
- data/lib/ruby_smb/server/server_client/share_io.rb +28 -0
- data/lib/ruby_smb/server/server_client/tree_connect.rb +60 -0
- data/lib/ruby_smb/server/server_client.rb +214 -25
- data/lib/ruby_smb/server/session.rb +71 -0
- data/lib/ruby_smb/server/share/provider/disk.rb +437 -0
- data/lib/ruby_smb/server/share/provider/pipe.rb +27 -0
- data/lib/ruby_smb/server/share/provider/processor.rb +76 -0
- data/lib/ruby_smb/server/share/provider.rb +38 -0
- data/lib/ruby_smb/server/share.rb +11 -0
- data/lib/ruby_smb/server.rb +35 -3
- data/lib/ruby_smb/signing.rb +37 -11
- data/lib/ruby_smb/smb1/commands.rb +4 -0
- data/lib/ruby_smb/smb1/pipe.rb +4 -0
- data/lib/ruby_smb/smb1.rb +0 -1
- data/lib/ruby_smb/smb2/bit_field/smb2_header_flags.rb +2 -1
- data/lib/ruby_smb/smb2/commands.rb +4 -0
- data/lib/ruby_smb/smb2/create_context/request.rb +64 -0
- data/lib/ruby_smb/smb2/create_context/response.rb +62 -0
- data/lib/ruby_smb/smb2/create_context.rb +74 -22
- data/lib/ruby_smb/smb2/packet/create_request.rb +44 -11
- data/lib/ruby_smb/smb2/packet/create_response.rb +17 -3
- data/lib/ruby_smb/smb2/packet/query_directory_request.rb +1 -1
- data/lib/ruby_smb/smb2/packet/query_directory_response.rb +2 -2
- data/lib/ruby_smb/smb2/packet/query_info_request.rb +43 -0
- data/lib/ruby_smb/smb2/packet/query_info_response.rb +23 -0
- data/lib/ruby_smb/smb2/packet/tree_connect_response.rb +1 -1
- data/lib/ruby_smb/smb2/packet/tree_disconnect_response.rb +1 -0
- data/lib/ruby_smb/smb2/packet.rb +2 -0
- data/lib/ruby_smb/smb2/pipe.rb +4 -0
- data/lib/ruby_smb/smb2.rb +11 -0
- data/lib/ruby_smb/smb_error.rb +110 -0
- data/lib/ruby_smb/version.rb +1 -1
- data/lib/ruby_smb.rb +2 -0
- data/ruby_smb.gemspec +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/nt_status_spec.rb +6 -2
- data/spec/lib/ruby_smb/field/string16_spec.rb +22 -0
- data/spec/lib/ruby_smb/gss/provider/ntlm/authenticator_spec.rb +4 -0
- data/spec/lib/ruby_smb/gss/provider/ntlm/os_version_spec.rb +1 -1
- data/spec/lib/ruby_smb/server/server_client_spec.rb +36 -53
- data/spec/lib/ruby_smb/server/session_spec.rb +38 -0
- data/spec/lib/ruby_smb/server/share/provider/disk_spec.rb +61 -0
- data/spec/lib/ruby_smb/server/share/provider/pipe_spec.rb +31 -0
- data/spec/lib/ruby_smb/server/share/provider_spec.rb +13 -0
- data/spec/lib/ruby_smb/smb1/pipe_spec.rb +18 -37
- data/spec/lib/ruby_smb/smb2/bit_field/header_flags_spec.rb +8 -2
- data/spec/lib/ruby_smb/smb2/{create_context_spec.rb → create_context/create_context_request_spec.rb} +1 -1
- data/spec/lib/ruby_smb/smb2/packet/create_request_spec.rb +5 -5
- data/spec/lib/ruby_smb/smb2/packet/create_response_spec.rb +9 -5
- data/spec/lib/ruby_smb/smb2/packet/query_directory_response_spec.rb +3 -2
- data/spec/lib/ruby_smb/smb2/pipe_spec.rb +18 -16
- data/spec/support/bin_helper.rb +9 -0
- data.tar.gz.sig +2 -3
- metadata +129 -10
- metadata.gz.sig +0 -0
- data/lib/ruby_smb/dcerpc/rrp_unicode_string.rb +0 -38
- data/lib/ruby_smb/smb1/create_actions.rb +0 -20
- data/spec/lib/ruby_smb/dcerpc/rrp_unicode_string_spec.rb +0 -135
@@ -0,0 +1,38 @@
|
|
1
|
+
RSpec.describe RubySMB::Server::Session do
|
2
|
+
let(:user_id) { 'WORKGROUP\RubySMB' }
|
3
|
+
subject(:session) { described_class.new(rand(0xffffffff), user_id: user_id) }
|
4
|
+
|
5
|
+
it { is_expected.to respond_to :id }
|
6
|
+
it { is_expected.to respond_to :key }
|
7
|
+
it { is_expected.to respond_to :signing_required }
|
8
|
+
it { is_expected.to respond_to :tree_connect_table }
|
9
|
+
it { is_expected.to respond_to :creation_time }
|
10
|
+
|
11
|
+
describe '#initialize' do
|
12
|
+
it 'starts with no signing required' do
|
13
|
+
expect(session.signing_required).to be_falsey
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'starts with no tree connections' do
|
17
|
+
expect(session.tree_connect_table).to be_empty
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'starts in the in progress state' do
|
21
|
+
expect(session.state).to be :in_progress
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#is_anonymous' do
|
26
|
+
it 'is false' do
|
27
|
+
expect(session.is_anonymous).to be_falsey
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when the identity is set to anonymous' do
|
31
|
+
let(:user_id) { RubySMB::Gss::Provider::IDENTITY_ANONYMOUS }
|
32
|
+
|
33
|
+
it 'is true' do
|
34
|
+
expect(session.is_anonymous).to be_truthy
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
RSpec.describe RubySMB::Server::Share::Provider::Disk do
|
2
|
+
let(:name) { 'share' }
|
3
|
+
let(:path) { Dir.getwd }
|
4
|
+
subject(:share_provider) { described_class.new(name, path) }
|
5
|
+
|
6
|
+
it { is_expected.to respond_to :name }
|
7
|
+
it { is_expected.to respond_to :path }
|
8
|
+
it { is_expected.to respond_to :type }
|
9
|
+
|
10
|
+
describe '#TYPE' do
|
11
|
+
it 'is TYPE_DISK' do
|
12
|
+
expect(described_class::TYPE).to eq RubySMB::Server::Share::TYPE_DISK
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#initialize' do
|
17
|
+
it 'sets the name' do
|
18
|
+
expect(share_provider.name).to eq name
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'sets the path' do
|
22
|
+
expect(share_provider.path).to be_a Pathname
|
23
|
+
expect(share_provider.path).to eq Pathname.new(path)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'sets the type correctly' do
|
27
|
+
expect(share_provider.type).to eq RubySMB::Server::Share::TYPE_DISK
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'raises an ArgumentError for an invalid path' do
|
31
|
+
# __FILE__ is not a directory so it's invalid
|
32
|
+
expect { described_class.new(name, __FILE__) }.to raise_error(ArgumentError)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
RSpec.describe RubySMB::Server::Share::Provider::Disk::Processor do
|
38
|
+
let(:session) { RubySMB::Server::Session.new(rand(0xffffffff)) }
|
39
|
+
let(:share_provider) { RubySMB::Server::Share::Provider::Disk.new('share', Dir.getwd) }
|
40
|
+
subject(:share_processor) { described_class.new(share_provider, nil, session) }
|
41
|
+
|
42
|
+
it { is_expected.to respond_to :provider }
|
43
|
+
|
44
|
+
describe '#maximal_access' do
|
45
|
+
# no path specified should be the root of the share
|
46
|
+
context 'with no path specified' do
|
47
|
+
let(:maximal_access) { share_processor.maximal_access }
|
48
|
+
it 'is a FileAccessMask' do
|
49
|
+
expect(maximal_access).to be_a RubySMB::SMB2::BitField::FileAccessMask
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'marks the data as readable' do
|
53
|
+
expect(maximal_access.read_data).to eq 1
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'marks the data attributes as readable' do
|
57
|
+
expect(maximal_access.read_attr).to eq 1
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
RSpec.describe RubySMB::Server::Share::Provider::Pipe do
|
2
|
+
let(:name) { 'share' }
|
3
|
+
subject(:share_provider) { described_class.new(name) }
|
4
|
+
|
5
|
+
it { is_expected.to respond_to :name }
|
6
|
+
it { is_expected.to respond_to :type }
|
7
|
+
|
8
|
+
describe '#TYPE' do
|
9
|
+
it 'is TYPE_PIPE' do
|
10
|
+
expect(described_class::TYPE).to eq RubySMB::Server::Share::TYPE_PIPE
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#initialize' do
|
15
|
+
it 'sets the name' do
|
16
|
+
expect(share_provider.name).to eq name
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'sets the type correctly' do
|
20
|
+
expect(share_provider.type).to eq RubySMB::Server::Share::TYPE_PIPE
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
RSpec.describe RubySMB::Server::Share::Provider::Pipe::Processor do
|
26
|
+
let(:session) { RubySMB::Server::Session.new(rand(0xffffffff)) }
|
27
|
+
let(:share_provider) { RubySMB::Server::Share::Provider::Pipe.new('share') }
|
28
|
+
subject(:share_processor) { described_class.new(share_provider, nil, session) }
|
29
|
+
|
30
|
+
it { is_expected.to respond_to :provider }
|
31
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
RSpec.describe RubySMB::Server::Share::Provider::Base do
|
2
|
+
let(:name) { 'share' }
|
3
|
+
subject(:share_provider) { described_class.new(name) }
|
4
|
+
|
5
|
+
it { is_expected.to respond_to :name }
|
6
|
+
it { is_expected.to respond_to :type }
|
7
|
+
|
8
|
+
describe '#initialize' do
|
9
|
+
it 'sets the name' do
|
10
|
+
expect(share_provider.name).to eq name
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -140,45 +140,26 @@ RSpec.describe RubySMB::SMB1::Pipe do
|
|
140
140
|
expect(pipe.size_on_disk).to eq(nt_create_andx_response.parameter_block.allocation_size)
|
141
141
|
end
|
142
142
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
context 'with \'winreg\' filename' do
|
158
|
-
it 'extends Winreg class' do
|
159
|
-
pipe = described_class.new(tree: tree, response: nt_create_andx_response, name: 'winreg')
|
160
|
-
expect(pipe.respond_to?(:has_registry_key?)).to be true
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
context 'with \'\\winreg\' filename' do
|
165
|
-
it 'extends Winreg class' do
|
166
|
-
pipe = described_class.new(tree: tree, response: nt_create_andx_response, name: '\\winreg')
|
167
|
-
expect(pipe.respond_to?(:has_registry_key?)).to be true
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
context 'with \'svcctl\' filename' do
|
172
|
-
it 'extends svcctl class' do
|
173
|
-
pipe = described_class.new(tree: tree, response: nt_create_andx_response, name: 'svcctl')
|
174
|
-
expect(pipe.respond_to?(:query_service_config)).to be true
|
143
|
+
{
|
144
|
+
netlogon: RubySMB::Dcerpc::Netlogon,
|
145
|
+
srvsvc: RubySMB::Dcerpc::Srvsvc,
|
146
|
+
svcctl: RubySMB::Dcerpc::Svcctl,
|
147
|
+
winreg: RubySMB::Dcerpc::Winreg,
|
148
|
+
samr: RubySMB::Dcerpc::Samr,
|
149
|
+
wkssvc: RubySMB::Dcerpc::Wkssvc
|
150
|
+
}.each do |endpoint, klass|
|
151
|
+
context "with \'#{endpoint}\' filename" do
|
152
|
+
it "extends #{klass} class" do
|
153
|
+
pipe = described_class.new(tree: tree, response: nt_create_andx_response, name: endpoint.to_s)
|
154
|
+
expect(pipe).to be_a klass
|
155
|
+
end
|
175
156
|
end
|
176
|
-
end
|
177
157
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
158
|
+
context "with \'\\#{endpoint}\' filename" do
|
159
|
+
it "extends #{klass} class" do
|
160
|
+
pipe = described_class.new(tree: tree, response: nt_create_andx_response, name: "\\#{endpoint.to_s}")
|
161
|
+
expect(pipe).to be_a klass
|
162
|
+
end
|
182
163
|
end
|
183
164
|
end
|
184
165
|
end
|
@@ -44,8 +44,14 @@ RSpec.describe RubySMB::SMB2::BitField::Smb2HeaderFlags do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
describe '#reserved3' do
|
47
|
-
it 'should be a
|
48
|
-
expect(flags.reserved3).to be_a BinData::
|
47
|
+
it 'should be a 1-bit field per the SMB spec' do
|
48
|
+
expect(flags.reserved3).to be_a BinData::Bit1
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#priority' do
|
53
|
+
it 'should be a 3-bit field per the SMB spec' do
|
54
|
+
expect(flags.priority).to be_a BinData::Bit3
|
49
55
|
end
|
50
56
|
end
|
51
57
|
|
@@ -80,22 +80,22 @@ RSpec.describe RubySMB::SMB2::Packet::CreateRequest do
|
|
80
80
|
expect(packet.name_offset).to eq packet.name.abs_offset
|
81
81
|
end
|
82
82
|
|
83
|
-
it 'tracks the offset to #context in #
|
84
|
-
expect(packet.
|
83
|
+
it 'tracks the offset to #context in #contexts_offset' do
|
84
|
+
expect(packet.contexts_offset).to eq packet.contexts.abs_offset
|
85
85
|
end
|
86
86
|
|
87
87
|
it 'tracks the length of #name in #name_length' do
|
88
88
|
expect(packet.name_length).to eq packet.name.length
|
89
89
|
end
|
90
90
|
|
91
|
-
it 'tracks the length of #context in #
|
92
|
-
expect(packet.
|
91
|
+
it 'tracks the length of #context in #contexts_length' do
|
92
|
+
expect(packet.contexts_length).to eq packet.contexts.do_num_bytes
|
93
93
|
end
|
94
94
|
|
95
95
|
describe '#name' do
|
96
96
|
it 'encodes any input into UTF-16LE' do
|
97
97
|
packet.name = 'Hello'
|
98
|
-
expect(packet.name.to_binary_s).to eq "H\x00e\x00l\x00l\x00o\x00"
|
98
|
+
expect(packet.name.to_binary_s { |name| name.abs_offset = 0; name.write_now! }).to eq "H\x00e\x00l\x00l\x00o\x00"
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|
@@ -54,11 +54,15 @@ RSpec.describe RubySMB::SMB2::Packet::CreateResponse do
|
|
54
54
|
expect(packet.file_id).to be_a RubySMB::Field::Smb2Fileid
|
55
55
|
end
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
describe '#contexts' do
|
58
|
+
# with no context, the offset and length should be 0
|
59
|
+
# see: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/d166aa9e-0b53-410e-b35e-3933d8131927
|
60
|
+
it 'should have the contexts_offset set to 0' do
|
61
|
+
expect(packet.contexts_offset).to eq 0
|
62
|
+
end
|
60
63
|
|
61
|
-
|
62
|
-
|
64
|
+
it 'should have the contexts_length set to ' do
|
65
|
+
expect(packet.contexts_length).to eq 0
|
66
|
+
end
|
63
67
|
end
|
64
68
|
end
|
@@ -30,8 +30,9 @@ RSpec.describe RubySMB::SMB2::Packet::QueryDirectoryResponse do
|
|
30
30
|
expect(packet.structure_size).to eq 9
|
31
31
|
end
|
32
32
|
|
33
|
-
it 'has an offset pointer
|
34
|
-
expect(packet.
|
33
|
+
it 'has an offset pointer of 0 for an empty buffer field' do
|
34
|
+
expect(packet.buffer).to be_empty
|
35
|
+
expect(packet.buffer_offset).to eq 0
|
35
36
|
end
|
36
37
|
|
37
38
|
it 'has a length value for the buffer field' do
|
@@ -146,24 +146,26 @@ RSpec.describe RubySMB::SMB2::Pipe do
|
|
146
146
|
expect(pipe.size_on_disk).to eq(create_response.allocation_size)
|
147
147
|
end
|
148
148
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
149
|
+
{
|
150
|
+
netlogon: RubySMB::Dcerpc::Netlogon,
|
151
|
+
srvsvc: RubySMB::Dcerpc::Srvsvc,
|
152
|
+
svcctl: RubySMB::Dcerpc::Svcctl,
|
153
|
+
winreg: RubySMB::Dcerpc::Winreg,
|
154
|
+
samr: RubySMB::Dcerpc::Samr,
|
155
|
+
wkssvc: RubySMB::Dcerpc::Wkssvc
|
156
|
+
}.each do |endpoint, klass|
|
157
|
+
context "with \'#{endpoint}\' filename" do
|
158
|
+
it "extends #{klass} class" do
|
159
|
+
pipe = described_class.new(tree: tree, response: create_response, name: endpoint.to_s)
|
160
|
+
expect(pipe).to be_a klass
|
161
|
+
end
|
160
162
|
end
|
161
|
-
end
|
162
163
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
164
|
+
context "with \'\\#{endpoint}\' filename" do
|
165
|
+
it "extends #{klass} class" do
|
166
|
+
pipe = described_class.new(tree: tree, response: create_response, name: "\\#{endpoint.to_s}")
|
167
|
+
expect(pipe).to be_a klass
|
168
|
+
end
|
167
169
|
end
|
168
170
|
end
|
169
171
|
end
|
data.tar.gz.sig
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
nMj
|
1
|
+
�˾I}��XdH���t�7q��jc�m<�����ֿ��v���:�HK0��s�2��ǃ�� O���@EH5�F��T�<2����]���}.@��E2�O."}��=�+�N�A��̀�M:�H7D���~|c�q��ݽ�^��
|
2
|
+
�f3_�6���7�YX�w %�:𦅎G������`�8�G1������G \�k9�%꒰��S��Sr�����h�,^ۺ3����V���TIh*�>J��!>,
|