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,26 @@
|
|
1
|
+
module RubySMB
|
2
|
+
module Dcerpc
|
3
|
+
module Epm
|
4
|
+
|
5
|
+
# [2.2.1.2.5 ept_map Method](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rpce/ab744583-430e-4055-8901-3c6bc007e791)
|
6
|
+
# [https://pubs.opengroup.org/onlinepubs/9629399/apdxo.htm](https://pubs.opengroup.org/onlinepubs/9629399/apdxo.htm)
|
7
|
+
class EpmEptMapRequest < BinData::Record
|
8
|
+
attr_reader :opnum
|
9
|
+
|
10
|
+
endian :little
|
11
|
+
|
12
|
+
uuid_ptr :obj
|
13
|
+
epm_twrpt :map_tower
|
14
|
+
ndr_context_handle :entry_handle
|
15
|
+
ndr_uint32 :max_towers
|
16
|
+
|
17
|
+
def initialize_instance
|
18
|
+
super
|
19
|
+
@opnum = EPT_MAP
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module RubySMB
|
2
|
+
module Dcerpc
|
3
|
+
module Epm
|
4
|
+
|
5
|
+
# [2.2.1.2.5 ept_map Method](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rpce/ab744583-430e-4055-8901-3c6bc007e791)
|
6
|
+
class EpmEptMapResponse < BinData::Record
|
7
|
+
attr_reader :opnum
|
8
|
+
|
9
|
+
endian :little
|
10
|
+
|
11
|
+
ndr_context_handle :entry_handle
|
12
|
+
ndr_uint32 :num_towers
|
13
|
+
ndr_conf_var_array :towers, type: :epm_twrpt
|
14
|
+
ndr_uint32 :error_status
|
15
|
+
|
16
|
+
def initialize_instance
|
17
|
+
super
|
18
|
+
@opnum = EPT_MAP
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,211 @@
|
|
1
|
+
module RubySMB
|
2
|
+
module Dcerpc
|
3
|
+
module Epm
|
4
|
+
|
5
|
+
# [Protocol Tower Encoding](https://pubs.opengroup.org/onlinepubs/9629399/apdxl.htm)
|
6
|
+
# [Protocol Identifiers](https://pubs.opengroup.org/onlinepubs/9629399/apdxi.htm#tagcjh_28)
|
7
|
+
|
8
|
+
class EpmFloorInterfaceOrDataIdentifier < Ndr::NdrStruct
|
9
|
+
default_parameters byte_align: 1
|
10
|
+
endian :little
|
11
|
+
|
12
|
+
uint16 :lhs_bytecount, byte_align: 1, initial_value: -> {identifier.num_bytes + interface.num_bytes + major_version.num_bytes}
|
13
|
+
uint8 :identifier, byte_align: 1, initial_value: 0x0d
|
14
|
+
choice :interface, selection: :identifier, byte_align: 1 do
|
15
|
+
# TODO
|
16
|
+
#oid 0
|
17
|
+
uuid :default
|
18
|
+
end
|
19
|
+
uint16 :major_version, byte_align: 1
|
20
|
+
uint16 :rhs_bytecount, byte_align: 1, initial_value: 2
|
21
|
+
uint16 :minor_version, byte_align: 1
|
22
|
+
end
|
23
|
+
|
24
|
+
class EpmFloorProtocolIdentifier < Ndr::NdrStruct
|
25
|
+
default_parameters byte_align: 1
|
26
|
+
endian :little
|
27
|
+
|
28
|
+
uint16 :lhs_bytecount, byte_align: 1, initial_value: -> {prot_identifier.num_bytes}
|
29
|
+
# Protocol Identifiers:
|
30
|
+
# 0x00: "OSI Object Identifier [OID]"
|
31
|
+
# 0x02: "DNA Session Control Phase 4"
|
32
|
+
# 0x03: "DNA Session Control V3 Phase 5"
|
33
|
+
# 0x04: "DNA NSP Transport"
|
34
|
+
# 0x05: "OSI TP4 [T-Selector]"
|
35
|
+
# 0x06: "OSI CLNS [NSAP]"
|
36
|
+
# 0x07: "DOD TCP port"
|
37
|
+
# 0x08: "DOD UDP port"
|
38
|
+
# 0x09: "DOD IP v4 big-endian"
|
39
|
+
# 0x0a: "RPC Connectionless v4"
|
40
|
+
# 0x0b: "RPC Connection-oriented v5"
|
41
|
+
# 0x0c: "MS Named Pipes"
|
42
|
+
# 0x0d: "UUID"
|
43
|
+
# 0x0e: "ncadg_ipx"
|
44
|
+
# 0x0f: "NetBIOS Named Pipes"
|
45
|
+
# 0x10: "MS Named Pipe Name" or "Local InterProcess Communication (LRPC)")
|
46
|
+
# 0x11: "MS NetBIOS"
|
47
|
+
# 0x12: "MS NetBEUI"
|
48
|
+
# 0x13: "Netware SPX"
|
49
|
+
# 0x14: "Netware IPX"
|
50
|
+
# 0x15: "NMP_TOWER_ID"
|
51
|
+
# 0x16: "Appletalk Stream [endpoint]"
|
52
|
+
# 0x17: "Appletalk Datagram [endpoint]"
|
53
|
+
# 0x18: "Appletalk [NBP-style Name]"
|
54
|
+
# 0x19: "NetBIOS [CL on all protocols]"
|
55
|
+
# 0x1a: "VINES SPP"
|
56
|
+
# 0x1b: "VINES IPC"
|
57
|
+
# 0x1c: "StreetTalk [name]"
|
58
|
+
# 0x1d: "MSMQ"
|
59
|
+
# 0x1f: "MS IIS (http)"
|
60
|
+
# 0x20: "Unix Domain socket [pathname]"
|
61
|
+
# 0x21: "null"
|
62
|
+
# 0x22: "NetBIOS name"
|
63
|
+
uint8 :prot_identifier, byte_align: 1, initial_value: 0x0b
|
64
|
+
uint16 :rhs_bytecount, byte_align: 1, initial_value: 2
|
65
|
+
uint16 :minor_version, byte_align: 1
|
66
|
+
end
|
67
|
+
|
68
|
+
class EpmFloorPipeOrHost < Ndr::NdrStruct
|
69
|
+
default_parameters byte_align: 1
|
70
|
+
endian :little
|
71
|
+
|
72
|
+
uint16 :lhs_bytecount, byte_align: 1, initial_value: -> {identifier.num_bytes}
|
73
|
+
# :identifier defines what :name is
|
74
|
+
# 0x10: MS Named pipe name
|
75
|
+
# 0x0c: ncalrpc pipe name (local interprocess communication)
|
76
|
+
# 0x0f: NetBIOS pipe name
|
77
|
+
# default: Host name
|
78
|
+
uint8 :identifier, byte_align: 1
|
79
|
+
uint16 :rhs_bytecount, byte_align: 1, initial_value: -> { name.length }
|
80
|
+
ndr_fixed_byte_array :name, initial_length: :rhs_bytecount
|
81
|
+
end
|
82
|
+
|
83
|
+
class EpmFloorPipeOrPort < Ndr::NdrStruct
|
84
|
+
default_parameters byte_align: 1
|
85
|
+
endian :little
|
86
|
+
|
87
|
+
uint16 :lhs_bytecount, byte_align: 1, initial_value: -> {identifier.num_bytes}
|
88
|
+
# :identifier defines what :pipe_or_port is
|
89
|
+
# 0x10: MS Named pipe name
|
90
|
+
# 0x0c: ncalrpc pipe name (local interprocess communication)
|
91
|
+
# 0x0f: NetBIOS pipe name
|
92
|
+
# 0x07: DOD TCP port
|
93
|
+
# 0x08: DOD UCP port
|
94
|
+
# 0x13: Netware SPX port
|
95
|
+
# 0x14: Netware IPX port
|
96
|
+
# 0x1a: VINES SPP port
|
97
|
+
# 0x1b: VINES IPC port
|
98
|
+
# 0x1f: Default port
|
99
|
+
# default: Default port
|
100
|
+
uint8 :identifier, byte_align: 1, initial_value: 0x07
|
101
|
+
uint16 :rhs_bytecount, byte_align: 1, initial_value: -> { pipe_or_port.num_bytes }
|
102
|
+
choice :pipe_or_port, selection: :identifier, byte_align: 1 do
|
103
|
+
ndr_fixed_byte_array 0x10, initial_length: :rhs_bytecount
|
104
|
+
ndr_fixed_byte_array 0x0c, initial_length: :rhs_bytecount
|
105
|
+
ndr_fixed_byte_array 0x0f, initial_length: :rhs_bytecount
|
106
|
+
uint16be 0x07
|
107
|
+
uint16be 0x08
|
108
|
+
uint16be 0x13
|
109
|
+
uint16be 0x14
|
110
|
+
uint16be 0x1a
|
111
|
+
uint16be 0x1b
|
112
|
+
uint16be 0x1f
|
113
|
+
ndr_fixed_byte_array :default, initial_length: :rhs_bytecount
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
class EpmIpv4Address < BinData::Uint32be
|
118
|
+
default_parameters byte_align: 1
|
119
|
+
end
|
120
|
+
|
121
|
+
class EpmIpxSpxAddress < Ndr::NdrStruct
|
122
|
+
default_parameters byte_align: 1
|
123
|
+
endian :little
|
124
|
+
|
125
|
+
int32 :net, byte_align: 1
|
126
|
+
int48 :node, byte_align: 1
|
127
|
+
end
|
128
|
+
|
129
|
+
class EpmFloorHostOrAddr < Ndr::NdrStruct
|
130
|
+
default_parameters byte_align: 1
|
131
|
+
endian :little
|
132
|
+
|
133
|
+
uint16 :lhs_bytecount, byte_align: 1, initial_value: -> {identifier.num_bytes}
|
134
|
+
# :identifier defines what :host_or_addr is
|
135
|
+
# 0x11: MS NetBIOS host name
|
136
|
+
# 0x12: MS NetBEUI host name
|
137
|
+
# 0x22: NetBIOS name
|
138
|
+
# 0x09: DOD IP v4 address (big-endian)
|
139
|
+
# 0x13: Netware SPX address
|
140
|
+
# 0x14: Netware IPX address
|
141
|
+
# 0x00: IP v6 address
|
142
|
+
# default: Default address
|
143
|
+
uint8 :identifier, byte_align: 1, initial_value: 0x09
|
144
|
+
uint16 :rhs_bytecount, byte_align: 1, initial_value: -> { host_or_addr.num_bytes }
|
145
|
+
choice :host_or_addr, selection: :identifier, byte_align: 1 do
|
146
|
+
ndr_fixed_byte_array 0x11, initial_length: :rhs_bytecount
|
147
|
+
ndr_fixed_byte_array 0x12, initial_length: :rhs_bytecount
|
148
|
+
ndr_fixed_byte_array 0x22, initial_length: :rhs_bytecount
|
149
|
+
epm_ipv4_address 0x09
|
150
|
+
epm_ipx_spx_address 0x13
|
151
|
+
epm_ipx_spx_address 0x14
|
152
|
+
choice 0x00, selection: -> {rhs_bytecount.num_bytes} do
|
153
|
+
ndr_fixed_byte_array 16, initial_length: 16
|
154
|
+
ndr_fixed_byte_array :default, initial_length: :rhs_bytecount
|
155
|
+
end
|
156
|
+
ndr_fixed_byte_array :default, initial_length: :rhs_bytecount
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
class EpmDecodedTowerOctetString < Ndr::NdrStruct
|
161
|
+
default_parameters byte_align: 1
|
162
|
+
endian :little
|
163
|
+
|
164
|
+
uint16 :floor_count, byte_align: 1, initial_value: 5
|
165
|
+
epm_floor_interface_or_data_identifier :interface_identifier
|
166
|
+
epm_floor_interface_or_data_identifier :data_representation
|
167
|
+
epm_floor_protocol_identifier :protocol_identifier
|
168
|
+
epm_floor_pipe_or_host :pipe_or_host, onlyif: -> {self.floor_count == 4}
|
169
|
+
epm_floor_pipe_or_port :pipe_or_port, onlyif: -> {self.floor_count == 5}
|
170
|
+
epm_floor_host_or_addr :host_or_addr, onlyif: -> {self.floor_count == 5}
|
171
|
+
# TODO:
|
172
|
+
#epm_floor4_decnet :session_ctrl, only_if: -> {self.floor_count == 6}
|
173
|
+
#epm_floor5_decnet :nsp_transport, only_if: -> {self.floor_count == 6}
|
174
|
+
#epm_floor6_decnet :nsap_routing, only_if: -> {self.floor_count == 6}
|
175
|
+
end
|
176
|
+
|
177
|
+
class EpmTowerOctetString < Ndr::NdrConfArray
|
178
|
+
default_parameters type: :ndr_uint8
|
179
|
+
end
|
180
|
+
|
181
|
+
# [2.2.1.2.2 twr_t Type](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rpce/7888714d-0c2a-48a0-b39a-6062ee3fd1d7)
|
182
|
+
class EpmTwrt < Ndr::NdrStruct
|
183
|
+
default_parameters byte_align: 4
|
184
|
+
endian :little
|
185
|
+
|
186
|
+
ndr_uint32 :tower_length, initial_value: -> { self.tower_octet_string.num_bytes }
|
187
|
+
epm_tower_octet_string :tower_octet_string
|
188
|
+
|
189
|
+
def assign(val)
|
190
|
+
case val
|
191
|
+
when String
|
192
|
+
self.tower_octet_string.assign(val.bytes)
|
193
|
+
when Array
|
194
|
+
self.tower_octet_string.assign(val.to_ary)
|
195
|
+
when EpmDecodedTowerOctetString
|
196
|
+
self.tower_octet_string.assign(val.to_binary_s.bytes)
|
197
|
+
else
|
198
|
+
super
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
class EpmTwrpt < EpmTwrt
|
204
|
+
default_parameters referent_byte_align: 4
|
205
|
+
extend Ndr::PointerClassPlugin
|
206
|
+
end
|
207
|
+
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module RubySMB
|
2
|
+
module Dcerpc
|
3
|
+
module Epm
|
4
|
+
|
5
|
+
UUID = 'E1AF8308-5D1F-11C9-91A4-08002B14A0FA'
|
6
|
+
VER_MAJOR = 3
|
7
|
+
VER_MINOR = 0
|
8
|
+
|
9
|
+
# Operation numbers
|
10
|
+
EPT_MAP = 0x0003
|
11
|
+
|
12
|
+
require 'ruby_smb/dcerpc/epm/epm_twrt'
|
13
|
+
require 'ruby_smb/dcerpc/epm/epm_ept_map_request'
|
14
|
+
require 'ruby_smb/dcerpc/epm/epm_ept_map_response'
|
15
|
+
|
16
|
+
# Retrieve the service port number given a DCERPC interface UUID
|
17
|
+
# See:
|
18
|
+
# [2.2.1.2.5 ept_map Method](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rpce/ab744583-430e-4055-8901-3c6bc007e791)
|
19
|
+
# [https://pubs.opengroup.org/onlinepubs/9629399/apdxo.htm](https://pubs.opengroup.org/onlinepubs/9629399/apdxo.htm)
|
20
|
+
#
|
21
|
+
# @param uuid [String] The interface UUID
|
22
|
+
# @param maj_ver [Integer] The interface Major version
|
23
|
+
# @param min_ver [Integer] The interface Minor version
|
24
|
+
# @param max_towers [Integer] The maximum number of elements to be returned
|
25
|
+
# @return [Hash] A hash with the host and port
|
26
|
+
# @raise [RubySMB::Dcerpc::Error::InvalidPacket] if the response is not a
|
27
|
+
# EpmEptMap packet
|
28
|
+
# @raise [RubySMB::Dcerpc::Error::EpmError] if the response error status
|
29
|
+
# is not STATUS_SUCCESS
|
30
|
+
def get_host_port_from_ept_mapper(uuid:, maj_ver:, min_ver:, max_towers: 1)
|
31
|
+
decoded_tower = EpmDecodedTowerOctetString.new(
|
32
|
+
interface_identifier: {
|
33
|
+
interface: uuid,
|
34
|
+
major_version: maj_ver,
|
35
|
+
minor_version: min_ver
|
36
|
+
},
|
37
|
+
data_representation: {
|
38
|
+
interface: Ndr::UUID,
|
39
|
+
major_version: Ndr::VER_MAJOR,
|
40
|
+
minor_version: Ndr::VER_MINOR
|
41
|
+
}
|
42
|
+
)
|
43
|
+
tower = EpmTwrt.new(decoded_tower)
|
44
|
+
ept_map_request = EpmEptMapRequest.new(
|
45
|
+
obj: Uuid.new,
|
46
|
+
map_tower: tower,
|
47
|
+
entry_handle: Ndr::NdrContextHandle.new,
|
48
|
+
max_towers: max_towers
|
49
|
+
)
|
50
|
+
response = dcerpc_request(ept_map_request)
|
51
|
+
begin
|
52
|
+
ept_map_response = EpmEptMapResponse.read(response)
|
53
|
+
rescue IOError
|
54
|
+
raise RubySMB::Dcerpc::Error::InvalidPacket, 'Error reading EptMapResponse'
|
55
|
+
end
|
56
|
+
unless ept_map_response.error_status == WindowsError::NTStatus::STATUS_SUCCESS
|
57
|
+
raise RubySMB::Dcerpc::Error::EpmError,
|
58
|
+
"Error returned with ept_map: "\
|
59
|
+
"#{WindowsError::NTStatus.find_by_retval(ept_map_response.error_status.value).join(',')}"
|
60
|
+
end
|
61
|
+
tower_binary = ept_map_response.towers[0].tower_octet_string.to_binary_s
|
62
|
+
begin
|
63
|
+
decoded_tower = EpmDecodedTowerOctetString.read(tower_binary)
|
64
|
+
rescue IOError
|
65
|
+
raise RubySMB::Dcerpc::Error::InvalidPacket, 'Error reading EpmDecodedTowerOctetString'
|
66
|
+
end
|
67
|
+
{
|
68
|
+
port: decoded_tower.pipe_or_port.pipe_or_port.to_i,
|
69
|
+
host: decoded_tower.host_or_addr.host_or_addr.to_i
|
70
|
+
}
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'ruby_smb/error'
|
2
|
+
|
1
3
|
module RubySMB
|
2
4
|
# Contains all the DCERPC specific Error classes.
|
3
5
|
module Dcerpc
|
@@ -16,6 +18,21 @@ module RubySMB
|
|
16
18
|
|
17
19
|
# Raised when an error is returned during a Svcctl operation
|
18
20
|
class SvcctlError < DcerpcError; end
|
21
|
+
|
22
|
+
# Raised when an error is returned during a Samr operation
|
23
|
+
class SamrError < DcerpcError; end
|
24
|
+
|
25
|
+
# Raised when an error is returned during a Wkssvc operation
|
26
|
+
class WkssvcError < DcerpcError; end
|
27
|
+
|
28
|
+
# Raised when an error is returned during a Drsr operation
|
29
|
+
class DrsrError < DcerpcError; end
|
30
|
+
|
31
|
+
# Raised when an error occurs with the underlying socket.
|
32
|
+
class CommunicationError < DcerpcError; end
|
33
|
+
|
34
|
+
# Raised when an error is returned during a Epm operation
|
35
|
+
class EpmError < DcerpcError; end
|
19
36
|
end
|
20
37
|
end
|
21
38
|
end
|